Create a record in different tables based on catalog item
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-28-2022 04:01 AM
Is it possible to create a record to different tables based on the category that gets chosen on a form? Currently, I'm only able to create a record on a single table when I configure the record producers. I'd like the location of where the record gets created based on the form category and have it be dynamic.
- Labels:
-
Service Catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-28-2022 08:32 AM
Do these other tables extend the task table?
I'm wondering, and I've never tested or tried this before, if you change the table name on the record producer to Task, and then in the script, dynamically set current.sys_class_name based on the category.
if(producer.request_type == 'General Inquire"){
current.sys_class_name = 'incident';
}
else if(producer.request_type == 'Applications'){
current.sys_class_name = 'otherTableName';
}
Like I said, I never tested this before so you would need to thoroughly test.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-31-2022 12:08 AM
Thanks but no luck yet. I've tried to apply the script to the catalog item script area and directly to Catalog Client Script with the On Submit function but didn't work.
Updated script below but didn't work either.
function onSubmit() {
var incRec = new GlideRecord("incident");
if(producer.u_choice_1 == "EAM"){
incRec.initialize();
incRec.u_description = 'short_description';
incRec.comments = '[code]' + producer.u_description + '[/code]';
incRec.u_status = 'Open';
incRec.u_choice_1 = "producer.u_choice_1";
}
}