Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-21-2024 09:32 PM
I have a requirnmnet to"Populate source fields from task" onChange of Field Task in fm_expense_line table.
Solved! Go to Solution.
1 ACCEPTED SOLUTION
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-22-2024 07:06 AM
Hello,
Use the below :-
Code :-
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || (g_form.getValue('parent') != '' && g_form.isNewRecord())) {
return;
}
if (g_scratchpad.active == undefined || g_scratchpad.active == 'false') {
g_scratchpad.active = 'true';
var record = g_form.getReference('task')
var task = new GlideRecord(record.sys_class_name);
task.get(record.sys_id);
var ci = new GlideRecord('cmdb_ci');
ci.get(task.cmdb_ci);
g_form.setValue('ci', ci.sys_id);
g_form.setValue('asset', ci.asset);
g_form.setValue('cost_center', ci.cost_center);
g_form.setValue('contract', '');
g_form.setValue('source_id', '');
if (task.caller_id != undefined)
g_form.setValue('user', task.caller_id);
else if (task.requested_by != undefined)
g_form.setValue('user', task.requested_by);
else
g_form.setValue('user', '');
g_scratchpad.active = 'false';
}
}
--------------------------------------------------------------------------------------------------------------------------
If you found my response helpful, I would greatly appreciate it if you could mark it as "Accepted Solution" and "Helpful."
Your support not only benefits the community but also encourages me to continue assisting. Thank you so much!
Thanks and Regards
Ravi Gaurav | ServiceNow MVP 2025,2024 | ServiceNow Practice Lead | Solution Architect
CGI
M.Tech in Data Science & AI
ï”— YouTube: https://www.youtube.com/@learnservicenowwithravi
ï”— LinkedIn: https://www.linkedin.com/in/ravi-gaurav-a67542aa/
If you found my response helpful, I would greatly appreciate it if you could mark it as "Accepted Solution" and "Helpful."
Your support not only benefits the community but also encourages me to continue assisting. Thank you so much!
Thanks and Regards
Ravi Gaurav | ServiceNow MVP 2025,2024 | ServiceNow Practice Lead | Solution Architect
CGI
M.Tech in Data Science & AI
ï”— YouTube: https://www.youtube.com/@learnservicenowwithravi
ï”— LinkedIn: https://www.linkedin.com/in/ravi-gaurav-a67542aa/
1 REPLY 1
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-22-2024 07:06 AM
Hello,
Use the below :-
Code :-
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || (g_form.getValue('parent') != '' && g_form.isNewRecord())) {
return;
}
if (g_scratchpad.active == undefined || g_scratchpad.active == 'false') {
g_scratchpad.active = 'true';
var record = g_form.getReference('task')
var task = new GlideRecord(record.sys_class_name);
task.get(record.sys_id);
var ci = new GlideRecord('cmdb_ci');
ci.get(task.cmdb_ci);
g_form.setValue('ci', ci.sys_id);
g_form.setValue('asset', ci.asset);
g_form.setValue('cost_center', ci.cost_center);
g_form.setValue('contract', '');
g_form.setValue('source_id', '');
if (task.caller_id != undefined)
g_form.setValue('user', task.caller_id);
else if (task.requested_by != undefined)
g_form.setValue('user', task.requested_by);
else
g_form.setValue('user', '');
g_scratchpad.active = 'false';
}
}
--------------------------------------------------------------------------------------------------------------------------
If you found my response helpful, I would greatly appreciate it if you could mark it as "Accepted Solution" and "Helpful."
Your support not only benefits the community but also encourages me to continue assisting. Thank you so much!
Thanks and Regards
Ravi Gaurav | ServiceNow MVP 2025,2024 | ServiceNow Practice Lead | Solution Architect
CGI
M.Tech in Data Science & AI
ï”— YouTube: https://www.youtube.com/@learnservicenowwithravi
ï”— LinkedIn: https://www.linkedin.com/in/ravi-gaurav-a67542aa/
If you found my response helpful, I would greatly appreciate it if you could mark it as "Accepted Solution" and "Helpful."
Your support not only benefits the community but also encourages me to continue assisting. Thank you so much!
Thanks and Regards
Ravi Gaurav | ServiceNow MVP 2025,2024 | ServiceNow Practice Lead | Solution Architect
CGI
M.Tech in Data Science & AI
ï”— YouTube: https://www.youtube.com/@learnservicenowwithravi
ï”— LinkedIn: https://www.linkedin.com/in/ravi-gaurav-a67542aa/