- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-13-2020 08:24 AM
Hi Experts,
I am trying to set value on 'contact type' choice field on Request and RITM table. when user submits catalog item from service portal, the script should compare 'opened by' value and 'requested_for' value. if those values are same contact type should be set as 'self-service' else contact type should be as 'phone'.
How can I achieve this.?
Thanks,
Rocky.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-13-2020 09:11 AM
Hi Rocky,
I see the code is not aligned as per the best practice i.e In an "after" Business Rule current.update() should also not be used. Any action that might be performed in an After Business Rule can usually have been added in a high ordered Before Business Rule, eliminating any need for an explicit update() function call. In addition, updating in an After Business Rule will cause all Before Business Rules to run again, which, as mentioned previously could cause performance processing issues.
https://hi.service-now.com/kb_view.do?sysparm_article=KB0715782
Updated code below. Please make sure to give the order number highest in the BR that you have created.
var contactType = '';
if(current.opened_by == current.request.requested_for){
contactType = 'self-service';
}
else{
contactType = 'phone';
}
current.contact_type = contactType;
current.setWorkflow(false);
current.update();
// query request table and update for it as well
var req = new GlideRecord('sc_request');
req.get(current.request);
req.contact_type = contactType;
req.update();
- Pradeep Sharma

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-13-2020 08:28 AM
I would use a Before Insert Business Rule to compare opened_by and requested_for values. Something like
if(current.opened_by == current.requested_for){
current.contact_type = 'self-service';
} else {
current.contact_type = 'phone';
}
Hope this helps!
-Joel R.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-13-2020 08:38 AM
Hello Rocky,
This thread looks to be a duplicate thread. Please delete one of the thread to avoid confusion.
Let me know if you have any questions.
- Pradeep Sharma
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-13-2020 08:51 AM
Done thanks.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-13-2020 09:11 AM
thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-09-2022 11:54 PM
Hi
How can we populate contact type field to "Self-service" if user submits form from Service portal
Any help is appreciated,
Regards,
Midilesh