Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

auto generate login name basis on user first initial and last name... LC designer

Avatar

Former Community Member

First initial + last name= login name...

Text field   + text field  = text field....

can I use javascript to generate the loginname form first name (first Int) and last name???

For ex... First name: John

             middle int: k

             last Name: Doe

            LoginName: jdoe

var LoginName = getField("LastName").value;

         var FirstName = getField("FirstName").value;

         if (FirstName!="")

         LoginName += " " + FirstName.substring(0,1) + "."

         event.value = LoginName;

not sure if this is right... please help

1 Accepted Solution

Avatar

Correct answer by
Level 10

You guys are both using Acrobat JS notation so you're not going to have much luck.

In LC there's no getField or event.value and values are returned from fields using fieldName.rawValue (or .formattedValue).

I put this on the Calculate event of the LoginName field:

var vFirstName = FirstName.rawValue;

var vLastName = LastName.rawValue;

if (!(FirstName.isNull || LastName.isNull)) { // if both fields have data

this.rawValue = vFirstName.substring(0,1) + vLastName;

}


View solution in original post

3 Replies

Avatar

Level 5

Hi,

I think you code is a little off as I believe it would result in "doej" which is not what you want.

If you change it to this

      var FirstName = getField("FirstName").value;

      var LastName = getField("LastName").value;

      if (FirstName!="")

      {

           event.value = FirstName.substring(0,1) + LastName; // this should return jdoe

      }

     else

     {    

          event.value = LastName;

     }

Hope this helps

Malcolm

Avatar

Correct answer by
Level 10

You guys are both using Acrobat JS notation so you're not going to have much luck.

In LC there's no getField or event.value and values are returned from fields using fieldName.rawValue (or .formattedValue).

I put this on the Calculate event of the LoginName field:

var vFirstName = FirstName.rawValue;

var vLastName = LastName.rawValue;

if (!(FirstName.isNull || LastName.isNull)) { // if both fields have data

this.rawValue = vFirstName.substring(0,1) + vLastName;

}


Avatar

Former Community Member

Jono Moore....

That's scary that know lol... thanks for your help man, that worked perfectly...