- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-25-2017 11:29 AM
Hi All,
I have a script include that has a number of GlideRecords to check or set field values on incident and change.
One value I am passing is the CR planning requested flag and if it is true do this else do that. The problem is that the value always comes in as true
Code snippets below:
//GR to get the boolean field for the company u_cr_planning_requested)
var ComCR = new GlideRecord('core_company');
ComCR.addQuery(grT.company);
ComCR.query();
while (ComCR.next()) {
.....
....
if (ComCR.u_cr_planning_requested) {
grCH.start_date = gs.nowDateTime();
grCH.end_date = dateTime();
gs.log(ComCR.u_cr_planning_requested);
when I check sys logs the above log entry always has true even when its false.
Is some conversion missing my code?
Any suggestions greatly appreciated.
Thanks
Ellie
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-25-2017 11:36 AM
Hello Ellie,
Replace ComCR.addQuery(grT.company); with ComCR.get(grT.company);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-25-2017 11:36 AM
Hello Ellie,
Replace ComCR.addQuery(grT.company); with ComCR.get(grT.company);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-25-2017 11:40 AM
Hi
Just try with below code, changes are in Bold
var ComCR = new GlideRecord('core_company');
ComCR.addQuery(grT.company);
ComCR.query();
while (ComCR.next()) {
if (ComCR.getValue('u_cr_planning_requested')) {
grCH.start_date = gs.nowDateTime();
grCH.end_date = dateTime();
}
gs.log(ComCR.u_cr_planning_requested);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-25-2017 11:41 AM
change the line of addQuery with,ComCR.get(grT.company); // if it returns sys_id
or ComCR.addQuery ('company',grT.company); if the field name is company