How to create record in custom table when a record is created and updated in other custom table?

karishma shaik
Tera Contributor

Hi , 

 

I have a Business Requirement ,where - 'If a record gets inserted / Updated in a custom table then same respective record should be created / updated in another custom table'. What script needs to be used in this type of scenario 's.

 

Please Help me on this

5 REPLIES 5

Saurav11
Kilo Patron
Kilo Patron

Hello,

 

Write a after insert BR  on the 1st table write the below script for getting the record created on 2nd table whenever the 1st table record  is created

 

var gr= new GlideRecord('yoursecondtablename');
gr.initialize();
gr.fieldname1secondtable=current.fieldname1firsttable;
gr.fieldname2secondtable=current.fieldname2firsttable;
gr.insert();

 

Please mark my answer as correct based on Impact.

 

Hello,

 

If my answer helped you can you also mark it as correct.

 

Thanks.

GodOfWar
Mega Guru

Since you have the same fields from some other table you may create a BR to Insert/Update the same record. You may use the scripts provided by the other members just for the insert. 

SuhasPSalunkhe
Kilo Guru

You have to write Business rule to achieved this -

After Insert - BR should written on first table and in script you have to insert details in another table.

 

After Update/Async - BR should written on first table and in script you have to update details in another table.