TRUE/FALSE field is not working
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-25-2021 01:14 AM
Hi Team,
I have a true/false field(made_sla), this field need to populate as true or false based on two date&time fields(X&Y).
if(X>Y) then made_sla=TRUE
else if(X<Y) then made_sla=FALSE.
logic is working and logs also printing, but made_sla is always showing as "FALSE" we do not have default value defined for this field.
if (widnowstart > breachtime) {
current.made_sla = 'true';
//gs.addInfoMessage("made:" + current.made_sla);
} else if (widnowstart < breachtime) {
current.made_sla = 'false';
}
Addinfo mesages are coming correctly but field is not updating, i have tried business rule on Before and after.
What might be the reason why Made_sla not accepting TRUE value? can anyone help me what are the backend logic stoping except dictionary default value.
Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-25-2021 01:51 AM
The part of with quotes/without that others are mentioning, should not matter at all for an update. This can't be the issue.
Maybe some other scripting preventing this update? Can you try for example with using
current.setWorkflow(false);
If my answer helped you in any way, please then mark it as helpful.
Kind regards,
Mark
2020, 2021 ServiceNow Community MVP
2020, 2021 ServiceNow Developer MVP
---
LinkedIn
Community article, blog, video list
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-25-2021 01:32 AM
some things to inform
1) if this is before business rule then small change
2) you should not use after insert/update business rule
Also as mentioned by Erik don't use quotes for boolean fields
if (widnowstart > breachtime) {
current.made_sla = true;
//gs.addInfoMessage("made:" + current.made_sla);
} else if (widnowstart < breachtime) {
current.made_sla = false;
}
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-25-2021 01:49 AM
I have tried all above given suggestions but still same issue, made_sla field is showin as FALSE.
Any field back end configurations do i need to look? there is not default value for made sla field.
Thanks,
Aahita
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-25-2021 02:03 AM
Maybe some other scripting preventing this update? Can you try for example with using
current.setWorkflow(false);
If my answer helped you in any way, please then mark it as helpful.
Kind regards,
Mark
2020, 2021 ServiceNow Community MVP
2020, 2021 ServiceNow Developer MVP
---
LinkedIn
Community article, blog, video list
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-25-2021 03:24 AM
Hi,
It's setting the appropriate value in your code, But it is not setting value on field for that you have to update that record after setting the value
if (widnowstart > breachtime) {
current.made_sla = true;
gs.info(current.made_sla) // Here it will set proper value but it won't apply on actual field
//gs.addInfoMessage("made:" + current.made_sla);
} else if (widnowstart < breachtime) {
current.made_sla = false;
}
since you are using current, So i am assuming are are writing server side script
Please current.update() , It will work and update proper value
to update true/false value, You have to update the record
Please mark as correct/helpful, If you get help
