Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Did not get rollback option in related links

Purushotham1992
Tera Contributor

Hi ,

 

Ran wrong script in background script , after realize i want to rollback the script 

but i am unable to see the option rollback in related list 

 

Rollback & Recovery > Script Execution History.

1 ACCEPTED SOLUTION

Bert_c1
Kilo Patron

Hi @Purushotham1992 

 

Thank you for posting, I see there is an "update" there. In this case, I have no idea why you can't role back the script execution, provided you find it. Your issue seems to suggest creating a Support Case.  But then you have 'audit history' for that incident record that you can check. And it seems the update may have failed, as I see in the screenshot you're updating a read-only field 'cmdb_ci'. There is no check for the 'incRec.update()' being successful in your script.

View solution in original post

5 REPLIES 5

Bert_c1
Kilo Patron

Seems there is nothing to rollback. Post your script.

This is my script :

 

      var incRec = new GlideRecord('incident');
            incRec.addQuery('u_partner_ticket_number','!=','');
            incRec.addQuery('u_ebonding_partner','Century Link');
            incRec.addQuery('cmdb_ci','!=','7cd6769cdb417344fb959837db961937'); //'IENV sysID'
            incRec.query();
            if (incRec.next()) {
            incRec.setValue('cmdb_ci','7cd6769cdb417344fb959837db961937'); //'IENV sysID'
            incRec.setWorkflow(false);
            incRec.update();
             gs.print('the updated incident number is'+incRec.number);


}
 
 
and 
 
Result : 
Time: 0:00:04.972 id: intrado_1[glide.20] primary_hash=1929248382 (connpid=3679907) for: SELECT task0.`sys_id` FROM task task0 WHERE task0.`sys_class_name` = 'incident' AND task0.`a_str_49` IS NOT NULL AND task0.`a_str_46` = 'Century Link' AND task0.`cmdb_ci` != '7cd6769cdb417344fb959837db961937' /* intrado012, gs:6FA331ED4711F5505E015052E36D4352, tx:19df9b254799b9505e015052e36d4384, hash:1929248382 */
Background message, type:error, message: Data Policy Exception:
The following fields are read only: Configuration item
*** Script: the updated incident number isINC0493757
 
 
Did any changes happed ? why did not get rollback in related list 

Purushotham1992
Tera Contributor

Purushotham1992_0-1694811037826.png

 

Bert_c1
Kilo Patron

Hi @Purushotham1992 

 

Thank you for posting, I see there is an "update" there. In this case, I have no idea why you can't role back the script execution, provided you find it. Your issue seems to suggest creating a Support Case.  But then you have 'audit history' for that incident record that you can check. And it seems the update may have failed, as I see in the screenshot you're updating a read-only field 'cmdb_ci'. There is no check for the 'incRec.update()' being successful in your script.