The CreatorCon Call for Content is officially open! Get started here.

Auto-populate field on Cat Item Form with "Head of Department" of Users department

Konstantinos Di
Mega Guru

Hello everyone,
I am currently trying to auto-populate a field  on my Cat Item.
It should have the Head of Department of the Users department (cmn_department)

What type of variable should I use and what if I in the future the customers want to have multiple "Head of Department" - User? How can I make this work with one and what would change if the future case happens?

 

I have attached my current response but couldn't decide how to actually auto-populate it.

Thanks to everyone in advance šŸ™‚

1 ACCEPTED SOLUTION

Ok so I found the solution to it.
By adding the following lines to the "Default Value" it auto-fills it with the right dept_head:
javascript:var userDept=gs.getUser().getDepartmentID();
var deptHead='';
var deptGR=new GlideRecord('cmn_department');
if(deptGR.get(userDept)){deptHead=deptGR.getValue('dept_head');}
deptHead;

 

Thanks again everyone nonetheless šŸ™‚

View solution in original post

5 REPLIES 5

Ravi Chandra_K
Kilo Patron
Kilo Patron

Hello @Konstantinos Di 

Greetings!

Any feedback on my reply? were you able to do this.?

Please mark the answer as correct solution and helpful if helped.

Kind Regards,

Ravi Chandra