Skip to Content
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:
  1. get current log on business user’s uuid via Context.GetCurrentIdentityUUID()
  2. get the identification instance of the found business user by query
  3. get the corresponding employee instance of current business user
  4. get assigned organization unit of found employee got from step 3
  5. get the department name of found organization unit from association NameAndAddress
  6. 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;
	}
To report this post you need to login first.

7 Comments

You must be Logged on to comment or reply to a post.

  1. Dhruvin Mehta

    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

    (0) 
  2. Nathanael Mangold

    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

    (0) 

Leave a Reply