Built something you're proud of? Tell the story. A quick G2 review of App Engine or Build Agent helps other developers see what's possible on ServiceNow. Share your experience.

Fix Script will not compile

Not applicable
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
Giga Patron

Hi @Community Alums ,

 

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 @Community Alums 

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
Giga Patron

Hi @Community Alums ,

 

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

Not applicable

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 @Community Alums 

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