How can I add the "Add to Update Set Button" to my config pages?

josh_tessaro
Giga Expert

I see a bunch of screenshots on the community forms where admins have an Add To Update Set button on configuration records, is this part of a plugin or a custom add?

Matt Saxton

1 ACCEPTED SOLUTION

Tyler Hoge - Gl
Tera Guru

The "Add To Update Set" button is a Global UI action.



also, "Show Insert" and "Show update" are marked true.



the condition for this button is gs.hasRole("admin")




here is the script that is run.



//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().hasAttribute('update_synch') ||current.getED().hasAttribute('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


    if (typeof GlideUpdateManager2 != 'undefined')


          var um = new GlideUpdateManager2();


    else


          var um = new Packages.com.glide.update.UpdateManager2();


    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);


}



you will also get an "Add To Update Set" button to your "Add To Update Set" button


6-2-2015 10-13-52 AM.png


View solution in original post

6 REPLIES 6

Michael Ritchie
ServiceNow Employee
ServiceNow Employee

Tyler Hoge - Gl
Tera Guru

The "Add To Update Set" button is a Global UI action.



also, "Show Insert" and "Show update" are marked true.



the condition for this button is gs.hasRole("admin")




here is the script that is run.



//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().hasAttribute('update_synch') ||current.getED().hasAttribute('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


    if (typeof GlideUpdateManager2 != 'undefined')


          var um = new GlideUpdateManager2();


    else


          var um = new Packages.com.glide.update.UpdateManager2();


    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);


}



you will also get an "Add To Update Set" button to your "Add To Update Set" button


6-2-2015 10-13-52 AM.png


josephd_liberat
Kilo Contributor

Has anyone added this option to the "Actions on selected rows" drop down menu?   If so, how should script be written?


If you download the version from Share that I posted above, it shows up as a Related Link on an individual record and also shows up as a list action in the drop down at the bottom of the list.