Adding a field to a dispatcher JSON output with InvokeMethod (within desired place)

Hey there,

I am trying to add a field to a JSON at dispatcher level to pass on to the performer and can’t seem to get it positioned correctly.

It works like this:
Dispatcher picks up JSON from system → Dispatcher adds field to JSON → passes to Performer to process

I have used an ‘invoke method’ to do this, but it adds the field outside of the JSON itself and I want it within it.

Example JSON (I put X in the field for data protection reasons):

{
“Source”: {
“LeadId”: “X”,
“GridId”: “X”,
“LastModifiedDate”: “X”
},
“AdditionalData”: {
“CapId”: X,
“CapCode”: “X”,
“Accessories”: ,
“Ply”: X,
“StockSource”: “X”,
“Vehicle”: “X”,
“Manufacturer”: “X”,
“Range”: “X”,
“Model”: “X”,
“ListPrice”: X,
“ModelYear”: X,
“ExpiringQuote”: X
},
“MessageID”: “1234567”
}

I added the MessageID field to the target Json object as below, but as you can see, it is on the outside of the JSON and I require it under the ‘AdditionalData’ bracket:

Could anyone please help? Its driving me crazy aha.

Thank you!

When you want MessageID inside to the AdditionalData then ensure:

  • invoke the method on: yourJObjectVar("AdditionalData").Value(Of Object)
1 Like

As an alternate we can make use of a shortcut by using an Assign Activity instead of an Invoke Code

Before:
grafik

Assgin Activity:
myJObject("AdditionalData")("MessageID") = "1234"
grafik

Result:
grafik

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.