Run Script to Add/Delete on Related List
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2017 05:44 AM
Anyone have any examples of adding/removing items from a related list via a Run Script in a workflow? I am not finding much in my Google searches and I have a related list on our sys_user records and I wanted to update via a Run Script in a workflow.
Please mark this response as correct and/or helpful if it assisted you with your question.
Steven
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2017 08:12 AM
Steven,
button "Edit" inserts (adds if you will) new records into table - that is how mechanisms work.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2017 08:15 AM
Correct....but how do I connect to that Related List specifically on the correct user record? I don't want to add or remove anything from the custom "Founders Application List" table. I just need to insert into that related list.
Please mark this response as correct and/or helpful if it assisted you with your question.
Steven
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2017 08:20 AM
But isn't that what I'm trying to tell you? *)'
Related list is the filtered piece of a table that is filtered by a field value. In your case I've asked you if that is the "User Access" field.
And therefore you providing gr.u_user_access value when you adding record via script - so it will only appear for specific user record.
If you not sure - you might need someone close to you who may help with scripting.
P.S> You also may right click on related list filter and open in new window to see what table and field values are provided. This will provide you with more understanding of the right way to go.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2017 08:30 AM
I do see what you are saying....let me try that.
Please mark this response as correct and/or helpful if it assisted you with your question.
Steven

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2017 06:11 AM
Hi Steven,
You can insert a record in m2m table using GlideRecord, in case you checked it, Delete it in case it is Remove Access.
Please create a Business Rule and run the scripts which will fulfillment your requirements.
Insert -> true
Table -> Request Item
Filter Condition -> item is <Item Name>
if(current.variables.<variable name for access type> == <ADD Drop Down Value>)
script to INSERT --> http://wiki.servicenow.com/index.php?title=GlideRecord#Insert_Methods
else if(current.variables.<variable name for access type> == <REMOVE Drop Down Value>)
script to DELETE ---> http://wiki.servicenow.com/index.php?title=GlideRecord#Delete_Methods&gsc.tab=0