The CreatorCon Call for Content is officially open! Get started here.

How to combine 2 array fields?

Zod
Giga Guru

Hi,

for a string I can do something like this ... current.u_field1 =   current.u_field1 + current.u_field2; current.update();

... but how to do this if both fields are arrays?

Thank you!

1 ACCEPTED SOLUTION

Have a read of this thread about why not to use current.update()



Never use current.update in a Business Rule



try the below script, it's saying, if the current watch list is not empty, get the value and add it to the work notes.



if(!current.watch_list.nil()){


var watch = current.getValue('watch_list');


current.work_notes_list += ',' + watch;


}


View solution in original post

16 REPLIES 16

I know regarding the BR and the current.update() ... was just stupid for a moment .... BUT I found 2 OOB BR that have current.update() within before BR 😉


Opened a HI already to have a look ...



Back to the issue ... still not working.


I tested that on my dev instance and it works just fine.



Are you on the incident table or a scoped app and are both the glide list fields you're working with on the same form?


I'm on a custom table (but global), records are same .. so it should work.


The BR also does what it should do ... except this.


When I just add a single value to u_field2 and have u_field1 empty .. this works:   current.u_field1 = current.u_field2;


This tells me that something is wrong with the code ... ;-(


Stopp. Shit. It worked before as the current.update was there ... no it doesn't either ... there is something wrong.


Need to check again ... . So I hope your code is ok .. will update if I find the issue.


test with 1 value in each field and try:



current.u_field1 += current.u_field2;



When i tried this it just added the 2 sys_id's together hence why i went for the below as glide lists are just a comma separated list of values.



current.u_field1 += ',' current.u_field2



Stick in some gs.logs to tell you what's happening:



var field = current.u_field1.getValue();


var field2 = current.u_field2.getValue();


gs.log('this is the value: ' + field);


gs.log('this is the other value: ' + field2);


current.u_field2 += ',' + field;


gs.log('this is the new value: ' + field2;



Good luck with it and Merry Christmas, i'm off home for the holidays