How to get current logged on business user’s employee information and assigned organization unit via ABSL
My series of Cloud Application Studio Blogs
- How to detect EditMode in an Embedded Component
- Step by step to enable your custom BO with attachment upload functionality
- Step by step to create an Adobe Print form in Cloud application Studio
- How to render PDF which displays picture from the image attachment of your custom BO
- How to get current logged on business user’s employee information and assigned organization unit via ABSL
- How to implement dynamic access control based on custom BO using OWL
- How to make Code List Restriction work when control field and restricted field are not on the same BO
Suppose I have business user WANGJERRY37 which could be reviewed in Work center Administrator, and once clicking Name column,

I could find corresponding employee ID 37 and its department name:


This India PMLS could be found in Work center view Administrator->General Settings->Company->Org Structures:

Suppose I want to retrieve the Department Name of the current logged on business user’s assigned Organization unit for example PMLS below:

The general idea is:
- get current log on business user’s uuid via Context.GetCurrentIdentityUUID()
- get the identification instance of the found business user by query
- get the corresponding employee instance of current business user
- get assigned organization unit of found employee got from step 3
- get the department name of found organization unit from association NameAndAddress
- create a transient field in a custom BO and write the above logic into AfterLoading event. The script file for this AfterLoading is marked as NOT mass-enabled.


Now once I open the TI page of my custom BO, the transient field is filled by the script accordingly.

The complete ABSL source code could be found below:
import ABSL;
import AP.PC.IdentityManagement.Global;
import AP.FO.BusinessPartner.Global;
var queryByIdentityUUID = Identity.QueryByElements;
var queryByIdentityUUIDParameter = queryByIdentityUUID.CreateSelectionParams();
var queryByEmployeeBPUUID = Employee.QueryByIdentification;
var queryByEmployeeBPUUIDParameter = queryByEmployeeBPUUID.CreateSelectionParams();
if ( this.DepartmentName.IsInitial()){
var id = Context.GetCurrentIdentityUUID().content;
queryByIdentityUUIDParameter.Add( queryByIdentityUUID.UUID.content, "I", "EQ", id.ToString() );
var result = queryByIdentityUUID.Execute(queryByIdentityUUIDParameter);
var first = result.GetFirst(); // points to identity instance
var person = first.Person;
var bpUUId = person.UUID.content;
queryByEmployeeBPUUIDParameter.Add( queryByEmployeeBPUUID.UUID.content, "I", "EQ", bpUUId.ToString());
var employeeQueryResult = queryByEmployeeBPUUID.Execute(queryByEmployeeBPUUIDParameter);
var EmployeeQueryResultCurrent = employeeQueryResult.GetFirst();
var assignedOrg = EmployeeQueryResultCurrent.OrganisationalUnitAssignment.GetFirst();
var org = assignedOrg.ToRoot;
// readOnly in AfterLoading event
this.DepartmentName = org.NameAndAddress.AddressSnapshot.NameSuitableForLogonLanguage.GetFirst().Name.SecondLineName;
}
Great article but is there any changes in code because I get an error that "OrganisationalUnitAssignment" doesn't exist:
Did u import import ABSL; import AP.PC.IdentityManagement.Global; import AP.FO.BusinessPartner.Global; ?
<a href="http://may2018calendar.com">May 2018 Calendar Printable</a>
Hello Jerry,
Can I get Employee information like assigned user id , territories where he is assigned , from a web service?
I didnt find any standard webservice which gives me employee id if I pass his user name.
Can you please help me in this?
Regards,
Dhruvin
Hello Dhruvin,
Could you provide the Web Service details incase if you are able to find one? We also have similar requirement.
Thanks,
AG
Hi Ag,
Unfortunately i dont remember it now fully 😛
However as far as i know wedid create a fullly customBO for it and made an Odata Services for it.
I know not a good solution but unfortunately that was the fastest solution.
BR
Dhruvin
Hello Jerry,
Is it also possible to do a similar thing for ByDesign? For e.g. use a button to get to a custom BO with a hand over of the ID of an Opportunity?
Best Regards,
Nathanael Mangold
It's very useful snippet.
Thanks Jerry! It’s posts like this that give any hope of being able to deal with this .. system.
Thanks again
Nice post Jerry! It is very helpful. Considering that an employee can be terminated/rehired, he can have multiple employee records with the same UUID and considering that an employee can be transferred to different org unit, he can can have multiple Org Assignments. So I think it would be best to consider the current dates in the above queries to get the current employee record and current Org assignment instead of getFirst()
Dear Jerry,
Great Post, thank you for sharing. One thing is that avoiding Query executing; Retrieve method is faster than any Query so if you need to reach the object with UUID you can use Retrieve. For this case you can get the personid by;
var bpUUId = Identity.Retrieve(Context.GetCurrentIdentityUUID()).Person.UUID.content;
Thank you.
Ekrem
Dear Jerry,
Very useful snippet. I was wondering, is it possible to enhance C4C top right section and include attributes from User Profile? Appreciate your time.
Thanks,
AG