1 Reply Latest reply on Aug 15, 2013 8:31 PM by MichaelN

    Help with custom script that can enter a users name

    foreigncarguy Level 1

      I am trying to use the custom calculation script to automatically fetch and enter the users name in a field. Is this possoble? It seems easy to get the date, but the users name seems hard to get.

        • 1. Re: Help with custom script that can enter a users name
          MichaelN Level 3

          If you mean the user's login name, then you can find this by using

           

               identity.loginName

           

          However, due to security restrictions you need to create a trusted function, as the identity object properties are accessible only during batch, console and application initialisation events.

           

          The function would look something like this:

           

               getUserName = app.trustedFunction(

               function()

               {

               app.beginPriv();

               var c = identity.loginName;

               app.endPriv();

               this.getField("myUserName").value = c;   //places the login name into the myUserName text field

               }

               );

           

          You place the above script in the JavaScripts folder of the user.

           

          You then call this function by the following:

           

               getUserName()

           

          This will place the login name into "myUserName" text field on the form.

           

          Hope this helps.