Appending/Updating records field value of one table based on other

SD23
Kilo Contributor

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();

7 REPLIES 7

SD23
Kilo Contributor

The existing table is the application table. Is the line you have proposed the only change needed? Thanks @palanikumar 

 

If it is application table then above change will work

Since  'field on custom table' is list collector field of applications, it return sys_id of all selected application as coma separated text. 

So, you use the above changes. Make sure you are passing correct field name

Thank you,
Palani

SD23
Kilo Contributor

@palanikumar Unfortunately it doesn't seem to have worked. The field I want to append from the custom table to the application table is a reference field but within application table it is a list collector (within the while loop). Outside the loop, I am just referring to the field that is in common, which you have assisted with