Skip to main content
sunus0001
January 25, 2022
Solved

How to get the UserName from User Id in a aggregate column function or a rule for filter

  • January 25, 2022
  • 7 replies
  • 1 view

a!queryEntity(
  entity: cons!PF_ENTITY_VW_REQUEST,
  query: a!query(
    aggregation: a!queryAggregation(
      aggregationColumns: {
        a!queryAggregationColumn(field: "RequestUserID", isGrouping: true),
        a!queryAggregationColumn(
          field: "RecordID",
          isGrouping: false,
          aggregationFunction: "COUNT"
        )
      }
    ),
    logicalExpression: a!queryLogicalExpression(
      operator: "AND",
      filters: {
        a!queryFilter(field: "RecordID", operator: "not null"),
        if(
          isnull(ri!RequestUserId),
          {},
          a!queryFilter(
            field: "RequestUserID",
            operator: "=",
            value: ri!RequestUserId
          )
        ),
        if(
          isnull(ri!activeStatus),
          {},
          a!queryFilter(
            field: "ActiveStatus",
            operator: "=",
            value: ri!activeStatus
          )
        ),
        if(
          isnull(ri!RecordID),
          {},
          a!queryFilter(
            field: "RecordID",
            operator: "=",
            value: ri!RecordID
          )
        )
      }
    ),
    pagingInfo: if(
      isnull(ri!pagingInfo),
      a!pagingInfo(startIndex: 1, batchSize: - 1),
      ri!pagingInfo
    )
  )
)

Hi Appian team,

Please check above code return for rule expression, it returns two fields one is RequestUserID and other is recordID. I want to fetch Username from UserID which means I have to get one more field as output that is UserName which I should get from user ID. I know there is user() function in-Build, but i do not know where i can use it to fetch username from RequestUserID field.

Can anyone of you help me solve this issue?

Thanks

Sunu Sam

Best answer by sunus0001

thanks for your help...finally its working i have written a rule to fetch username from user ID and called it where am using it.

7 replies

harshitb6843
January 25, 2022

Hi there,

The user function works with the username. We can use the user function to get different properties of a user by passing the username and the property that we want to query. In the above problem, you mentioned that you want to extract the username using the user function. But that is the input we have to pass to that function. 

Can you tell me what kind of data is this query returning? Is UserID an integer value or text value? Can you also attach the resultant data subset so I can take a look at the output? 

sunus0001
sunus0001Author
January 25, 2022

Hi Harshit,

thank you for replying,

Yes UserID is text field.

Following is the result for the above code snippet added.

    • RequestUserID"AC8648"(Text)
      • RecordID8(Number (Integer))
      • Dictionary
          • RequestUserID"XX33889956"(Text)
            • RecordID25(Number (Integer))
            • Dictionary
                • RequestUserID"Yx33778457"(Text)
                  • RecordID3(Number (Integer))
                  • Dictionary
                      • RequestUserID"Re8898901"(Text)
                        • RecordID1(Number (Integer))

                      What is my requirement is i want one more field in the result that is UserName which i should fetch passing REquestUserID as input

                      harshitb6843
                      January 25, 2022

                      Is REquestUserID the usernames of the Appian user accounts?