You are viewing limited content. For full access, please sign in.

Question

Question

Turn user name into an email address

asked on April 20, 2018

Trying to get Forms to take an employee name (Connie Prendergast) and turn it into an email address in another field by taking the first initial and last name ...

   CAN THIS BE DONE?

Or is there an easier way?  Can Forms take a name and match it to our Active Directory and return the person's email address into another field?

0 0

Replies

replied on April 20, 2018 Show version history

Are the users licensed? If your form is not public and user accounts are synced through LFDS/AD or LDAP, then you should just be able to use the Current User > Email variable {/_useremail} that's built into Forms.

 

0 0
replied on April 23, 2018 Show version history

Some of the users are licensed and part of our active directory, set up as a Windows Account in our repository.  

Some of the names in the drop-down list are seasonal employees (outdoors workers) and not given access to our repository, but still need an email when this process finishes if it was activated on behalf of them.  These are the ones that I need to be able to have both a name and an email address for.

0 0
replied on April 23, 2018

Hi Connie, 

 

You can use Javascript to retrieve the values of the name and populate an email address into a field using the name and just manipulating it with Javascript.

0 0
replied on April 23, 2018

I tried some javascript I found posted here:  https://answers.laserfiche.com/questions/122119/Accessing-values-field-from-dropdown-list#122139

It looked like this, but it didn't work:

$(document).ready(function(){
  $('#Field30').change(function(){
    $('#Field24').val($('#Field24 option:selected').text());
  })
})

0 0
replied on April 23, 2018 Show version history

$(document).ready(function(){

  $('#fieldID input').on('change',FunctionName);

FunctionName(){

    var FullName = $('#Name input').val();
    var Email = FullName + "@gmail.com";
    $('#EmailField input').val(Email);
}

});

Something like this would work if you want to add the email to a certain field

0 0
replied on April 23, 2018

Sorry, I'm having trouble figuring out what parts to tweak.  I now have this for script, but I must have missed something.  Field 31 is the email field; Field 24 is the Employee_1 field:

$(document).ready(function(){

  $('#fieldID input').on('change',FunctionName);

FunctionName(){

    var FullName = $('#Field24').val();
    var Email = FullName + "@flagstaff.ab.ca";
    $('#Field31 input').val(Email);
}

});
 

And the variables after the test ended up like this:

But the default for the email field is:

 so the @flagstaff.ab.ca part was already filling in before.  And then I did another test with the default removed from the email field and the test ended up with an empty field.

0 0
replied on April 23, 2018

So, why wouldn't this work:

  • I have an Employee field where the employee's full name is picked out of a drop down list and the variable attached to it is the first part of his email address.
  • Then I have an email address field where the default is {/dataset/Employee_1}@flagstaff.ab.ca

 

Yet, after testing this, I get:

And yet, even so, this still wouldn't result in what I want.  I need the full name in a field on the template, and I need the email address available to the process!

0 0
replied on April 23, 2018 Show version history

SUCCESS!!!  Using concatenate in the Advanced Tab! 

I created a hidden field and made the default the @flagstaff.ab.ca part of the email.  Then, in the advanced tab, I added:  =CONCATENATE(Employee_1,"",Employee_Hidden)

The template name still comes out using the shortened form of the name, but... better than getting the whole email address showing up in the employee name field and in the name of the document when it saves to the repository!

0 0
replied on April 24, 2018 Show version history

I made a small sample, is this what you are looking for?

I made a class for each object and used the class to work with the code:

 

The code will run everytime a diffrent name is chosen. As the method is called OnChange();

1 0
replied on April 25, 2018

Thanks, Johan.  I'm intrigued by your solution and I'm sure I could use that concept for my forms processes in the future and I have documented what you've done so I can keep it in mind.

Unfortunately, I don't think I can use your solution in this form, because our employee names don't transfer over to the email address exactly.  We use the first initial and last name instead of the full first name and last name in the email address.  Here is what I'm getting with the concatenate solution I found on Monday:  

I would rather the full name in the Employee Name field on the template, but it is only picking up the variable from the initial form submission, and that variable is tied to what I need in the email address.

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.