- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-15-2018 06:57 AM
I'm working in a Business Rule and need to update a list field. (which is also a reference field).
Is my syntax correct:
current.listfield = 'something';
or current.listfield = gr.components_impacted; <-components impacted is another list reference field from another form that using the same table as a reference and usually just brings over the sys_id
or current.listfield = gr.components_impacted.getDisplayValue();
I can't get any of these to work. Once I get it to work, I know that I'll have to possibly make sure it's empty first and if not just a "," and then my data.
But the first test just trying to get data into this field. I know I'm missing something really dumb.
The Business Rule is running, because if have another field that I'm updating (a text field) to make sure it's running.
Lisa
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-15-2018 07:06 AM
Hi,
look at this
Updating a List field with a Business Rule
Please mark this as "Correct Answer" if I have given you a sufficient answer to your question.
Best Regards,
Daniele
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-15-2018 07:06 AM
It should just take a comma sep list of sys_id's.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-15-2018 07:06 AM
Hi,
look at this
Updating a List field with a Business Rule
Please mark this as "Correct Answer" if I have given you a sufficient answer to your question.
Best Regards,
Daniele
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-15-2018 07:07 AM
Kemmy, list fields are basically a long string field that stores a comma separated list of SysIDs of records in the associated reference table. So if you are updating this field via script, you need to "push" a SysID into that. Good practice is to first split the current value into an array and check to make sure the value you are pushing into it doesn't already exist.
Example:
var valueToAdd = "123456";
if (current.listfield.toString().indexOf(valueToAdd) == -1) {
var listfieldArray = current.listfield.toString().split(",");
listfieldArray.push(valueToAdd);
current.listfield = listfieldArray.join(",");
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-16-2018 06:36 AM
Thank you all so much I took Michael's code and merged it into the Daniele linke (to get rid of dupes).