// TO get a current User Id and User Role and WorkerIdassignment through X++ in ax 2012
static void HCMWorkerIDFromUSerID(Args _args)
{
UserInfo userInfo;
SecurityUserRole securityUserRole;
SecurityRole Roles;
HcmWorkerRecId workerRecId ;
str workerDesgn,workername;
Label label = new Label();
info(curUserId()); // Current User id
workerRecId = DirPersonUser::currentWorker();
info(strFmt("%1",workerRecId)); // HCM.Person // worker id
while select userInfo where userInfo.Id == curUserId()
join securityUserRole where securityUserRole.User == userInfo.Id
join Roles where Roles.RecId == securityUserRole.SecurityRole
{
workerDesgn = Roles.Name;
info(strFmt("%1",workerDesgn));
workername = label.extractString(Roles.Name);
info(strFmt("%1",workername));// Current WOrker Name
}
}
static void HCMWorkerIDFromUSerID(Args _args)
{
UserInfo userInfo;
SecurityUserRole securityUserRole;
SecurityRole Roles;
HcmWorkerRecId workerRecId ;
str workerDesgn,workername;
Label label = new Label();
info(curUserId()); // Current User id
workerRecId = DirPersonUser::currentWorker();
info(strFmt("%1",workerRecId)); // HCM.Person // worker id
while select userInfo where userInfo.Id == curUserId()
join securityUserRole where securityUserRole.User == userInfo.Id
join Roles where Roles.RecId == securityUserRole.SecurityRole
{
workerDesgn = Roles.Name;
info(strFmt("%1",workerDesgn));
workername = label.extractString(Roles.Name);
info(strFmt("%1",workername));// Current WOrker Name
}
}
No comments:
Post a Comment