Topic
6 replies Latest Post - ‏2013-02-22T21:08:49Z by HomerJSimpson
SystemAdmin
SystemAdmin
9855 Posts
ACCEPTED ANSWER

Pinned topic Add an owner attribute on new account notification

‏2013-02-20T21:52:10Z |
Hi all,

I'm trying to modify the mail notification template to include an owner's attribute when a new account is created. I've tried several javascripts but can't figure how to get this thing working so far.

My last attempt used the following js:


<JS>var account = account.get(); var accountOwner = account.getProperty(
'owner')[0]; var ownerName = accountOwner.getProperty(
'name')[0];</JS>


And resulted in the following error in trace.log:

org.apache.bsf.BSFException: Script interpreter error, line=1, col=111: Unknown member 'getProperty' in Java class 'java.lang.String'

The accountOwner variable has the owner DN but I think it needs to be of an specific object type.

Can someone help me figure out how to do this?

Thanks in advance!
Updated on 2013-02-22T21:08:49Z at 2013-02-22T21:08:49Z by HomerJSimpson
  • HomerJSimpson
    HomerJSimpson
    157 Posts
    ACCEPTED ANSWER

    Re: Add an owner attribute on new account notification

    ‏2013-02-21T01:17:03Z  in response to SystemAdmin
    Hi...

    The problem is that account.getProperty('owner')[0] is going to get the 'owner' attribute from the Account object, which will be a DN (string)...not an Object.

    So you'd either need to use that value to create a new Person(accountOwner)
    OR (more efficiently)
    use the 'self' relation..to get the Owner object:

    var accountOwner = account.getProperty('self')[0];
    var ownerName = accountOwner.name;
    // .name will return whatever attribute you've set as the 'naming attribute' on the Entity that is your account owner.
    • SystemAdmin
      SystemAdmin
      9855 Posts
      ACCEPTED ANSWER

      Re: Add an owner attribute on new account notification

      ‏2013-02-22T19:19:27Z  in response to HomerJSimpson
      Hi Homer,

      Thanks for your reply...

      I spent the my day trying to figure out the correct objects without any luck...

      Tried many things but always get some type of conversion error or a "undefined" value:

      
      var account = account.get(); var accountOwner = account.getProperty(
      'self'); var URL = accountOwner.getProperty(
      'VagasURL');
      


      org.apache.bsf.BSFException: Script interpreter error, line=1, col=104: 'accountOwner' is undefined

      This way accountOwner should be a directoryObject where I could use the getProperty method to retrieve any attribute as a string... But I can't see why it is "undefined"...

      I used Enrole.log to print they values to msg.log and got this:

      
      <Message Id=
      "CTGIMO023E" Severity=
      "ERROR"> <Time Millis=
      "1361560387035"> 2013.02.22 16:13:07.035-03:00</Time> <Server Format=
      "IP">XXXXXX</Server> <ProductId>CTGIM</ProductId> <Component>Mail</Component> <ProductInstance>server1</ProductInstance> <LogText><![CDATA[CTGIMO023E  The following definition error occurred. Error: accountOwner= com.ibm.itim.script.wrappers.generic.ProtectedAccountWrapper contained object is:   Profile: itamaccount Name: 500207 ]]></LogText> <Source FileName=
      "com.ibm.itim.script.extensions.impl.EnroleBeanImpl" Method=
      "log(String, String)"/> <TranslationInfo Type=
      "JAVA" Catalog=
      "tmsMessages" MsgKey=
      "standardException.userDefinedError"><Param><![CDATA[accountOwner= com.ibm.itim.script.wrappers.generic.ProtectedAccountWrapper contained object is:   Profile: itamaccount Name: 500207]]></Param></TranslationInfo> </Message>   <Message Id=
      "CTGIMO023E" Severity=
      "ERROR"> <Time Millis=
      "1361560387035"> 2013.02.22 16:13:07.035-03:00</Time> <Server Format=
      "IP">XXXXXXXXX</Server> <ProductId>CTGIM</ProductId> <Component>Mail</Component> <ProductInstance>server1</ProductInstance> <LogText><![CDATA[CTGIMO023E  The following definition error occurred. Error: accountOwner= undefined ]]></LogText> <Source FileName=
      "com.ibm.itim.script.extensions.impl.EnroleBeanImpl" Method=
      "log(String, String)"/> <TranslationInfo Type=
      "JAVA" Catalog=
      "tmsMessages" MsgKey=
      "standardException.userDefinedError"><Param><![CDATA[accountOwner= undefined]]></Param></TranslationInfo> </Message>
      


      Am I missing something??

      Forgot to mention that I'm using ISIM 6.0 with the latest patches.
      • HomerJSimpson
        HomerJSimpson
        157 Posts
        ACCEPTED ANSWER

        Re: Add an owner attribute on new account notification

        ‏2013-02-22T20:04:40Z  in response to SystemAdmin
        ah...yeah...if this is in the 'add' Operation...the Account object that gets passed in, doesn't actually have a owner yet (not until its created)..BUT (assuming add operation), the owner object is one of the 3 objects that is passed in (named 'owner');

        So you could just do:
        var own = owner.get();
        var URL = own.getProperty('VagasURL');
        ...
        • SystemAdmin
          SystemAdmin
          9855 Posts
          ACCEPTED ANSWER

          Re: Add an owner attribute on new account notification

          ‏2013-02-22T20:57:43Z  in response to HomerJSimpson
          It Works!

          Really it was an ADD operation

          For future reference, the only detail is that probably the getProperty() returns an JavaArray, so I needed to include an [0] to indicate which item to use... The final solution was:

          
          var own = owner.get(); var URL = own.getProperty(
          'VagasURL')*[0]*; 
          
          return URL;
          


          Homer, Thanks a LOT for your help... I owe you some duffs!! ;-)
          • SystemAdmin
            SystemAdmin
            9855 Posts
            ACCEPTED ANSWER

            Re: Add an owner attribute on new account notification

            ‏2013-02-22T20:58:45Z  in response to SystemAdmin
            The formatting doesn't works very well... Here is the right one:

            
            var own = owner.get(); var URL = own.getProperty(
            'VagasURL')[0]; 
            
            return URL;
            
          • HomerJSimpson
            HomerJSimpson
            157 Posts
            ACCEPTED ANSWER

            Re: Add an owner attribute on new account notification

            ‏2013-02-22T21:08:49Z  in response to SystemAdmin
            doh!