How to set a default CI for user

Eric K3
Kilo Guru

How could I set a default CI for a user?

For example: A user is assigned a desktop, a notebook, and an iPad. I want to set the desktop as their default CI so that when they call in or create an incident, their default CI (desktop) auto populates the "Configuration item" field on the incident form.

Do I need to create a new field on the User table, [Default CI], referencing the cmdb_ci table?

4 REPLIES 4

Ravi Prasad1
Tera Guru

Hi Eric,



Does this User CI details stored in service now ?



If yes then you can write on load client script on Incident table to populate the Configuration Item field with the CI associated to the User profile.



Thanks,


Ravi


Mike Allen
Mega Sage

I would add a default yes/no to the CI.   Then your client script can be:



onChange caller_id



var ci = new GlideRecord('cmdb_ci');


ci.addQuery('assigned_to', newValue);


ci.addQuery('u_default', true);


ci.query();


ci.next();


var defaultCI = ci.sys_id;



g_form.setValue('cmdb_ci', defaultCI);


Thank you Mike.



The reason I mentioned adding the [Default CI] field to the User table is so the Service Desk employees can easily add/change the CI for the user in their profile. I thought that would be easier than searching through Configuration - Base Items - All   to find the device and set it as a default device. Thoughts?


I would add the field, add the Configuration Item > Assigned To related list and let the Service Desk change it that way:



find_real_file.png



That way, they can see all devices currently assigned to the user and choose from there.   In my screenshot, the user has a laptop, desktop and phone.   It would be easy to allow users on the Service Desk to either a) allow list edit to make one false and one true, or b) create a list ui action that allows a user to select one of these, have the action mark that one as true and the others as false.



That is probably what I would do.