- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-23-2017 05:48 AM
Hi All,
I am having two arrays. First with the list of variable name in a catalog and second with the list of field names along with their values(Variable names and field name are same). Now I am comparing both the array to find the list of variables whose name is same as the field name in second array. Once I get the list, I wanted to set those field values in catalog item variables.
Any help would be appreciated.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-23-2017 06:14 AM
It sounds like you just need to go through the array and make the assignments.
for (k in array_a) {
array_b[k] = array_a[k];
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-23-2017 05:54 AM
Take a look at ArrayUtil().intersect(). It's built just for this.
http://wiki.servicenow.com/index.php?title=ArrayUtil
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-23-2017 06:05 AM
Thanks Chuck for the quick reply.
I am able to get the list of item which is common in both the arrays. Let's assume Array A is a list of catalog Variable and Array B is a list of the field name. I also have the values of the fields which are present in Array B. I wanted to set the values of variables to item values of Array B.
E.g If Array B has item 'Description' with value 'abc'. I wanted to assign/set this value in my catalog item variable with the name 'Description'.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-23-2017 06:14 AM
It sounds like you just need to go through the array and make the assignments.
for (k in array_a) {
array_b[k] = array_a[k];
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-28-2017 07:32 AM
If I have answered your question, please mark my response as correct so that others with the same question in the future can find it quickly and that it gets removed from the Unanswered list.
If you are viewing this from the community inbox you will not see the correct answer button. If so, please review How to Mark Answers Correct From Inbox View.
Thank you