cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Add multiple values to request variable in Cloud Workflow Service Task?

karanbahl
Active Participant
0 Likes
993

Hi All,

Is there a way to add multiple values for PATCH operation in Cloud Workflow Service Task? Currently, the framework allows one as indicated in the below screenshot?

When I am passing the variable as {context}; I am getting payload deserialization error.

I want to pass {context.status} and another field; for example {context.field2}

Any input: tobias.breyer , archana.shukla ?

Regards,

Karan

Accepted Solutions (1)

Accepted Solutions (1)

tobias_breyer
Product and Topic Expert
Product and Topic Expert

The type of the request variable, like object or array, effectively determines the main characteristics of the content that is sent over the wire. If you could specify several variables, the question would be how they would be put together. That's why you can only specify a single variable, the overall structure is clear then.

What a certain structure is acceptable/parseable/deserializable, depends on the service you want to call. I guess this one does not like to receive any other than the expected fields and thereby fails the deserialization.

But you can build any appropriate structure with the help of the script tasks. You store a new variable with the appropriate contents into the context and then use that one as request variable.

karanbahl
Active Participant
0 Likes

I am using the following syntax in script task; however the UpdatedStatus field is available as a part of the context.

In case I want to add one more field; Do I create another variable for context or a dummy variable? Any suggestions?

//Existing
$.context.UpdatedStatus = {
    "UpdatedStatus": "Actioned & Completed"
};
//Proposed
$.context.UpdatedStatusandField = {
    "UpdatedStatus": "Actioned & Completed",
    "Field2":"value"

};
tobias_breyer
Product and Topic Expert
Product and Topic Expert

You might want to keep the top-level variables (UpdatedStatus, UpdatedStatusandField) as few as possible. You might want to use an even deeper structure to keep track of what a variable is used for.

For example,

$.context.patchData = {

service1: {

status: "Actioned & Completed",

field2: "value2"

},

service2: {

status: "Open",

field3: "value3"

}

};


In the service task calling service1 with PATCH, you would use ${context.patchData.service1} for request variable. In service2, you would call ${context.patchData.service2}, etc.

But that's just a matter of what brings structure and understandabiltiy into the workflow.

karanbahl
Active Participant
0 Likes

Thanks Tobias, I have got it working using the same concept.

Answers (0)