Need to write business rule where worknotes contains "My Laptop Issue" then only it should assigned to specific assignment group

Shweta Kasbe1
Tera Contributor

Need to write business rule where worknotes contains "My Laptop Issue" then only it should assigned to specific assignment group.

I have written br its not working.Please guide me in this.

  var gr = new GlideRecord('sc_task');
    gr.query();
    if (current.work_notes == 'My Laptop Issue') {  gr.update();
    }

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

update your script as this

(function executeRule(current, previous /*null when async*/) {

	// Add your code here
	if (current.work_notes.getJournalEntry(1).indexOf('My Laptop Issue') > -1 ) { 
		current.assignment_group = "groupSysId"; // give group sysId here
	}

})(current, previous);

Regards
Ankur

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

View solution in original post

8 REPLIES 8

Harish KM
Kilo Patron
Kilo Patron

You dont need script for this.

BR on SC Task table before insert/update

Condition :

Worknotes contain MY Laptop issue

AND

Assignment group to groupname

Regards
Harish

Abhijit4
Mega Sage

Hi Shweta,

Your script looks incomplete to me. On which table this BR is written and on which record you want to update the assignment group. 

If you want to update the assignment group on same table then please try below,

    if (current.work_notes == 'My Laptop Issue') { 
current.assignment_group="group_sys_id_here" //store it in system property as best practice
    }

Let me know if you have any further queries.

Please mark this as Correct or Helpful if it helps.

Thanks and Regards,
Abhijit
Community Rising Star 2022

By marking my response as correct or helpful, you contribute to helping future readers with similar issues.
Regards,
Abhijit
ServiceNow MVP

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

update your script as this

(function executeRule(current, previous /*null when async*/) {

	// Add your code here
	if (current.work_notes.getJournalEntry(1).indexOf('My Laptop Issue') > -1 ) { 
		current.assignment_group = "groupSysId"; // give group sysId here
	}

})(current, previous);

Regards
Ankur

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

suvro
Mega Sage
Mega Sage

Use before insert/update BR with condition worknote changes

var gr = new GlideRecord('sys_journal_field');

gr.addQuery('element_id', current.sys_id);

gr.addQuery('name', 'incident');

gr.addQuery('element', 'work_notes');

gr.query();


while (gr.next()) {


if (gr.value.toString() == "My Laptop Issue"){
current.assignment_group = sys_id of the assignment group;
}


}