Search code examples
joinlabelaxaptadynamics-ax-2012x++

Why in Select Statement on Table SecurityRole I have only Label?


I have a little question, why if I do a Query on table SecurityRole with join other table, when i get the value from field SecurityRole.Name I have only the Label (look like @SYS...) and I have to convert.

SecurityRole securityRole;
SecurityUserRole UserRole;
SysUserInfo  userInfo;
OMUserRoleOrganization roleOrganization;
OMInternalOrganization internalOrganization;

while select ID from userInfo
    order by id asc
    outer join UserRole
    where UserRole.User == userInfo.Id
        outer join securityRole
        where securityRole.RecId == UserRole.SecurityRole
        outer join roleOrganization
        where roleOrganization.User == userInfo.Id
        && roleOrganization.SecurityRole == UserRole.SecurityRole
            outer join internalOrganization
                where internalOrganization.RecId == roleOrganization.OMInternalOrganization
    {

        print userInfo.Id, userInfo.Email, SysLabel::labelId2String(securityRole.Name), internalOrganization.Name ? internalOrganization.Name : "All Company";

        pause;
}

If I do a simple Query like this :

while select securityRole
{
   info (strfmt("%1", securityRole.Name)); // here I have the really value filed - NOT the label
}

So, my question is this : why if I do a query on securityRole with join I will have a label from field Name.

I know, there is a way to get the value from label (SysLabel::labelId2String2(. .. )) , but for me it's better to get the really value from Table's field.

There is a way to get always the really field value (That shown in Table)?

Thanks,

enjoy!


Solution

  • If you explicitly specify the field list in your select clause, you'll get the name of the role, not the label:

    outer join Name from securityRole
    

    instead of

    outer join securityRole