Force records to update sets




There are a few ways to force records to update sets.

Here are three ways how to do it:

Force records to update sets via a simple background script


var tableName = "topic"; // table name
var encodedQuery = ""; // encoded query => the same you have on the list view => "Copy query"

// code
var gr = new GlideRecord(tableName);
gr.addEncodedQuery(encodedQuery);
gr.query();
while (gr.next()) {
   var um = new GlideUpdateManager2();
   um.saveRecord(gr);
}

Case scenario: add groups that start with an A to update set


Force records to update sets via a UI action

//Commit any changes to the record
current.update();
 
//Check to make sure the table isn't synchronized already
var tbl = current.getTableName();
if(tbl.startsWith("wf_") || tbl.startsWith("sys_ui_") || tbl == "sys_choice" || current.getED().getBooleanAttribute("update_synch") || current.getED().getBooleanAttribute("update_synch_custom")){
   gs.addErrorMessage("Updates are already being recorded for this table.");
   action.setRedirectURL(current); 
}
else{
   //Push the update into the current update set
   var um = new GlideUpdateManager2();
   um.saveRecord(current);
 
   //Query for the current update set to display info message
   var setID = gs.getPreference("sys_update_set");
   var us = new GlideRecord("sys_update_set");
   us.get(setID);
 
   //Display info message and reload the form
   gs.addInfoMessage("Record included in <a href="sys_update_set.do?sys_id=' + setID + '">' + us.name + '</a> update set.");
   action.setRedirectURL(current);
}

Case scenario: force a catalog item to be added to update set

This is a nice solution for forcing data or configs that have not been captured in the update set initially.


Force records to update sets via the "Add to Update Set Utility" global UI Action

Case scenario: force any data or config to update set

This is the best solution for adding any record (plus attachments & translations) to the active update set.


Steps for installation:
  1. Download the XML file (see reference link)
  2. Import the XML file in your instance
  3. Navigate to Retrieved Update Sets
  4. Open the respective update set 
  5. Preview update set
  6. Commit update set

The "Add to Update Set" app should be set up and you should be able to use this amazing functionality!


You can add stuff to the update set via the Related Link UI action or via a drop-down menu option on each list

Note:

What I noticed is that when you add a record to an update set within an App Scope (in a Scoped update set), the Scoped update set gets automatically copied/duplicated to the Global Scope (as you can see in the image):



As weird as it may look this still will work when you migrate the Batch Update Set or the individual Global update set to another instance.

For more context check this community question.



Comments

Popular Posts