Script to Auto-populate email address into field within record producer.

jewing
Tera Contributor

Hello,

 

I created a record producer for a service that's designed to allow users to request access to another system on our infrastructure. In the simple workflow, the requestor selects their requested user in the first field that is a "reference" of "user sys_user". I'm wanting to automatically fill in the next field entitled "email" with the email address of the user identified in the previously selected field. Any ideas on how to accomplish this as I don't see much information for this specifically?

 

See the attached screen shot for better illustration:

  • Field 300 - User First & Last Name - Reference > "user sys_user"
    • Data captured from "user sys_user" reference in Field 300 automatically populates email of selected user in Field 450. 
  • Field 450 - user email - Single Line Text (Automatically receives email of previously selected user in Field 300)

Thank you for any information you can provide.

 

5 REPLIES 5

Community Alums
Not applicable

You can add onChange client script to populate this value with GlideAjax

Thanks for this, do you have a link to a deeper description of this? I'm interested to learn more about this way.

Community Alums
Not applicable

Kai Tingey
Tera Guru

You can do it directly in the client script if you want. Try this in an onChange client script:

function onChange(control, oldValue, newValue, isLoading) {
   if (isLoading || newValue == '') {
      return;
   }

	if (newValue != ''){
	
		var user = g_form.getReference('field_300',popEmail);
		
	}
	
	function popEmail(user)
	{
		g_form.setValue('field_450',user.email);
	}
   
}