Question

How to convert an inbound array into a single string?

  • 25 July 2023
  • 3 replies
  • 71 views

Badge +1

I am seeking to receive an array from our customer’s system and convert it into a single string that we can add as a note.

They are sending the below in the body of their message:
 

"request": {
"site_id": "0085",
"template_id": "1533",
"cross_reference_id": "RTS-326",
"po": "RTS-326",
"priority": "",
"part_id": ["00DN001","00L8367","01L1646","011545A","01L1647"],
"long_description": "Testing scanner order"
}



When reviewing the transaction logs, I can see that all 5 parts were interpreted in the system but only the first part_id, 00DN001, populates in the notes.

<request>
  <site_id>0085</site_id>
  <template_id>1533</template_id>
  <cross_reference_id>RTS-326</cross_reference_id>
  <po>RTS-326</po>
  <priority>
  </priority>
  <part_id>00DN001</part_id>
  <part_id>00L8367</part_id>
  <part_id>01L1646</part_id>
  <part_id>011545A</part_id>
  <part_id>01L1647</part_id>
  <long_description>Testing scanner order</long_description>
</request>

Is there a way to concatenate the multiple part_ids being passed in the array into one string? can it be done with an integration map function, or does it need to be done another way? I was unable to find any detailed information on dealing with arrays in the FSM Connect documentation and would appreciate any assistance.


3 replies

Badge +1

I am also willing to accept an option that will let me turn the array into multiple notes, if it’s not able to be concatenated into one string; i.e., are we able to create 5 notes from the above message instead?

Userlevel 4
Badge +12

Hi @Dean OC ,

There should be a workaround to concatenate the json array with a function and then attach to request notes but this needs to be investigated as I don’t recall a straight forward way to do this. But since you have requested to create 5 notes from the array, it should be possible to create a new relationship on your xml map as below. Make sure to provide the part_id on the extract path. Will let you know in case if I found a way around to achieve your first requirement in the meantime.

 

Badge +1

Thank you very much for your response- I have tried implementing your suggested fix, but when I add “part_id” to the extract xpath, I get the following error:

EXCEPTION   Columns: Text in table Request Text are required.

Reply