1
0
-1

Does anyone know how I can do a user lookup from a Groovy Service in TM?

    CommentAdd your comment...

    3 answers

    1.  
      3
      2
      1

      Hi Diana,

      Here's how I access user properties based on the logged in user as part of a prefill:

       

      /*
       Script parameters include:
        form : com.avoka.fc.core.entity.Form
        formRequestParams : Map<String, Object>
        request : javax.servlet.http.HttpServletRequest
        schemaSeed : org.w3c.dom.Document
        userAccountId : String
        serviceDefinition : com.avoka.fc.core.entity.ServiceDefinition
        serviceParameters : Map<String, String>
       */
        
       import com.avoka.fc.core.dao.DaoFactory;
       import com.avoka.fc.core.dao.ClientDao;
       import com.avoka.fc.core.dao.ClientPropertyDao;
        
        
        
       // only needed for testing service.
       if (!userAccountId){
       userAccountId = 'yourname'
       }
        
        
       //get user account from user name
       def user = DaoFactory.getUserAccountDao().getActiveUserAccountForLogin(userAccountId);
        
       assert user != null
        
       // load user profile and user properties
       def userProfile = user.getActiveProfile()
       def userName = user.getLoginName().toUpperCase()
       def userPropertyMap = userProfile.getPropertyValues()
       def friendlyName = user.getFullName()
        
        
        
       // extract from user profile properties
       def useLastShift = userPropertyMap['Copy Last Shift'] ?: "false"
       def projectName = userPropertyMap['Project']
       def defShift = userPropertyMap['Shift Type'] ?: "Day Shift"
       def start = setShiftTime(userPropertyMap['Shift Start Time'])
       def finish = setShiftTime(userPropertyMap['Shift Finish Time'])

       

       

      Hope that helps

       

      Doug O

        CommentAdd your comment...
      1.  
        1
        0
        -1

        You can use class UserAccountDao as well

         

        User lookup
          CommentAdd your comment...
        1.  
          1
          0
          -1

          Thanks Doug! I will try that

            CommentAdd your comment...