- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-18-2017 05:09 AM
I have this impacted services related list in my incident form.
I want the "managed by" field which is a reference field of user table to be populated to a custom field in my INC form. Kindly help me to
achieve this. Developer Community bawiskar
Thanks in advance
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-20-2017 05:25 AM
Not sure how you are going to pull that off but here is code for adding users to a list field that relates to the sys_user table. Adding or removing an Affected CI in the related list will trigger an update of the List field and add assigned to from all the related CI's to the u_service_owner field.
List field on Incident table called u_service_owner referencing sys_user table.
Business rule on task_ci table. Runs after on Insert, Update and Delete.
Script:
(function executeRule(current, previous /*null when async*/) {
// Add your code here
var inc = new GlideRecord('incident');
inc.addQuery('sys_id',current.task);
inc.query();
if(inc.next()){
inc.u_service_owner=''; //Clear service owner list
var ci = new GlideRecord('task_ci');
ci.addQuery('task',current.task);
ci.query();
while (ci.next()){
inc.u_service_owner += ',' + ci.ci_item.assigned_to; //Add CI assigned to
}
inc.update();
}
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-18-2017 11:16 PM
Hi Niklas,
I have OOTB field "Business service" which is a reference field of cmdb_ci_service table where i can define my business service record which can contain only one record but when iam inserting a record its not showing in the "impacted service" related list. what may be the reason for this??
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-19-2017 09:50 AM
There is no out of the box business rule that adds the business service to "Impacted Services". You need to create one. Have a look at the business rule "Sync CI with Affected CIs" that does this for Configuration Item to get a hint on how to build a rule for Services.
/Niklas
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-18-2017 08:32 AM
Hi,
Just to prove the concept. You will need much more functionality and validation to get it to populate and unpopulate as needed.
In this scenario the assigned to of an affected CI is set to a new field called u_service_manager on the incident form.
Add a field, u_service_manager, to the incident form.
Which is a reference to the sys_user table.
Display the related list "Affected CI's on the Incident form.
Create a business rule on task_ci table that runs before on insert and update using the following script.
(function executeRule(current, previous /*null when async*/) {
// Add your code here
var gr = new GlideRecord('incident');
gr.addQuery('sys_id',current.task);
gr.query();
if(gr.next()){
gr.u_service_manager=current.ci_item.assigned_to;
gr.update();
}
})(current, previous);
/Niklas
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-18-2017 11:37 PM
Thanks Niklas for the code but what about we have multiple CI's affected then how can we store the "owned by" user list.. can u plz help me in dat??
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-19-2017 09:46 AM
That's is really the purpose of Related Lists. To show the relation to multiple records. You could of course make the custom field on the Incident record a list field and add multiple records. But do you really need that? How are you going to use that information? If it's only going to be used by someone looking at the form it is just as easy to look at the related list as it is to look at a list field.
/Niklas