g_scratchpad issue

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-12-2024 02:50 AM
Hi,
I know i should have created a Business Rule on Problem Task table but I want to create on Problem table to see why it doesn't work. It didn't work. Keeping it as it is, please tell me what Is wrong so that I can learn and correct myself.
(function executeRule(current, previous /*null when async*/) {
var gr = new GlideRecord('problem_task');
gr.short_description = current.short_description;
g_scratchpad.SD = gr.short_description;
gr.assignment_group = current.assignment_group;
g_scratchpad.AG = gr.assignment_group;
gr.description = current.description;
g_scratchpad.Desc = current.description;
})(current, previous);
function onLoad() {
g_form.setValue('short_description', g_scratchpad.SD);
g_form.setValue('description', g_scratchpad.Desc);
g_form.setValue('assignment_group', g_scratchpad.AG);
}
Regards
Suman P.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-12-2024 03:26 AM
@Community Alums
seems you need to pre-populate 3 fields on problem_task record based on value present on problem field
then do this
Display BR on problem_task
Condition: Parent IS NOT EMPTY
(function executeRule(current, previous /*null when async*/ ) {
var gr = new GlideRecord("problem");
if (gr.get(current.parent)) {
g_scratchpad.parent = current.parent;
g_scratchpad.SD = gr.short_description;
g_scratchpad.Desc = gr.description
g_scratchpad.AG = gr.assignment_group;
}
})(current, previous);
Client script:
function onLoad() {
if(g_scratchpad.parent) {
g_form.setValue('short_description', g_scratchpad.SD);
g_form.setValue('description', g_scratchpad.Desc);
g_form.setValue('assignment_group', g_scratchpad.AG);
}
}
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-12-2024 06:33 PM
@Community Alums
Thank you for marking my response as helpful.
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-12-2024 03:28 AM - edited 12-12-2024 03:29 AM
Hi @Community Alums ,
It wont work, Display business rule you need to write on problem task table instead of problem table if your client script is written on problem task.
you can set the value like below in BR.
g_scratchpad.SD = current.parent.short_description;
and in client script you can set it like
g_form.setValue('short_description', g_scratchpad.SD);
-------------------------------------------------------------------------
If you found my response helpful, please consider selecting "Accept as Solution" and marking it as "Helpful." This not only supports me but also benefits the community.
Regards
Runjay Patel - ServiceNow Solution Architect
YouTube: https://www.youtube.com/@RunjayP
LinkedIn: https://www.linkedin.com/in/runjay
-------------------------------------------------------------------------