In Record Producer, I want to create multiple records in a single submit( Parent --> Child --> Child

Swathi Padighar
Tera Contributor

 

 

Hello All,

 

In Record Producer, I want to create multiple records in a single submit.

 

I am assuming this is the same as when sending a catalog item, where a Request and RequestItem record and catalog task is created at the same time.

Also, when three records (1), (2) and (3) are created, we want to make (2) to (1) and (3) to (2)

 

What I want to know is the following two things.

1. How to create multiple records in a single submit.

2. Also, when three records (1), (2) and (3) are created, we want to make (2) to (1) and (3) to (2)

As mentioned above, the same thing is done in Request and RequestItem and catalog task

If anyone knows where this is done, we would like to know.


want to achieve this with Record Producer 

 

5 REPLIES 5


Sure, you can create multiple records from a single record producer by using server-side scripting. Here's a simple example of how you can do this:

1. Navigate to the record producer you want to modify.
2. In the Script field, you can add a script to create additional records. Here's a simple example:

javascript
// Get the current user
var user = gs.getUser();

// Create the first record
var gr1 = new GlideRecord('table_name_1');
gr1.initialize();
gr1.short_description = 'Record 1';
gr1.caller_id = user;
gr1.insert();

// Create the second record
var gr2 = new GlideRecord('table_name_2');
gr2.initialize();
gr2.short_description = 'Record 2';
gr2.caller_id = user;
gr2.insert();

// Create the third record
var gr3 = new GlideRecord('table_name_3');
gr3.initialize();
gr3.short_description = 'Record 3';
gr3.caller_id = user;
gr3.insert();


Please replace 'table_name_1', 'table_name_2', and 'table_name_3' with the actual table names where you want to create the records.

Remember, this is a simple example. You might need to adjust the script to fit your needs, for example, by setting additional fields or using data from the record producer.

Here are the steps summarized:

- Navigate to the record producer you want to modify.
- Add a script in the Script field to create additional records.
- Use the GlideRecord API to create new records.
- Initialize the new records with the initialize() method.
- Set the fields of the records.
- Insert the records into the database with the insert() method.
- Replace 'table_name_1', 'table_name_2', and 'table_name_3' with the actual table names where you want to create the records.
- Adjust the script to fit your needs, for example, by setting additional fields or using data from the record producer.


nowKB.com