
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-18-2017 06:39 AM
I know I'm missing something simple here.
In time worked, trying to return task.parent.top_task.
Created a On-load Client Script:
alert(g_scratchpad.top);
Created a Business rule on Time Worked (task_time_worked)
var gr = new GlideRecord('pm_project_task')
gr.addQuery('sys_id', current.task);
gr.Query();
g_scratchpad.top = gr.top_task.getDisplayValue();
Result is undefined. Even if put the current task in a variable, I still get undefined alert when I load the form.
The form does have a PRJTASK in the task field, as the form is called via "New" button on the Project Task Time Worked related list.
var ta = current.task //Time Worked Table
var gr = new GlideRecord('pm_project_task')
gr.addQuery('sys_id', ta);
gr.Query();
g_scratchpad.top = gr.top_task.getDisplayValue();
Solved! Go to Solution.
- Labels:
-
Best Practices
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-18-2017 07:48 AM
Hi,
You need to do a gr.next() to actually get to the specific record.When getting a single record, you can use get() like this to save a few lines since it does both query() and next() for you.
var gr = new GlideRecord('pm_project_task')
gr.get(current.task);
g_scratchpad.top = gr.top_task.getDisplayValue();
//Göran
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-18-2017 07:48 AM
Hi,
You need to do a gr.next() to actually get to the specific record.When getting a single record, you can use get() like this to save a few lines since it does both query() and next() for you.
var gr = new GlideRecord('pm_project_task')
gr.get(current.task);
g_scratchpad.top = gr.top_task.getDisplayValue();
//Göran

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-18-2017 09:45 AM
Thanks Goran!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-18-2017 11:09 AM
No problemo,
Just shout if you run into anything else.
//Göran

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-17-2021 08:56 PM
Had similar issue. In my case it was happened due to, Display Business rule was written on the different table and we were using g_scratchpad in different table.
So after adding same Display Business rule for the table used in Client script resolved our issue.
Regards
Pawan K Singh