Record Producer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-26-2023 03:18 AM
Hello Experts,
I have the below requirements.
There should be 3 options in record producer incident, problem, change-- if the user clicks the incident option then the record should be updated in the incident table and respectively. please guide me.
Thank You

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-26-2023 03:33 AM
Hey,
record producers are always linked to a table. However, a record producer also allows you to run a script, which runs after the record is inserted (this is the Post insert script). Here in the script you can update any target values - including the sys_class_name value (the table value).
Just create a record producer for the "task" table. Then, in the post insert script, update the sys_class_name to the desired value. This kind of class change to a child table is not problematic, as all the task values are also present in the child tables.
Hope this helps,
Regards
Fabian
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-26-2023 03:53 AM
Hi @Mark Wood ,
Hope you are doing great.
Start by creating a catalog item within ServiceNow. You can refer to ServiceNow's official documentation on Service Catalog and Workflow Overview for more information and guidance on this process https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0538590
Within the catalog item, you will need to create a variable that captures the type of request, which in this case includes incident, problem, and change. ServiceNow provides detailed instructions on creating flow Service Catalog variables that can assist you in this step :https://docs.servicenow.com/bundle/sandiego-application-development/page/administer/flow-designer/ta...
After creating the catalog item and defining the appropriate variables, you need to establish a new workflow and associate it with the catalog item. This workflow will determine the sequence of actions and processes that occur when a request is submitted. This linkage ensures that the chosen catalog item drives the subsequent steps. Please refer to the ServiceNow documentation for further guidance on configuring workflows.
In the run script, you can incorporate a check for the catalog item's input variable to determine the type of request selected. Based on this information, you can create a script that dynamically generates records in the respective table—incident, problem, or change—accordingly.
Regards,
Riya Verma
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-26-2023 04:07 AM
Hello @Riya Verma ,
I have written below code
//current.setAbortAction(true);
var i=producer.select_table;
gs.addInfoMessage(i);
if(i==1)
{
var gr=new GlideRecord('incident');
gr.initialize();
gr.description="test";
gr.short_description="test";
gr.insert();
//current.setRedirectURL(gr);
}
//current.setAbortAction(true);
and i have select task table on record producer creation form.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-26-2023 06:33 AM
Hi there ,
the code should be as given below , and this script will be there in workflow as i have specified that it could be done via catalog item , it cant be incorporated in single record producer:
var class = current.variables.<the choice value >// eg incident/problem/change
var gr = new GlideRecord (class);
gr.initialize();
gr.description="test";
gr.short_description="test";
gr.insert();
//current.setRedirectURL(gr);
,
Regards,
Riya Verma