unable to set the value for a field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-21-2024 03:49 AM
hi all,
i have below requirements. based on the http status i need to set a value for a field. if it is 200 we need to set state to closed complete and set the flag to true so below is the script
current.flag = false;
if (httpStatus == 201 || httpStatus == 200 ) {
current.state = 3;
current.flag = true;
current.update();
} else {
current.state = 10;
current.update();
}
my script is not working for the setting the flag please suggest.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-21-2024 04:26 AM
Hi @lakshman nalla ,
Can you please let us know , where you have written this code...??
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
01-21-2024 04:39 AM
hi @Vishal Birajdar business rule
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-21-2024 04:54 AM
Hello @lakshman nalla
Ok..Thanks....!!
Can you try using setValue() & also check the backend name of 'flag' field.
current.setValue('flag',false);
if (httpStatus == 201 || httpStatus == 200 ) {
current.setValue('state' ,3);
current.setValue('flag',true);
// current.update(); not to use .update for current object
} else {
current.setValue('state' ,10);
// current.update();
}
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
01-21-2024 06:20 AM
@lakshman nalla Are you sure your flag field name is flag? This looks like a custom field to me and custom fields usually start with u_ prefix. Check if your field name us u_flag instead of flag.