Skip to Content

Party role for XBO

Dear experts,

I'm building a custom solution which requires determination rules for the involved parties of this object. Could you please give me a hint of how to achieve this?

- The object is called BuildingObject. This BuildingObject can have ParentBuildingObject.

- Each BuildingObject has a Team with following roles associated to employee: EmployeeReponsible, ProjectResponsible, QuoteMonitor

- EmployeeResponsible should be current user

- ProjectResponsible and QuoteMonitor should be pulled from ParentBuildingObject as default (if existed)

Thank you so much

Cheers

Linh

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Best Answer
    May 06, 2017 at 01:22 AM

    Hi Linh,

    you can access the current user via session identity and then query the employee. Here's a snippet:

    import AP.PC.IdentityManagement.Global;
    import AP.FO.BusinessPartner.Global;
    
    var identityUUID = Context.GetCurrentIdentityUUID();
    var identity = Identity.Retrieve(identityUUID);
    if (identity.IsSet()) {
        var empQ = Employee.QueryByIdentification;
        var empQP = empQ.CreateSelectionParams();
        empQP.Add(empQ.UUID.content, "I", "EQ", identity.BusinessPartnerUUID.content);
        var empQR = empQ.Execute(empQp);
        if (empQR.Count() > 0) {
    	var employee = empQR.GetFirst();
    		
    	if (this.ResponsibleEmployeeID.IsInitial()) {
    	    this.ResponsibleEmployeeID= employee.IdentificationEmployeeID.EmployeeID;
                this.ResponsibleEmployeeName = employee.CurrentCommon.BusinessPartnerFormattedName;
                this.ToResponsibleEmployee = employee;
    	}
         }
    }
    

    this.ToResponsibleEmployee would be an association. If you use an association, you would probably not need the preceeding ID and Name fields as you could access them via this association.

    Regarding ProjectResponsible and QuoteMonitor: I suggest you should have the ParentBuildingObject referred in an association in your BO definition of BuildingObject, like:

    association ToParentBuildingObject to BuildingObject;

    Then you can access these two roles like:

    if (this.ToParentBuildingObject.IsSet()) {
        this.ProjectResponsible = this.ToParentBuildingObject.ProjectResponsible; 
     // ...and alike for the other role
    }

    If you cannot use an association the parent should be referenced by ID / AlternativeKey and then accessed via:

    var parent = BuildingObject.Retrieve(this.ParentBuildingObjectID);

    Best,

    Pablo

    Add comment
    10|10000 characters needed characters exceeded