How to populate assignment group of Ctask/ChangeRequest/RITM on incident record assignment group

shaik11
Tera Expert

Hello All,

I have requirement to create an incident record based on the faliure response of thrid party. I am using patch method scripted rest Api. As of now I am using static sysid of the assignment group in the code to populate it in incident record.

 

But I need to populate the value dynamically. 

Can anyone provide the inputs and correct my script on immediate basis to resolve the issue ASAP.

 

Using script:

 var ritm = new GlideRecord('sc_req_item');
    ritm.addQuery('number', uniqid);
    ritm.query();
    if (ritm.next()) {
var ritmSysID = ritm.getUniqueValue();
        var changeNumber = new GlideRecord("change_request");
        changeNumber.addEncodedQuery("u_source_ticket="+ritmSysID); 
        changeNumber.query();
        if (changeNumber.next()) {
var changeTask = new GlideRecord("change_task");
 
changeTask.addQuery('number',packageCTask);
changeTask.query();
if (changeTask.next()) {
                changeTask.work_notes = updt;
 
                if (worknotes == 'successful') {                    
            
changeTask.setValue('u_closure_code', 'Successful');
 
                } if (worknotes == 'failure') {
var incFail = new GlideRecord('incident');
                    incFail.initialize();
changeTask.setValue('state', -5);
                    incFail.short_description = "Based on update c-task failed";
                    incFail.assignment_group = "28646fab4fa36240b2343f8210c786"; // Need to populated this value dynamically
                    changeTask.setValue('u_reason_for_closure', 'Failed');  
                  
incFail.insert();

 

Regards

Muneera.

 

 

 

4 REPLIES 4

Tony Chatfield1
Kilo Patron

Hi, where you state the group needs to be populated 'dynamically', what exactly does this depend on\what is the relationship between the required incident group and the change request or change task group?

In your script you can dot.walk an assignment group from one of your returned gliderecords, (as long as the task has an assignment group) eg

incFail.assignment_group = changeNumber.assignment_group;
//OR
incFail.assignment_group = changeTask.assignment_group;

 

 

DYCM
Mega Sage

Hi @shaik11 ,

Where does the assignment group come from? From the third party or there is a logic to pick up from ServiceNow? Please provide details

Hi 

 

Need to populate the same change request/ task assignment group in the incident record from servicenow only.

 

Regards,

Muneera

If that's the case, I believe @Tony Chatfield1  has provided you the answer.