Adding Requestor Title and Department to Form

Mike Formica
Kilo Expert

I need to display the requester's title and department on the case form.  Is a client side script the best option or is there something simpler?  Thanks in Advance !

 

Case Form Fields

find_real_file.png

 

 

User Table:

find_real_file.png

 

5 REPLIES 5

Dubz
Mega Sage

It depends how you want it to display. If you want those fields to be filled in when the opened_by field changes then you'll need a client script (and a glide ajax call to a script include) but if you want them filled when the form is saved you can use a before insert business rule.

Sai Anna
ServiceNow Employee
ServiceNow Employee

Hi Mike,

 

you don't need to write client script for this. you can add fields using dot walk.

1. Configure--> Form Layout

2. Select "Opened For" and expand

find_real_file.png

 

3. Select Title and department add it at your desired location in form

 

find_real_file.png

 

Thanks,

Sai

Hit like, Helpful or Correct depending on the impact of the response

 

Jaspal Singh
Mega Patron
Mega Patron

Hi Mike,

 

onChange() Client script that runs on Name field (considering is a reference field) with below snippet would be a better & only option if you want to get it worked when Name field changes.

function onChange(control, oldValue, newValue, isLoading) {
	if (isLoading || newValue == '')
		return;
	
	var location = g_form.getValue("location");
	var caller = g_form.getReference("name_of_user_field"); //field namewhere user is selected
	
	if (location == "") {
		if( caller != null)
			g_form.setValue("location", caller.location);
	}
}

 

Else, you can get a Before/After Business rule created as well but the Location will be filled only when record is saved.

I would prefer Client script though as results would show up on the go itself.

 

Thanks,

Jaspal Singh

 

Hit Helpful or Correct on the impact of response.

Agree but in this case, he has to create title and department fields on case table just for display purposes. I wouldn't recommend creating a new field and writing scripts to populate information if we can dot walk and display Opened For information. Just my perception though. please correct if I'm wrong