The CreatorCon Call for Content is officially open! Get started here.

Make a checkbox field true/false in the problem record if the incident related to problem is checked

MouktikB
Tera Contributor

I want to populate a field which is a checkbox in a problem based on its value in incident form. 

if that is checked , problem should also show as checked . 

8 REPLIES 8

J Siva
Kilo Patron
Kilo Patron

Hi @MouktikB 

You can achieve that by creating business rule on the incident table.

Condition: If check box on the incident form changes to true

Script:

-> Glide through problem record

-> Fetch the problem record you want to update 

-> Update the field as required.

 

Hope this helps.

Regards,

Siva

Regards,

Siva

GopikaP
Mega Sage

Hi @MouktikB , you can create a Business Rule in problem table, and set the conditions when to run, and try this script(adjust the script as needed)

var gr = new GlideRecord('incident');
    gr.addEncodedQuery('problem_id=' + current.sys_id);
    gr.query();
    if (gr.next()) {//note here, there can be multiple incidents related to one problem
        var check = gr.getValue('u_checked');
        if (check)
            current.u_problem_checked = true;
			current.update();
                        current.setWorkFlow(false)
    }

Ankur Bawiskar
Tera Patron
Tera Patron

@MouktikB 

when should this happen? during update or insert?

what did you start with and where are you stuck?

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

jcmings
Mega Sage

I think we need a few more details from you before we can determine the entire solution. When would you like the checkbox to get marked on the problem table? Does the problem record already exist before the incident is inserted/updated? Are there any specific conditions? Should the box get unchecked if the incident value changes?

 

Ultimately, this will likely be a business rule on the incident table, and will watch for a change in the value of the field. Your script would look something like...

var isChecked = current.field; //this is the field on incident that gets modified; assuming it is a boolean, isChecked will be either true or false

var gr = new GlideRecord('problem');
gr.addEncodedQuery('xxx'); //whatever criteria you use to identify the associated problem record
gr.query();
if (gr.next()) { //assumes there is only one PRB associated
gr.setValue('fieldName', isChecked); 
gr.setValue('work_notes', 'fieldName updated as a result of INC####'); //for traceability
gr.update();
}