REST Message via Flow Designer Action

Naveen87
Tera Guru

Hello Developers,

I'm trying OUTBOUND integration from Flow Designer.
I have created a custom action.
I want to fetch the partner ticket from the response received & store on correlation ID on my Instance.

Below is my script, But unsuccessful.

Please suggest


outputs.correlation_id = responseBody.result.u_partner_ticket_id;

 

Naveen87_0-1714036873979.png

(function execute(inputs, outputs) {

 if(inputs.status_code == '201'){
   var group = inputs.u_shr_assignment_group.getDisplayValue() + ',' + inputs.u_shr_priority + ',' + inputs.u_shr_company;
   var responseBody = JSON.parse(inputs.response_body);
   outputs.correlation_id = responseBody.result.u_partner_ticket_id;
   outputs.description = group; 
}


})(inputs, outputs);

 

Naveen87_1-1714036975549.png

 

5 REPLIES 5

James Chun
Kilo Patron

Hi @Naveen87,

 

From the screenshot, it seems like the value of the key 'u_partner_ticket_id' is empty. Have you tried an input that has a value of the same key?

 

If it still not working, what is the data type of the 'response_body' input?

 

Can you also share the actual text (not a screenshot) of the object you shared above?

 

Cheers

@James Chun ,

Thank you. That makes sense.

I tried with u_number & it is returning the value.

 

Naveen87_0-1714039314645.pngNaveen87_1-1714039342946.png

 

u_partner_ticket_id will hold the incident number of other instance.

It's not returning the value because assignment_group is passing the sys_id.

It should pass the display value.

I tried below but still the same. Can you please suggest where to use getDisplayValue();

Naveen87_2-1714040030879.png

Naveen87_3-1714040076906.png

 

 

 

It worked.

I dot-walked till Name

Naveen87_4-1714040583504.png

 

Sohail Khilji
Kilo Patron
Kilo Patron

Hi @Naveen87 ,

 

Your code almost seems fine try the below code :

 

(function execute(inputs, outputs) {
    try {
        if (inputs.status_code == '201') {
            var responseBody = JSON.parse(inputs.response_body);
            if (responseBody.result && responseBody.result.u_partner_ticket_id) {
                outputs.correlation_id = responseBody.result.u_partner_ticket_id;
                outputs.description = inputs.u_shr_assignment_group.getDisplayValue() + ',' + inputs.u_shr_priority + ',' + inputs.u_shr_company;
            } else {
                gs.error("Response body does not contain the expected structure or field");
            }
        } else {
            gs.error("Unexpected status code received: " + inputs.status_code);
        }
    } catch (e) {
        gs.error("An error occurred: " + e);
    }
})(inputs, outputs);

 

I hope it works...


☑️ Please mark responses as HELPFUL or ACCEPT SOLUTION to assist future users in finding the right solution....

LinkedIn - Lets Connect