- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-20-2018 06:19 AM
Hello, I have a list field on the form much like a watch list. As I add values to the list field and saves the form a new record should be created, this record contains reference to current record and a reference to added value.
I've created a new table and created a system definition>relationships with the field values 'Applies to table-[table I wanted to show the related list], 'Queries from table-[table I've created]. I am stopped here now. Can someone help me move this further? Thanks!
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-20-2018 06:31 AM
I would do this with a business rule that checks the values in the list field and checks the values in the related list and does a compare to see if anything has been added or removed from the list field then updates the related list accordingly. This is where I invite you to take a look at script includes so you can break it down in to atomic pieces of what's being checked and done.
Sample business rule:
Name: Update Related List
Active: true
Insert: true
Update: true
When: After
Table: Your parent table with the list field on it
Condition: current.your_list_field.changes()
Script:
(function executeRule(current, previous /*null when async*/) {
// Get current contents of list field
var currentList = current.your_list_field.split(',');
// Get old value of list field
var oldList = previous.your_list_field.split(',');
// Get the difference of the array
// Your script include to determine what was added/subtracted from the array
// Call script include function to add/remove related records
})(current, previous);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-20-2018 06:31 AM
I would do this with a business rule that checks the values in the list field and checks the values in the related list and does a compare to see if anything has been added or removed from the list field then updates the related list accordingly. This is where I invite you to take a look at script includes so you can break it down in to atomic pieces of what's being checked and done.
Sample business rule:
Name: Update Related List
Active: true
Insert: true
Update: true
When: After
Table: Your parent table with the list field on it
Condition: current.your_list_field.changes()
Script:
(function executeRule(current, previous /*null when async*/) {
// Get current contents of list field
var currentList = current.your_list_field.split(',');
// Get old value of list field
var oldList = previous.your_list_field.split(',');
// Get the difference of the array
// Your script include to determine what was added/subtracted from the array
// Call script include function to add/remove related records
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-20-2018 06:44 AM
Thanks for the reply Chuck. Can you please provide/navigate me to script include that you've mentioned? Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-20-2018 07:47 AM
Chuck, please let me know your input.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-20-2018 06:38 AM
var arrayUtil = new ArrayUtil();
var before_change = [1,2,3,4,5];
var after_change = [2,3,5,6,7];
gs.print('arrayUtil.diff(before_change,after_change) - ' + arrayUtil.diff(before_change,after_change));
gs.print('arrayUtil.diff(after_change,before_change) - ' + arrayUtil.diff(after_change,before_change));
*** Script: arrayUtil.diff(before_change,after_change) - 1,4
*** Script: arrayUtil.diff(after_change,before_change) - 6,7
[0:00:00.004] Total Time