- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-06-2019 01:43 PM
Hi,
The requirement is to create an emergency change from Incident and transfer some of the field values from Incident to Change Request. I need to get the value from list field "u_brands_affected" on Incident and set those values in CR's list field "u_brands_affected". I could get the values but when I set these values, it only sets the last value from the list. However, I have noticed all the values are there in the log.
This is the code I am using:
var al = current.getDisplayValue('u_om_affected_location');
changeRequest.setDisplayValue("u_affected_locations", al);
var list = current.getDisplayValue('u_brands_affected');
var array = list.split(",");
for (var i=0; i < array.length; i++) {
gs.log("Reference value is: " + array[i]);
//changeRequest.u_brands_affected += array[i];
//changeRequest.setDisplayValue("u_brands_affected", array[i]);
//changeRequest.push("u_brands_affected".sys_id.toString());
changeRequest.setValue("u_brands_affected", array[i]);
}
Thanks in Advance,
Su
Solved! Go to Solution.
- Labels:
-
Change Management

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-06-2019 03:04 PM
Can you try
changeRequest.setDisplayValue('u_brands_affected' , current.u_brands_affected.getDisplayValue());

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-06-2019 01:46 PM
As you are using for loop to set the value and the way it is written is to overwrite previous value
Try this
changeRequest.u_brands_affected = current.u_brands_affected;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-06-2019 01:52 PM
No, it didn't work inside the loop.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-06-2019 02:11 PM
You don't need a loop
Can you share the script that you are currently working on
Script should be something like below
var al = current.getDisplayValue('u_om_affected_location');
changeRequest.setDisplayValue("u_affected_locations", al);
changeRequest.u_brands_affected = current.u_brands_affected;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-06-2019 02:28 PM
This is what I used
var al = current.getDisplayValue('u_om_affected_location');
changeRequest.setDisplayValue("u_affected_locations", al);
changeRequest.u_brands_affected = current.u_brands_affected;