want to create records in multiple custom tables from one record producer form

Nikhil55
Tera Contributor

I have a requirement like a record producer form that contains a Request Type select box variable. Users when select the choice of that Request Type variable, then a record should get created in that table.

Eg: 'Inquiry' and 'complaint' are two choices and they are also tables. When the user selects 'inquiry' as the Request Type choice in the record producer form, the record should be created in the inquiry table. In this case, record should not be created for the table that is given in record producer form it should only be created in the table of selected choice.

 

7 REPLIES 7

Dan O Connor
ServiceNow Employee
ServiceNow Employee

Unfortunately that is not really how Record Producers work. They provide the ability to take frontend inputs to map directly to the backend table. So it's a one to one relationship. 

You could in theory look into the likes of a Flow to create the Record, but it would get messy.

 

This is where table design is important. Sounds like you created two different tables, Inquiry and Complaint under the assumption that because they are two different 'things' they need a different table.

 

My design here would be having just one table. You can house both complaints and inquiries here. You can even have separate forms for them using Views and View rules.

 

This would let you have one record producer that dependent on the Request type, would then create the relevant record. 

Muhammad Khan
Mega Sage
Mega Sage

Try with record producer script. Something like below should work.

 

var grRecord = new GlideRecord(producer.<select_box_variable_backend_name>);
grRecord.initialize();
grRecord.setValue('<field_name>', producer.<variable_name>);
grRecord.setValue('<field_name>', producer.<variable_name>);
grRecord.setValue('<field_name>', producer.<variable_name>);
// .
// .
// .
grRecord.insert();

Also refer to below link.

Linking a record producer with multiple tables 

 

Record Producer scripts can be useful, but worth remembering that they also still create the record to the originally associated table. So you end up with two records.

 

I think OP is looking to have one Record Producer generate a record to one of two tables. 

Yes, with the above solution it will still create record in table associated to record producer. Is there any method we can achieve this other than record producer?