- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-09-2021 02:37 AM
Hey I have a very important problem:
I have a table which was created by extending the task table called x_582999_my_tasks. This table has the fields my_tasks_start and my_tasks_end.
As well I added the Resource Plan table to the related list of my new table. Now I want to auto-populate the start_date and end_date field of the resource plan, I can create in the related list, with the gives dates of my related task.
How can I do this?
I´m new in Service Now Scripting so it would be very helpful if you may help me with full scripts and the place I need to insert them.
Thank you so much!
Solved! Go to Solution.
- Labels:
-
Instance Configuration
-
Integrations
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-09-2021 02:48 AM
Hi,
So on the table x_582999_my_tasks you have related list of Resource plan
I assume Resource plan has a reference field to your Custom table (x_582999_my_tasks)
So you can use this logic to set the value on Resource plan based on Start and end
Display Business rule on resource plan table
g_scratchpad.start = current.<field_which_refers_customTable>.my_tasks_start;
g_scratchpad.end = current.<field_which_refers_customTable>.my_tasks_end;
Client Script: on the resource plan table
function onLoad(){
g_form.setValue('start_date', g_scratchpad.start);
g_form.setValue('end_date', g_scratchpad.end);
}
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
03-09-2021 02:48 AM
Hi,
So on the table x_582999_my_tasks you have related list of Resource plan
I assume Resource plan has a reference field to your Custom table (x_582999_my_tasks)
So you can use this logic to set the value on Resource plan based on Start and end
Display Business rule on resource plan table
g_scratchpad.start = current.<field_which_refers_customTable>.my_tasks_start;
g_scratchpad.end = current.<field_which_refers_customTable>.my_tasks_end;
Client Script: on the resource plan table
function onLoad(){
g_form.setValue('start_date', g_scratchpad.start);
g_form.setValue('end_date', g_scratchpad.end);
}
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
03-09-2021 04:43 AM
Yes, the resource plan has the field "task" as reference field to the x_582999_my_tasks table (where the referenced field is called number). This field becomes auto-populated correctly in the resource plan.
So I used the following code for the business rule:
g_scratchpad.start = current.task.my_tasks_start;
g_scratchpad.end = current.task.my_tasks_end;
This code resulted in that the date fields of the resource plan become not filled with the correct dates but with a "Undefined".
Whats wrong?
Thank you!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-09-2021 04:54 AM
Hi,
are you using correct field names for my_tasks_start and my_tasks_end
If yes then it should work fine.
Did you check the fields my_tasks_start and my_tasks_end are having values or not
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
03-09-2021 05:01 AM
The start- and end date of the x_582999_my_tasks table are as you said my_tasks_start and my_tasks_end and they are filled in the record, I want to create a resource plan for, filled as well.
So I didn´t find a problem but obviously it does not work...
Any further ideas?
