based on selection of values we would need to create either incident or HR case from record producer

venkram
Tera Contributor

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.

@SumanthDosapati 

@Dr Atul G- LNG 

@Ankur Bawiskar 

@Sid_Takali 

@SAI VENKATESH 

@Community Alums 

@Abhishek Thakur 

3 REPLIES 3

Tony Chatfield1
Kilo Patron

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();

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.

venkram_0-1719506263721.png

 

SAI VENKATESH
Tera Sage
Tera Sage

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