Hello team.
I'm having trouble capturing a field from an array within a request message in JSON format, capturing the character in the first position of the string, validating it, and mapping it to an XML field (this is the format recognized by the backend).
I have code in a gatewayScript that obtains the request body, validates the array, extracts the string from the desired field, extracts the first character from the string, validates it, and captures it in a context variable. However, when invoking that context variable in the map node, I'm unable to send the output.
I've used different ways to invoke the variable containing the data, such as:
$(fieldValue);
$(request.body.fieldValue);
I've also tried directly accessing the desired field as follows:
$(request.body.documents[0].buyer[0].code);
$(request.body.documents[0].buyer?.code);
I've attached the request JSON and XML.
The JSON input message field is the first "code" of the first "buyer" object.
After harmonizing it, it should be mapped to the unique "country" tag in the XML.
I greatly appreciate your suggestions.
------------------------------
Jimmy Perilla
------------------------------