Update Sets should be named uniquely

Aakhiil
Tera Expert

Hi Experts,

I have one requirement like  "When I create a update set that name should be unique. Its not be same as existing update set. if existing and newly created update set is same  need to notify while saving with error popup " Update set name is already in our records so please change the name " 

And Duplicate update sets should be removed or renamed if being used for active development.

I am not sure how to be proceed. Need your assistance on it. Any help will be appreciated. 

Thanks in advance 

1 ACCEPTED SOLUTION

Hi,

you can also make Name field on "sys_update_set" as Unique at dictionary level

BR Script If required

(function executeRule(current, previous /*null when async*/) {

	// Add your code here
	var gr = new GlideRecord("sys_update_set");
	gr.addQuery("name", current.getValue('name'));
	gr.setLimit(1);
	gr.query();
	if (gr.hasNext()) {
		gs.addErrorMessage("Please give unique update set name.");
		current.setAbortAction(true);
	}

})(current, previous);

regards
Ankur

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

View solution in original post

6 REPLIES 6

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

you will have to create before insert business rule on "sys_update_set" table and create your own logic.

regards
Ankur

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

Hi,

you can also make Name field on "sys_update_set" as Unique at dictionary level

BR Script If required

(function executeRule(current, previous /*null when async*/) {

	// Add your code here
	var gr = new GlideRecord("sys_update_set");
	gr.addQuery("name", current.getValue('name'));
	gr.setLimit(1);
	gr.query();
	if (gr.hasNext()) {
		gs.addErrorMessage("Please give unique update set name.");
		current.setAbortAction(true);
	}

})(current, previous);

regards
Ankur

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

Hi @Ankur Bawiskar  

Awesome! Its working as expected.

Thanks for your help.

Hi i created the before insert and update BR using your exact script on the update set table and when creating a update set with the exact same name as another. No error message appears.

 

can you assist?

 

Krissy_0-1736373111933.png

 

(function executeRule(current, previous /*null when async*/) {

    // Add your code here
    var gr = new GlideRecord("sys_update_set");
    gr.addQuery("name", current.getValue('name'));
    gr.setLimit(1);
    gr.query();
    if (gr.hasNext()) {
        gs.addErrorMessage("Please give unique update set name.");
        current.setAbortAction(true);
    }

})(current, previous);