when I change the priority of my xyz table record to 1 then all other records which has a

Abhishek Kathe
Mega Guru

when I change the priority of my xyz table record to 1 then all other records which has a priority 1 should change automatically to none.

6 REPLIES 6

Maik Skoddow
Tera Patron
Tera Patron

Hi @Abhishek Kathe 

why are you asking the same question again and also without providing more details?

You marked your previous question as "Correct". So was the answer there helpful or not? See https://www.servicenow.com/community/itsm-forum/when-i-change-the-priority-of-my-incident-record-to-... 

Maik

Aniket Chavan
Tera Sage
Tera Sage

Hello @Abhishek Kathe 

If its a Incident table then it will be depending on urgency and impact but if its different table lets say custom one and in there as well if the priority is depending on urgency and impact then you can do it there as well but you need to see the dependencies first. 
Please refer the script below and make the changes as per your requirement.
After Update Business Rule:

 

(function executeRule(current, previous) {
    // Check if priority is changed to 1
    if (current.priority == 1 && current.priority != previous.priority) {
        // Update other records with priority 1 to 'none'
        var gr = new GlideRecord('xyz_table');
        gr.addQuery('priority', 1);
        gr.addQuery('sys_id', '!=', current.sys_id); // Exclude the current record
        gr.query();

        while (gr.next()) {
            gr.priority = 'none';
            gr.update();
        }
    }
})(current, previous);

 

 

Let me know your views on this and Mark Correct if this solves your query and also mark 👍Helpful if you find my response worthy based on the impact.

 

Thanks,

Aniket

 

Sandeep Rajput
Tera Patron
Tera Patron

@Abhishek Kathe You need to write a business onBefore Update business rule as follows.

Screenshot 2023-12-22 at 3.03.11 PM.pngScreenshot 2023-12-22 at 3.04.18 PM.png

Hi @Sandeep Rajput 

sorry, but this makes no sense and is also pretty dangerous! As experts, we have a certain responsibility and cannot recommend just any nonsense. Do you have an idea what happens if such a script is fired in a production instance with let's say several tens of thousands of tickets? Think about this carefully and hopefully you do not implement something like this for your customers!

Maik