- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-07-2017 02:21 AM
Hello,
I have a onChange client script for populating the cmdb_ci field when the caller is manually selected - http://wiki.servicenow.com/index.php?title=Find_Computer_Assigned_to_Caller_and_Populate_CI_Field#gs...
But when a incident is raised by email or self service, then obviously this is not populated. Are there any best practice Business Rules or other ways that the cmdb_ci can be populated in these circumstances?
Cheers,
Dan
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-07-2017 02:29 AM
Hi Dan,
Have a business rule before insert and determine the caller and based on that fetch value of cmdb_ci. Condition for the business rule should be contact type is email or self service because for this condition you want to execute it
i.e.
Business rule script
var caller = current.caller_id;
var gr = new GlideRecord('cmdb_ci_computer'); //Table your computers reside in
gr.addQuery('assigned_to', caller );
gr.query();
if(gr.next()){
current.cmdb_ci = gr.sys_id;
}
Mark Correct if this solves your issue and also hit Like and Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-07-2017 02:29 AM
Hi Dan,
Have a business rule before insert and determine the caller and based on that fetch value of cmdb_ci. Condition for the business rule should be contact type is email or self service because for this condition you want to execute it
i.e.
Business rule script
var caller = current.caller_id;
var gr = new GlideRecord('cmdb_ci_computer'); //Table your computers reside in
gr.addQuery('assigned_to', caller );
gr.query();
if(gr.next()){
current.cmdb_ci = gr.sys_id;
}
Mark Correct if this solves your issue and also hit Like and Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-07-2017 02:30 AM
Hi Dan,
I guess a simple Business Rule "Before" "Update" should do the trick for you. A short untested snippet following the example:
var gr = new GlideRecord('cmdb_ci_computer');
gr.addQuery('assigned_to', current.caller_id);
gr.query();
if(gr.next()){
current.setValue('cmdb_ci', gr.sys_id);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-07-2017 02:31 AM
Hi Dan,
Client Scripts will be working for the form level.You have a before business rule to populate cmdb when assigned to is changing/inserting.
Regards
Anantha Gowraram
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-07-2017 02:45 AM
Hi Dan,
Hope you got the context with my script and it will help you in taking your approach. Thanks for marking the answer as correct. Could you also mark it helpful and hit like. Thanks in advance.
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader