How to create a record in a custom(not the target table) table when we submit a record producer?

HarshitaN
Tera Contributor

How to create a record in a custom(not the target table) table when we submit a record producer?
Note: The table in which we are creating a record is not the target table.

 

 

1 ACCEPTED SOLUTION

amitshishod
Tera Guru

Hello Buddy, there is a script field in record producer inside "What it will contain". There, you can write your code to create a record in a table if it is not the table in which we are storing the data.

 

Below is the script to do this

 

var var_name= new GlideRecord("tablename");

var_name.initialize();

var_name.field_name= producer.variable_name;

var_name.insert();

 

 

Please mark my answer helpful and correct if it helps you.

View solution in original post

3 REPLIES 3

amitshishod
Tera Guru

Hello Buddy, there is a script field in record producer inside "What it will contain". There, you can write your code to create a record in a table if it is not the table in which we are storing the data.

 

Below is the script to do this

 

var var_name= new GlideRecord("tablename");

var_name.initialize();

var_name.field_name= producer.variable_name;

var_name.insert();

 

 

Please mark my answer helpful and correct if it helps you.

Abhishek_Thakur
Mega Sage

Hello @HarshitaN ,

You can easily do it by making the changes in the table field. You can simply provide the any table name in which you want your record producer to be submitted.

Please refer the below screenshot.

Table.png

 

Also, if you have any further doubts on it. Please let me know.

 

I appreciate if you mark my answer as accepted solution and give thumbs up, if it helps you.

Regards,

Abhishek Thakur

Ankur Bawiskar
Tera Patron
Tera Patron

@HarshitaN 

you can use record producer script for this

OR

after insert BR on the target table on which record producer is defined

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader