- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-02-2023 10:35 AM
Trying to write a script that among other things, sets the public field to false;
gr.public = false;
I can't save it because of this error:
missing name after . operator (<refname>; line 3): JavaScript parse error at line (3) column (10) problem = missing name after . operator (<refname>; line 3)
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-02-2023 11:26 AM - edited 11-02-2023 11:29 AM
Hi @Stanley Martin ,
I guess its because of public is reserved word .
Try like below
gr.setValue('public');
** gr.setValue('public',false); // updated
ServiceNow Developer
I know one thing, and that is that I know nothing.
- Socrates
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-02-2023 10:36 AM
Can you share your code snippet here if possible...!!
ServiceNow Developer
I know one thing, and that is that I know nothing.
- Socrates
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-02-2023 11:20 AM
I have a need to update certain Announcements and set the public field to false.
function run() {
var gr = new GlideRecord('announcement');
gr.addEncodedQuery('active=true^name=Testing 123');
gr.query();
while (gr.next()) {
gr.public = false;
gr.update();
}
}
run();
When I try to save the script, I get the error:
missing name after . operator (<refname>; line 6): JavaScript parse error at line (6) column (18) problem = missing name after . operator (<refname>; line 6)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-02-2023 11:26 AM - edited 11-02-2023 11:29 AM
Hi @Stanley Martin ,
I guess its because of public is reserved word .
Try like below
gr.setValue('public');
** gr.setValue('public',false); // updated
ServiceNow Developer
I know one thing, and that is that I know nothing.
- Socrates