based on selection of values we would need to create either incident or HR case from record producer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-25-2024 08:09 PM
Could someone please help me how to create either incident or HR case based on selection of variable values on the single record producer form.
@Community Alums
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-25-2024 08:45 PM
Hi assuming you are population some variable in your producer that maps directly or indirectly to the target table then you should be able to populate required fields via script. As a basic guide
var someValue = producer.variableForTableName;
var newTask = new GlideRecord(someValue);
newTask.initialize();
// common fields eg
newTask.short_description = producer.variableForShortDescription;
//table specific fields
if(someValue == 'incident') {
test.caller_id = producer.userVariable;
} else if(someValue == 'sn_hr_core_case') {
newTask.subject_person = producer.userVariable;
}
newTask.insert();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-27-2024 09:40 AM - edited 06-27-2024 09:42 AM
Hi @Tony Chatfield1 ,
thanks for above suggestion. it really helps me create both either incident or hr case however after incident is submitted then I cannot able to view the details. Here is the below snap. the incident's which are in disabled are the one's are created from record producer where we can create either incident or hr case from Employee portal also cannot able to view the details of the incidnet. and more over we cannot able to see the tickets which are created for HR cases. Could you please help me.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-25-2024 08:46 PM - edited 06-25-2024 08:47 PM
Hi @venkram
You can try the below code in the script of record producer.
var recordType = producer.ticket_creation; //your field name
if (recordType == 'incident') {
var gr = new GlideRecord('incident');
gr.initialize();
gr.short_description = producer.short_description; // please add more fields if required
gr.caller_id = producer.opened_by;
gr.insert();
} else if (recordType == 'Hrcase') {
var gr = new GlideRecord('sn_hr_core_case');
gr.initialize();
gr.short_description = producer.short_description; // please add more fields if required
gr.opened_by = gs.getUserID();
gr.insert();
}
Thanks and Regards
Sai Venkatesh