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:46 AM
Can you share your script?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-14-2016 10:07 AM
Here you go Deepa.
function onLoad() {
//Type appropriate comment here, and begin script below
var vsar = g_form.getValue('u_vsar');
if (vsar != "")
{
var gr = new GlideRecord('u_virtual_table');
gr.get(vsar);
var resource_plan = gr.u_resource_plan;
var u_sys_id = gr.sys_id;
g_form.setValue("resource_plan",u_sys_id,resource_plan);
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-14-2016 10:10 AM
There may be an issue with your g_form.setValue()
For reference fields, the third argument is the display value. Is gr.u_resource_plan a string, a sys_id, something else?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-14-2016 10:17 AM
It is a reference field pointing to resource plan table.
Sent from my Windows Phone

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-14-2016 10:19 AM
If gr.u_resource_plan is a reference field, then you should change to this
var resource_plan = gr.u_resource_plan.getDisplayValue()
Then your setValue() should work (better)