g_scratchpad issue

Community Alums
Not applicable

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.

 

1.png

 

2.png

 

(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);

 

3.png

 

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.

7 REPLIES 7

Ankur Bawiskar
Tera Patron
Tera Patron

@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.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@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.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Runjay Patel
Giga Sage

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

-------------------------------------------------------------------------