Can't save script updating public field

Stanley Martin
Tera Guru

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)

1 ACCEPTED SOLUTION

Hi @Stanley Martin ,

 

I guess its because of public is reserved word .

Try like below 

 

 

 

gr.setValue('public');

 

 

** gr.setValue('public',false); // updated

 

 

 

 

 

 

Vishal Birajdar
ServiceNow Developer

I know one thing, and that is that I know nothing.
- Socrates

View solution in original post

3 REPLIES 3

Vishal Birajdar
Giga Sage

Hi @Stanley Martin 

 

Can you share your code snippet here if possible...!!

 

Vishal Birajdar
ServiceNow Developer

I know one thing, and that is that I know nothing.
- Socrates

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)

Hi @Stanley Martin ,

 

I guess its because of public is reserved word .

Try like below 

 

 

 

gr.setValue('public');

 

 

** gr.setValue('public',false); // updated

 

 

 

 

 

 

Vishal Birajdar
ServiceNow Developer

I know one thing, and that is that I know nothing.
- Socrates