The extract column ‘channels’ needs to be passed as an array, extract from the API Guide.
What do I need to set and where on the XML Mapping so the ‘channels’ extract column is passed as s“SMS”]. Currently it missing the square brackets outside the quotation marks.
I cannot add the square brackets to the value as it passes them inside the brackets when triggered.
Any suggestions?
Regards
Ady
Page 1 / 1
Hi @AdrianEgley
Are you binding only one item in your json array ? If you have multiple elements, then it should serialize your message as a json array with square brackets formatting.
Hi @Saranga Amaraweera
Unfortunately I don’t have permissions to that link.
Currently, I only need to to pass one item or value. Even if I put in two values (separated by a comma), it returns an exception.
Ady
Hi @AdrianEgley ,
With the existing functions on the xml mapping, this requirement looks to be quite tricky to resolve. If you are trying to bind the values with a relationship, then there can be a bit lengthy workaround. What I meant was if you had defined the channels element with a relationship on the relationships for the xml map, may be with a custom view or table (on the custom table you need to insert the record for ‘SMS1, SMS2’) then the framework it self will identify it as a json array and bind the items into it according to the expected format. But you need to have more than one records for channels in it.
Thank you @Saranga Amaraweera,
There’s no relationship the values being passed for channels are static.
This is the exception I am getting.
{"gatewayId":"9e82b965-4fdd-43e0-9135-b8b62d69e037","errors":s{"error":"At least one of SMS, RCS or WhatsApp should be specified","code":"channels_empty"}]}
I have added SMS, RCS as the value and still get the same response.
Just need to understand how to set up in FSM to get the “SMS” value inside square brackets.
Ady
Hi @AdrianEgley ,
The xml map itself is unable to identify whether the element that we need to define is an array or not unless if we define a 1:M relationship with relationships tab. According to your requirement, this is a hardcoded element which has no relationships.
Hence, we need to enforce the xml (framework code serializes the initial xml output into json by the JSONOutboundConnector) to represent the node as a json array here. There is no straightforward method to do this. I did some digging into this and found out this approach. Firstly you need to format your channels element in the following manner. Newtonsoft library will be referred here to format the xml document into json code.
This can be done in the map in the following manner by defining the channel element as a xml template
Copy paste the above xml code on the xml template. Make sure to add your primary node/primary path for the extract column as you do not need to insert it as a child element (This won’t work if you don’t define the extract column). I have used FSMU16 here
Then execute the message from the JSONOutboundConnector. You will get the converted node as an array.
There is one drawback here on the sequence of the message in which I need to check furthermore whereas it’s setting the element as the last node in the json or xml output. I will let you know once I found a fix for this as well.
@Saranga Amaraweera
Thank you so much for this.
Apologies for the late reply (been on annual leave). However I have used the XML as outlined above and the integration is now working.
Also there appears to be no issues with regards to sequencing either.
Thank you once again.
Regards
Ady
@Saranga Amaraweera
Thank you so much for this.
Apologies for the late reply (been on annual leave). However I have used the XML as outlined above and the integration is now working.
Also there appears to be no issues with regards to sequencing either.
Thank you once again.
Regards
Ady
You’re most welcome @AdrianEgley
@Saranga Amaraweera ,
We have the following relation mapping defined for an outbound mapping
When the task_text table has 1 element, the value returned is an object and when there are multiple elements, the value returned is an array. How can we ensure that it is always an array ?