Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Fix Script will not compile

Stacy2
Tera Expert
Scripting newbie here.  Any help appreciated.
 
I get error, "Could not save record because of a complile error:  SyntaxError:Expected",,got'{' at line 2, column 1
I also see that 'mobile phone = ' is seeming to be intrepreted not as a literal, but as a variable (aka, it is in black text) in  line 8
 
new GlideQuery('sys_user')
    .where('active', true)
    .where('user_name', 'walt.disney')
    .select('user_name', 'sys_id', 'mobile_phone')
    .forEach(fuction(u) {
        gs.info('\n' + 'user name = ' + u.user_name + '\n' + 'sys_id = ' + u.sys_id +
            '\n\' + '
            mobile phone = ' + ' + u.mobile_phone); }
    });
 
Stacy2_0-1753460554160.png

StacyLen

2 ACCEPTED SOLUTIONS

Chaitanya ILCR
Mega Patron

Hi @Stacy2 ,

 

try this

new GlideQuery('sys_user')
    .where('active', true)
    .where('user_name', 'walt.disney')
    .select('user_name', 'sys_id', 'mobile_phone')
    .forEach(function(u) {
        gs.info('\n' + 'user name = ' + u.user_name + '\n' + 'sys_id = ' + u.sys_id + '\n' + 'mobile phone = ' + u.mobile_phone);
    });

 

Please mark my answer as helpful/correct if it resolves your query.

Regards,
Chaitanya

View solution in original post

Hi @Stacy2 

Thanks for marking my response as helpful 

 

If my response helped could you please accept it as a solution and close the thread?

 

Thanks 

Chaitanya 

View solution in original post

3 REPLIES 3

Chaitanya ILCR
Mega Patron

Hi @Stacy2 ,

 

try this

new GlideQuery('sys_user')
    .where('active', true)
    .where('user_name', 'walt.disney')
    .select('user_name', 'sys_id', 'mobile_phone')
    .forEach(function(u) {
        gs.info('\n' + 'user name = ' + u.user_name + '\n' + 'sys_id = ' + u.sys_id + '\n' + 'mobile phone = ' + u.mobile_phone);
    });

 

Please mark my answer as helpful/correct if it resolves your query.

Regards,
Chaitanya

Stacy2
Tera Expert

thanks Chaitanya ILCR

 

Help me out here.... are my eyes bad.  I could see absolutely no differences between your suggestion and what I posted (except for a line return).  But yet when I copied yours, it worked.  No compilation errors

 

StacyLen

Hi @Stacy2 

Thanks for marking my response as helpful 

 

If my response helped could you please accept it as a solution and close the thread?

 

Thanks 

Chaitanya