- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-24-2020 11:31 PM
Hello Friends,
In the ITBM module, we have a demand task form. I am going to create the work order under the demand task. I need to populate the demand task form short description field value to the short description in the work order form. In the work order form I have a filed with the name parent. For your reference I am attaching the screen shot of it. Can any one suggest is it possible by client script?. If means could you please let me know how can get the data of parent in the child form client script.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-25-2020 12:55 AM
write an onload client script on work order:
var desc = g_form.getReference('parent',func);
function func(desc)
{
g_form.setValue('short_description',desc.short_description);
}
Raghav
MVP 2023
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-25-2020 12:55 AM
write an onload client script on work order:
var desc = g_form.getReference('parent',func);
function func(desc)
{
g_form.setValue('short_description',desc.short_description);
}
Raghav
MVP 2023
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-08-2021 10:12 AM
This works except is you are trying to retrieve a user from Parent User field. Do you have an example if I am trying to retrieve the Assigned To from reference field. The reference field is an incident number. I want to get the Assigned To from the Incident.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-25-2020 01:10 AM
Hi,
Couple of approaches
1) use before insert BR on work order table
Condition: current.parent != ''
Script:
(function executeRule(current, previous /*null when async*/) {
// Add your code here
current.short_description = current.parent.short_description;
})(current, previous);
OR
2) onLoad Client Script
function onLoad(){
if(g_form.isNewRecord()){
var ref = g_form.getReference('parent', callBackMethod);
}
function callBackMethod(ref){
if(ref.short_description){
g_form.setValue('short_description',ref.short_description);
}
}
}
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
11-26-2020 11:26 PM
I would suggest to use before Insert BR if user doesn't wish to see the value on the form during creation
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader