Is it possible to set the value of URL?

tyagisu
Mega Expert

Hello,

I am moving a scoped application from one instance to another. I have a lot of errors in the update set. I want to skip all of them at once. There are around 213,240 errors. I am planning to use fix script for that. This is the script I am using and not working. I am sure that's not the right way to set  the value of URL field "available_actions".

var gr = new GlideRecord("sys_update_preview_problem");
var qry = 'remote_update_set=7ceb91e9db40ef804718b0f0ef96190c^status=^description=Could not find a table ***** this update requires';
gr.addEncodedQuery(qry);
gr.query();
while (gr.next()) {
gr.available_actions = 'Skip remote update';
gr.update();
}

Any help would be appreciated! 🙂

Thanks in Advance!

Su

1 ACCEPTED SOLUTION

Use the while loop

var gr = new GlideRecord("sys_update_preview_problem");
var qry = 'remote_update_set=7ceb91e9db40ef804718b0f0ef96190c^status=^description=Could not find a table ***** this update requires';
gr.addEncodedQuery(qry);
gr.query();

gs.print("Row Count is: " + gr.getRowCount());

while(gr.next()) {
//You can put gs.action as the action parameter.
var ppa = new GlidePreviewProblemAction(gs.action, gr);
ppa.skipUpdate();
}

View solution in original post

12 REPLIES 12

Michael Ritchie
ServiceNow Employee
ServiceNow Employee

Wow 213k errors.  Is it the same error over and over again?  If so an easier solution may be easier to fix the issue in the update set XML file before you import it.

Yes, it's the same error over and over again. I know I couldn't have easily removed it from the XML but I couldn't export XML file because of this huge size. My system kept getting hanged whenever I try to export the XML file. Therefore I had to retrieve the source from instance directly without export/import.

 

OK dealt with this before as well and there are ways around it.  What happens when you click Export to XML related link is it is duplicating the entire local update set as a remote update set and then redirects to download it.  Since you have a bunch of records, the UI transaction quota is likely timing out.

You can break up this activity manually if you want to go down this route.

1. Via background script, execute the following which will create the remote update set:

// Get the sys_id of your local update set and set the following variable:
var localUpdateSetID = "SYSID-OF-LOCAL-UPDATE-SET";

// get local update set glide record
var updateSet = new GlideRecord("sys_update_set");
updateSet.get(localUpdateSetID);

// call same function as export to XML ui action
var updateSetExport = new UpdateSetExport();
var sysid = updateSetExport.exportUpdateSet(updateSet);

var instanceURI = gs.getProperty("glide.servlet.uri");
var exportURI = instanceURI + "export_update_set.do?sysparm_sys_id=" + sysid + "&sysparm_delete_when_done=true";
gs.log("Use this URI to export the update set: " + exportURI);

2. Capture the URI that is logged on the last line of the script as you will need that in step 4 below.

3. Once that is complete, verify the number of customer updates from the local update set match the remote update set.

4. Once verified, then you can download the update set via the URI that you captured via logging.

 

Once you download the update set you can then edit the XML to correct the issue via your favorite text editor.

 

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Tyagi,

First before updating the record check the rowCount whether exact count you are getting or not. I think it is not straight forward. When you click skip it's an UI action and following is the code inside that.

var ppa = new GlidePreviewProblemAction(action, current);
ppa.skipUpdate();

var gr = new GlideRecord("sys_update_preview_problem");
var qry = 'remote_update_set=7ceb91e9db40ef804718b0f0ef96190c^status=^description=Could not find a table ***** this update requires';
gr.addEncodedQuery(qry);
gr.query();

gs.print("Row Count is: " + gr.getRowCount());
while (gr.next()) {
//gr.available_actions = 'Skip remote update';
//gr.update();
}

Mark Correct if this solves your issue and also mark Helpful if you find my response worthy based on the impact.
Thanks
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader