Welcome to Community Week 2025! Join us to learn, connect, and be recognized as we celebrate the spirit of Community and the power of AI. Get the details  

Failure of executeRule Function to compile

Stacy2
Tera Expert
Newbie here.  Any Help appreciated.  I get this error when trying to save:
Could not save record because of a compile error: JavaScript parse error at line (3) column (16) problem = missing ; before statement (<refname>; line 3)
 
(function executeRule(current, previous /*null when async*/)
{
    Var makeVIP = new GlideRecord('sys_user');
    Var q1 = makeVIP.addQuery('title', 'COTAINS', 'VICE');
    q1.addOrCondition('title', 'CONTAINS', 'Vice');
    q1.addOrCondition('title', 'CONTAINS', 'CHIEF');

    while (makeVIP.next()) {
        makeVIP.vip = true;
        gs.info("ADMIN: " + makeVIP.name + "with title: " + makeVIP.title + " is now a VIP.");
        makeVIP.update();
    }

})(current, previous);
1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

@Stacy2 

update as this

(function executeRule(current, previous /*null when async*/) {
    var makeVIP = new GlideRecord('sys_user');
    makeVIP.addQuery('title', 'CONTAINS', 'VICE');
    makeVIP.addOrCondition('title', 'CONTAINS', 'Vice');
    makeVIP.addOrCondition('title', 'CONTAINS', 'CHIEF');
    makeVIP.query(); // Execute the query

    while (makeVIP.next()) {
        makeVIP.vip = 'true'; // Use string for boolean
        gs.info("ADMIN: " + makeVIP.name + " with title: " + makeVIP.title + " is now a VIP.");
        makeVIP.update();
    }
})(current, previous);

If my response helped please mark it correct and close the thread so that it benefits future readers.

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

View solution in original post

2 REPLIES 2

Ankur Bawiskar
Tera Patron
Tera Patron

@Stacy2 

update as this

(function executeRule(current, previous /*null when async*/) {
    var makeVIP = new GlideRecord('sys_user');
    makeVIP.addQuery('title', 'CONTAINS', 'VICE');
    makeVIP.addOrCondition('title', 'CONTAINS', 'Vice');
    makeVIP.addOrCondition('title', 'CONTAINS', 'CHIEF');
    makeVIP.query(); // Execute the query

    while (makeVIP.next()) {
        makeVIP.vip = 'true'; // Use string for boolean
        gs.info("ADMIN: " + makeVIP.name + " with title: " + makeVIP.title + " is now a VIP.");
        makeVIP.update();
    }
})(current, previous);

If my response helped please mark it correct and close the thread so that it benefits future readers.

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

Thanks.  That did it!