- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-30-2022 07:12 PM
Hello Community,
I would like to automate the assignment of group when short description field contains the key words [HORIZON].
I have used assignment rules and assigned it but i want to convert this text to lowercase and assign it and some how it does not seem to work.
I have tried:
if(current.short_description.toLowerCase().indexOf('[HORIZON]') >=0){
current.assignment_group = "a0a698c71ba9115073876313604bcb7f";
}
currentlly in my filtering condition i am providing the condition manually but i want to hard code it as the user can type in mixed case as well.for eg[HoriZON] or something similar
Any guidance would be appreciated.
Solved! Go to Solution.
- Labels:
-
Incident Management

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-01-2022 10:21 PM
Hi,
Why do you want the GlideRecord query? I think it is not required in your case. You can try the below code:
Note: Pass the sys_id of the assignment group. Make sure Before is selected in When
(function executeRule(current, previous /*null when async*/ ) {
// Add your code here
if(current.short_description.toLowerCase().indexOf('[horizon]') >=0){
current.assignment_group = "a0a698c71ba9115073876313604bcb7f"; // Pass the sys_id of assignment group
}
})(current, previous);
Palani

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-30-2022 07:28 PM
Hi Renu,
You can use assignment rule script with the same script you wrote in the question, where you can use .toLowerCase().
OR I would say you can simply use an update BR where you can use .toLowerCase(). Did you see any challenges in this approach?
Mark my answer as HELPFUL / CORRECT if this help resolve your issue.
Regards,
Vamsi S

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-30-2022 07:43 PM
Hi Renu,
I missed this in my first read, when you are using .toLowerCase then the HORIZON should be in small case.
i.e.,
if(current.short_description.toLowerCase().indexOf('[horizon]') >=0){ //horizon in small case
current.assignment_group = "a0a698c71ba9115073876313604bcb7f";
}
Mark my answer as HELPFUL / CORRECT if this help resolve your issue.
Regards,
Vamsi S
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-01-2022 09:40 PM
Hi Vamsi,
Thanks for your response.
I have few questions.
If i have to run a business rule and script it do i choose anything in the filtering conditions?
Second do i write a complete glide record function like this
(function executeRule(current, previous /*null when async*/ ) {
// Add your code here
var gr = new GlideRecord("incident");
gr.addQuery("short_description", current.short_description);
gr.query();
if (gr.next()) {
var horizon = ['a0a698c71ba9115073876313604bcb7f']; // Static Sys_ID of User which needs to be added to Watch List
if(current.short_description.toLowerCase().indexOf('[horizon]') >=0){
current.assignment_group = horizon";
}
})(current, previous);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-01-2022 10:21 PM
Hi,
Why do you want the GlideRecord query? I think it is not required in your case. You can try the below code:
Note: Pass the sys_id of the assignment group. Make sure Before is selected in When
(function executeRule(current, previous /*null when async*/ ) {
// Add your code here
if(current.short_description.toLowerCase().indexOf('[horizon]') >=0){
current.assignment_group = "a0a698c71ba9115073876313604bcb7f"; // Pass the sys_id of assignment group
}
})(current, previous);
Palani