How to iterate the array find some elements & pass their associated values to store in new variable

Rochel hans
Tera Contributor

Hello  @Ankur Bawiskar @Chuck Tomasi @Pradeep Sharma 

 

We have an array retrieved from the "cmdb_ci_rel" table where the array contains the group's and their associated sys-id's but we are unable to iterate the array to find the values and then extract their sys_id to store these values in new variables which later needs to be passed in to another function

 

Sample array : [{"sys_id":"sys-id of the group","name":"group name "},{"sys_id":"sys-id of the group","name":"group name"},{"sys_id":"sys-id of the group","name":"group name"},{"sys_id":"sys-id of the group","name":"group name"}];

 

Can you suggest how we can interate , the group names are based on the CI in addition to certain suffixes of the groups where suffix could be something like approver , manager etc

 

Regards

Rochel 

5 REPLIES 5

Ankur Bawiskar
Tera Patron
Tera Patron

@Rochel hans 

it's an array of json objects so you will require other logic.

Please refer script shared by @Tai Vu 

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader