Absent Member.. Absent Member..
Absent Member..

(SM) Support Tip: How to append unique values to an array instead of replacing via WS

Sometimes when using Web Services to update records in SM you will have to use Array type fields, and you will find yourself on the problem that the WS will overwrite the entire array, which is the expected behavior but not always will make sense, so here's some code can help you modify that: 


The following code will add unique values to an array instead of overwriting the entire array when doing update push actions to SM when using web services.


The code will be placed on the extaccess record corresponding to the web service that is being used:


  1. Go to  System Administration -> Tailoring -> Web Services -> WSDL Configuration
  2. Look for the extaccess record that matches the web service used
  3. Under the Expressions tab add the following code, where support.groups would be the name of the array:


if (not same(support.groups in $L.file.save, support.groups in $L.file)) then ($L.proceed=true) else ($L.proceed=false)

if $L.proceed then ($L.before=nullsub(support.groups in $L.file.save, {});$L.after=nullsub(support.groups in $L.file, {}))

if $L.proceed then ($L.result=$L.before+$L.after;$L.max=lng($L.result);support.groups in $L.file={})

if $L.proceed then for $L.loop = 1 to $L.max do (if (index($L.loop in $L.result, support.groups in $L.file)=0) then (support.groups in $L.file=insert(support.groups in $L.file, 0, 1, $L.loop in $L.result)))


4.    Save the record



This can be used for CIT integrations, third party push jobs, and basically whenever you consume a WS from SM. 


Labels (1)
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.