Update value in one form from another form

johndarroch
Tera Contributor

I have form A and form B I am looking to update form A the assignment group with the assignment group from Form B when this value is changed in Form B. I tried the following   2 below sorry new to GlideRecords so any help would be awesome.

First 1

ar gr = new GlideRecord('hr_case');
gr.get('number');
gr.assignment_group = current.assignment_group;
gr.update();

Second

var gr = new GlideRecord('hr_case');
gr.AddQuery('number',current.u_hr_case);
gr.Query();
gr.assignment_group = current.assignment_group;
gr.update();

Thanks

John

1 ACCEPTED SOLUTION

Chuck Tomasi
Tera Patron

Hi John,



The key to knowing how to query and update the records is how these two tables are related.



You are obviously looking to update a record on the hr_case table. What field on 'current' is pointing to that table? Put that in the 'FIELD' below.



var gr = new GlideRecord('hr_case');


if (gr.get(current.getValue('FIELD')) { // Replace FIELD with the reference field from the current record that points to hr_case


        gr.assignment_group = current.assignment_group;


        gr.update();


}


View solution in original post

2 REPLIES 2

Chuck Tomasi
Tera Patron

Hi John,



The key to knowing how to query and update the records is how these two tables are related.



You are obviously looking to update a record on the hr_case table. What field on 'current' is pointing to that table? Put that in the 'FIELD' below.



var gr = new GlideRecord('hr_case');


if (gr.get(current.getValue('FIELD')) { // Replace FIELD with the reference field from the current record that points to hr_case


        gr.assignment_group = current.assignment_group;


        gr.update();


}


johndarroch
Tera Contributor

This is what I added with an After condition but nothing



var gr = new GlideRecord('hr_case');


if(gr.get(current.u_hr_case))


gr.assignment_group = current.assignment_group;


gr.update();