Setting a Reference and corresponding dot walked fields
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-14-2016 09:39 AM
Hi Team,
I am not sure if this is technically feasible and hence thought of reaching out to the group.
Current Layout :
On my timecard, I display resource plan which is a reference field and I display the corresponding dot walked fields of Resource Plan which are rp.group resource, rp.task , rp.task.projectname and so on...
What is working :
If I am on the time card and manually populate the resource plan , all the corresponding 1st level dot walked fields and 2nd level dot walked fields are auto-populated . And I assume this happens automatically (No manual script written)
What is not working :
I am trying to write an OnLoad script in which I populate the resourceplan value. The subsequent 1st level fields are again getting auto-populated (no script written) but the 2nd level fields like project name and manager are not getting populated.
I have tried n number of combinations on the script but it is not working at all.
I tried setting the 2nd level fields as well but the problem here is that they are not reference fields but '+' (dot walked) fields.
via OnLoad:
manually if resourceplan is populated:
Any help is much appreciated.
Regards
Nitin
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-14-2016 09:43 AM
Hi Nitin,
The key point to note here is that client scripts cannot dot-walk. They only know what's on the form (from the current record.) I recommend doing your prepopulation by creating data in the g_scratchpad object using a DISPLAY business rule. Something like:
g_scratchpad.project_name = current.resource_plan.project.name;
Then your onLoad client script can populate from the g_scratchpad.
g_form.setValue('project_name', g_scratchpad.project_name); // You may need to do some digging in the page source to get the real value
Client Script Best Practices - ServiceNow Wiki
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-14-2016 10:05 AM
Thanks Chuck.
The problem is auto-population here.
Since this happens in the manual process , I thought it would also happen when I set the resourceplan field.
It does but only for few fields and not for others.
Is this expected or am I making some mistakes while I am set value for the first field ?
Regards
Nitin

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-14-2016 10:06 AM
Hi Nitin,
Can you clarify what you mean by "this happens in the manual process"?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-14-2016 10:09 AM
Hi Chuck,
Manual Process here means... Once the timecard form is loaded , if I go to the ResourcePlan field and manually enter a value then the rest fields below get auto-populated.
Regards
Nitin