Filter a lookup field by logged in user

KB15
Giga Guru

I thought this would be easier in some way but I think it's more complex than I thought.

I have a custom table that has rows of business units associated to employees via employee IDs. I need to be able to filter all the results in a look up select box by the logged in user on a service catalog item. Each user account has an associated ID as well. I was thinking that I could use a onload client script to attempt to match the employee ID to the user initially. I don't know if there's a performance hit for that.

Employee IDBusiness UnitDescription
1234512345.12345HR
1234554321.54321IT

What would be the best way to accomplish this?

4 REPLIES 4

Patrick DeCarl1
ServiceNow Employee
ServiceNow Employee

KB15
Giga Guru

That was a given I think but I'm not quite ready for that.



Right now, I'm trying to figure out how to match the user in the user table via the employee ID and then populating the custom table with the user's account. I'm attempting to do this through a transform map. The data will come in during an import.



Essentially, if this employee ID matches with someone in the user table, fill in a custom field "Employee" with the matching user (in a reference field).



I'm thinking that it would be easier to have the import process handle matching users to the business unit instead of leaning on a client script to do the matching and filtering. I completely forgot that ServiceNow will auto fill this for you if the field type is a reference field.



EDIT: This thread helped for this question: Re: populate reference field using transform map scri


Patrick DeCarl1
ServiceNow Employee
ServiceNow Employee

I didnt see where you said during an import..


Sorry. That wasn't clear after re-reading the post. It was a question of whether or not making the associations at the table level made more sense than doing it on the form level. I think this is the better way but I wanted to get some more opinions.



I was able to accomplish this via the import process and linking the user to the related employee field. It was able to map the user correct for both fields automatically


I was also able to use the getUserID function to do the filtering on the form level after resolving the users at the table level using this filter in the variable.



javascript:'u_assigned_employee='+gs.getUserID()