
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-22-2017 02:50 AM
Hi,
for a string I can do something like this ... current.u_field1 = current.u_field1 + current.u_field2; current.update();
... but how to do this if both fields are arrays?
Thank you!
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-22-2017 04:08 AM
Have a read of this thread about why not to use current.update()
Never use current.update in a Business Rule
try the below script, it's saying, if the current watch list is not empty, get the value and add it to the work notes.
if(!current.watch_list.nil()){
var watch = current.getValue('watch_list');
current.work_notes_list += ',' + watch;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-22-2017 03:34 AM
It really depends what you need to do, if you just need to populate one list with another you can use getValue() and setValue():
var list1 = current.getValue('u_list_1');
current.setValue(u_list_2', list1);
if you need to add a value you ca use +=
current.u_list_1 += ',' + current.u_reference_1;
These are, i guess, simpler options but listUtils offers more utility.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-22-2017 03:47 AM
This looks more like what I was looking for, but does not seem to work.
I tried:
var newVar = current.getValue('u_field2');
current.setValue('u_field1',newVar);
current.update();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-22-2017 03:54 AM
Where are you configuring this? An after update business rule? If you're changing values on the current form you should use a before update BR and don't use current.update(). Both of these list fields are on the same form right?
I just tested from a fix script and the below worked out fine.
var gr = new GlideRecord("incident");
gr.addQuery("number", "INC0236943");
gr.query();
if (gr.next()) {
var work = gr.getValue('work_notes_list');
gr.setValue('watch_list', work);
gr.update();
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-22-2017 04:01 AM
OMG - forget the current.update() !
... yes is BR before update.
Anyhow - not working.
IF you are on an incident and you would like to move all people from watch_list and add the to the people already in the work_notes_list ... this would fit close to what I need to achieve ...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-22-2017 04:08 AM
Have a read of this thread about why not to use current.update()
Never use current.update in a Business Rule
try the below script, it's saying, if the current watch list is not empty, get the value and add it to the work notes.
if(!current.watch_list.nil()){
var watch = current.getValue('watch_list');
current.work_notes_list += ',' + watch;
}