Appending/Updating records field value of one table based on other
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-12-2022 02:23 AM
Hi All,
I have created a custom table which has a field which contains a list of applications. I would like to be able to create a BR which upon creation of the row within this custom table, will update/append to a particular list field within the application table. I have tried doing this however it does not seem to work.
I have set the BR to after and ticked insert (please let me know if I have done wrong). The code I have used is below:
var gr=new GlideRecord('existing table');
gr.addQuery('field on existing table' ,'CONTAINS', 'field on custom table');
gr.query();
while(gr.next()){
gr.field = gr.field+ current.field; /*gr.field is relating to the one on exisiting table which I wish to append current.field too */
gr.update();
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-12-2022 02:30 AM
Hi,
Your requirement is not clear. Answer the below questions
- You mentioned that the custom table stores list of applications. Is it a reference field or List field?
- Where are you running the BR? on the Custom table or application table
- What is the existing table refers in the BR? custom table or application table or any other table?
- What is the type of field on existing table and field on custom table?
Palani
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-12-2022 04:54 AM
Hi,
- It is a list field
- I was running the BR on the custom table as when an entry is created there it should update on the app table
- not sure what you mean? but the BR refers to the app table
- Exisiting table it is String, custom table it is within a list - I want to be able to say where it is contained within that string, like an In function
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-12-2022 05:30 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-12-2022 06:00 AM
Hi
What is "existing table"? is it application table or any other table not mentioned in your post?
If it is application table and Business rule is running on the custom table then your code should be below:
gr.addQuery('sys_id' ,'IN', current.field_on_custom_table);
//replace field_on_custom_table with actual field name
Thank you,
Palani
Palani