Workflow - assignment_group Get Emptied On sc_req_item When sc_task Record Is Set To Closed Complete

ronro2
Tera Contributor

Hello guys!

I am currently working with a workflow based on the sc_req_item table. You can see how it looks down below.

 

ronro2_0-1736498036216.png

 

In the first Run Script (Set values on REQ and RITM) activity I have the following script: 

current.opened_by = current.variables.opened_by;
current.u_telefonnummer = current.variables.telefonnummer;


// Hämta request item (sc_req_item)
var reqItem = current; // Detta refererar till det aktuella sc_req_item objektet

// Hämta värdet från variabeln system_affiliation
var affiliation = reqItem.variables.system_affiliation; 

// Sätt assignment_group baserat på användarens val
if (affiliation == 'administrative_systems') {
    reqItem.assignment_group = '402295ce47a6c9189d34c261e36d4387'; //Administrativa system teknisk förvaltning

} else if (affiliation == 'health_care_systems') {
    reqItem.assignment_group = '607d3024db565784ed36384c7c96195f'; //Hälso och Sjukvårdssystem teknisk förvaltning

} else {
    // Om ingen matchning finns kan du sätta assignment_group till null eller någon standardgrupp
    reqItem.assignment_group = '';
}

// Uppdatera objektet
reqItem.update();



var gr = new GlideRecord("sc_request");
gr.addQuery("sys_id", current.request);
gr.query();
if (gr.next()) {
    gr.location = current.variables.adress;
    gr.opened_by = current.variables.opened_by;
	gr.requested_for = current.variables.user;
	
    if (current.variables.which_site) { //If address_correct = "no"  in variable set Location information, which_site populates u_site 
        gr.u_site = current.variables.which_site;
    }
    gr.update();
}

 


As you can see there is an if-statement that decides when to fill specific assignment_group. 

However, when the workflow proceeds to create an sc_task and you put the sc_task to Close Complete, and you then go back to the sc_req_item record, the assignment_group is emptied. 

How come? Have I missed something? A run script of some kind that reassures to reassure to set the assignment_group on the RITM? 

Keep in mind, I'm not great at scripting. 

Thanks in advance! 

2 REPLIES 2

Brad Bowman
Kilo Patron
Kilo Patron

If the pictured script is doing what it is supposed to, and the workflow moves on this script is out of the equation.  It doesn't look like you have anything else in this workflow that would update the assignment_group of the RITM, unless it's in the Set Values activity.  Do you have a workflow that runs on sc_task records?  The more likely place to look is a Business Rule running on the sc_task or sc_req_item table that has an action or a script or calls a Script Include that affects the assignment_group field on the RITM record.

Community Alums
Not applicable

Hi @ronro2 Are you sure that the data you are testing is satisfying the If and else if statement where it is updatig the assignment group field? I do see there is a else statement where you are setting the assignment group to blank. So, I would suggest you to check if the if statements in run scripts are validated correctly.

 

Please like/mark my response if it is in line with your expectation. 

 

Regards,

Gagan k