Service Catalog :

Deepak kathi
Tera Contributor

Hi Developers, 

I have created a Catalog Item and workflow with a single catalog task. when the catalog task state is "Closed Incomplete" then the request item state is in "closed complete". but it should be "Closed incomplete".

and same for the request too, when requested item state is "closed complete", request state should be "Closed Complete" by default. But in my case it's showing "Approved".

 

Please help me solve this problem.

Deepakkathi_0-1707288460585.png

Deepakkathi_1-1707288502216.pngDeepakkathi_2-1707288530851.png

 

 

1 ACCEPTED SOLUTION

shloke04
Kilo Patron

Hi @Deepak kathi ,

You would need to update your workflow as per sample version shown below:

 

1. Right after where you are generating your catalog task, add a Run Script activity block and use the script shared below to resolve this:

 

updateRITM();

function updateRITM() {
    var gr = new GlideRecord('sc_task');
    gr.addEncodedQuery('state=3^request_item=' + current.sys_id);
    gr.query();
    if (gr.next()) {
        current.state =3 ;
        current.update();
    }else{
		current.state =4 ;
        current.update();
	}
}

 

shloke04_0-1707292055140.png

 

 

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

View solution in original post

2 REPLIES 2

Sohail Khilji
Kilo Patron
Kilo Patron

Hi @Deepak kathi ,

 

This can be done in workflow... Did you start creating workflow or flow for this catalog  ? IF yes were are your struck...

 

 


☑️ Please mark responses as HELPFUL or ACCEPT SOLUTION to assist future users in finding the right solution....

LinkedIn - Lets Connect

shloke04
Kilo Patron

Hi @Deepak kathi ,

You would need to update your workflow as per sample version shown below:

 

1. Right after where you are generating your catalog task, add a Run Script activity block and use the script shared below to resolve this:

 

updateRITM();

function updateRITM() {
    var gr = new GlideRecord('sc_task');
    gr.addEncodedQuery('state=3^request_item=' + current.sys_id);
    gr.query();
    if (gr.next()) {
        current.state =3 ;
        current.update();
    }else{
		current.state =4 ;
        current.update();
	}
}

 

shloke04_0-1707292055140.png

 

 

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke