2017-09-22 3 views
0

Ich möchte Nachricht in Maultier-Anwendung basierend auf einigen Bedingungen zu transformieren.Zustand in Transform Nachricht - Mule

%dw 1.0 
%output application/json 
--- 
{ 
    **// create the below if the size of payload is greater than 0** 
    resource_type : "speciality", 
    speciality_name : payload[0].speciality_name, 
    speciality_description : payload[0].speciality_description, 
    uuid : payload[0].uuid 

    **//else create the below message** 
    message : "No records were fetched from backend" 
} 

Könnte bitte jemand mir bitte dabei helfen ?.

Antwort

4

Sie können verwenden, wenn andere Bedingung dafür. Wie

%dw 1.0 
%output application/json 
--- 
{ 
    // create the below if the size of payload is greater than 0** 
    resource_type : "speciality", 
    speciality_name : payload[0].speciality_name, 
    speciality_description : payload[0].speciality_description, 
    uuid : payload[0].uuid 
} when payload != null and (sizeOf payload) > 0 otherwise 
{ 
    //else create the below message** 
    message : "No records were fetched from backend" 
} 

Hoffe das hilft.