2 Replies Latest reply on Jul 20, 2017 3:19 AM by WildwoodChris

    Initials for stamp from identity.name


      Is it possible to generate initials for stamp from the identity.name field?  I can get the identity.name into my stamp (gives the whole name) and I can see JavaScript examples for extracting the initials from a 'Name' type field but I don't seem to be able to put them together.  What I want is for Adobe to read the identity.Name field, Joe Bloggs for example and put JB on the applied stamp.


      "event.value = identity.name" works fine for getting the full name into a stamp.


      I could use a scripts such as the below to ask with a pop up dialogue box: -


      var cAsk = "Enter your initials" ;

      var cTitle = "Initials";

      if(event.source.forReal && (event.source.stampName == "#G3wJtsfhyWcjjhWYZ5ombB"))


        var cMsg = app.response(cAsk);

          event.value = cMsg;

        event.source.source.info.DocumentState = cMsg;



      This would mean that you have to enter your initials every single time you use the stamp, so it's not really ideal.  The scripts I have gleaned from the web for extracting initials need the name field as a variable and I don't know how I can get identity.name to be used to extract the initials.  An example (which I can't get to work as it needs a 'function name' on line three apparently) is: -




      var  n=fn.split(" "),              // Split the full name into an array

        it="",                                  // Create and set the intials variable to nothing

        i;                                       // Set i to 0 for the while loop

      while(i<n.length)                // While loop that runs while i is smaller than the length of the array of names


        it+=n[i][0];                         // Get the first letter from the name and add it to the it(initial) variable

        i++                                    // Increment i by 1


      return(it.toUpperCase())    // Convert the initials to uppercase and then return it



      There are other examples of extracting initials out there such as: -







      Is anyone able to help or has achieved this in a different way?  Is the getInitials function an available option?  Any help would be appreciated - thanks!

        • 1. Re: Initials for stamp from identity.name
          try67 MVP & Adobe Community Professional

          You can use this code:


          event.value = getInitials(identity.name);
          function getInitials(string) {
              var names = string.split(' '),
                  initials = names[0].substring(0, 1).toUpperCase();
              if (names.length > 1) {
                  initials += names[names.length - 1].substring(0, 1).toUpperCase();
              return initials;


          I took the getInitials code from one of the links you provided and adjusted it a bit to work in this context, but I didn't test it.


          One problem I can think of is with hyphenated names like "John-Jack". The result for that will not be "JJ", but just "J"... This can be accounted for by replacing all hyphens with a space in the getInitials function.

          1 person found this helpful
          • 2. Re: Initials for stamp from identity.name
            WildwoodChris Level 1

            Thank you so much!  I tried that code in the stamp and it works beautifully.


            I think the hyphenated names shouldn't be too much of an issue. I will roll it out and see what comments I get!  Thanks again.