Not able to change the state of the problem record from 'closed" to "assess"

phr
Tera Contributor

The requirement is to change the state of the problem record from 'closed" to "assess".

On writing the fix script, i see that the state is still in "closed" state .

How to fix the issue as my below code didn't work?

 

var gr=new GlideRecord("problem");
gr.addQuery("numberSTARTSWITHPRB0000055");
gr.query();
while(gr.next()){
gr.state=102; //As per the backend value of the state
gr.active=true;
gr.setWorkflow(false);
gr.update();
}
2 ACCEPTED SOLUTIONS

Chaitanya ILCR
Kilo Patron

Hi @phr ,

 

try this

var gr = new GlideRecord("problem");
gr.addQuery("numberSTARTSWITHPRB0000055");
gr.query();
while (gr.next()) {
    gs.info('record exist ' + gr.getValue('number'));
    gr.state = 102; //As per the backend value of the state
    gr.active = true;
    gr.setUseEngines(false);
    gr.setWorkflow(false);
    gr.update();
}

 

Please mark my answer as helpful/correct if it resolves your query.

Regards,
Chaitanya

 

View solution in original post

Nishant8
Giga Sage

Hello @phr, Closed is considered a final state and state model takes care of not allowing to move it back. and we should avoid this. for testing purpose, you can include following line in your script and try 

 

gr.setUseEngines(false);

 

Regards,

Nishant

View solution in original post

13 REPLIES 13

Hi @Peter Bodelier ,

 

Sure, thank you

GlideFather
Tera Patron

Hi,

check on your State Flows as it is "map" from what state you can go to another state.

For example you cannot go from New to Close, you need to go state by state to Resolve and then Complete to Close...

KamilT_0-1752764441892.png

 

And OOTB Closed records shall be uneditable...

 

———
/* If my response wasn’t a total disaster ↙️ drop a Kudos or Accept as Solution ↘️ Cheers! */


J Siva
Tera Sage

Hi @phr 

I just tried your script in the background script.

It worked.

Note: it's not best practice to move the closed problem to assess state.

var gr = new GlideRecord("problem");
gr.addQuery("numberSTARTSWITHPRB0000055");
gr.query();
if (gr.next()) {
    gr.state = 102; //As per the backend value of the state
    gr.active = true;
    gr.setWorkflow(false);
    gr.update();
}

Nishant8
Giga Sage

Hello @phr, Closed is considered a final state and state model takes care of not allowing to move it back. and we should avoid this. for testing purpose, you can include following line in your script and try 

 

gr.setUseEngines(false);

 

Regards,

Nishant