Quantcast
Channel: SCN: Message List - SAP Business ByDesign
Viewing all articles
Browse latest Browse all 5008

Re: Access control : Viewing employees belonging to same company

$
0
0

Hai Ajay,

 

I have an workaround for this issue. Flow the steps one by one.

 

1. First you have to add two element in your BO Definition.

eg,

 

element OwnerId : EmployeeID;

association ToOwner to Employee;

 

element ManagerId : EmployeeID;

association ToManager to Employee;

 

2. In the After modify event you have to write the Business logic to set these id's (OwnerID, ManagerID).

eg code :

import ABSL;

import AP.FO.BusinessPartner.Global;

import AP.PC.IdentityManagement.Global;

var currentIdentityUUID;

var queryIdentity;

var paramIdentity;

var resultIdentity;

var instanceIdentity;

var queryEmployee;

var paramEmployee;

var resultEmployee;

 

currentIdentityUUID = Context.GetCurrentIdentityUUID();

 

if (this.PlanOwner.IsInitial())

{

    queryIdentity = Identity.QueryByElements;

    paramIdentity = queryIdentity.CreateSelectionParams();

    paramIdentity.Add(queryIdentity.UUID.content, "I", "EQ", currentIdentityUUID.content);

    resultIdentity = queryIdentity.Execute(paramIdentity);

    foreach (instanceIdentity in resultIdentity)

    {

        break;

    }

}

 

if (instanceIdentity.IsSet())

{

    queryEmployee = Employee.QueryByIdentification;

    paramEmployee = queryEmployee.CreateSelectionParams();

    paramEmployee.Add(queryEmployee.UUID.content, "I", "EQ",  instanceIdentity.BusinessPartnerUUID.content);

    resultEmployee = queryEmployee.Execute(paramEmployee);

    foreach (var oneEmployee in resultEmployee)

    {

        this.OwnerId.content = oneEmployee.IdentificationEmployeeID.EmployeeID.content;

        this.ToOwner= oneEmployee;

        break;

    }

}

 

Now apply the logic to set the ManagerID.

 

3. On the OWL click DataModel tab

4. Add the Structure in the Root. Again bind this new structure with your Custom BO.

Add data Field inside this structure and bind this to BO Elements.

5. Add Event handler to do BoOperation to create an instance.

6. Bind this event to onFire of Inport in OWL.

7. Add "DataOperation" in to assign the EmployeeID  to the search Param of the Query.

8. this Data operation must be added before "ExecuteQuerySet".

 

 

Now the Owl contains only logged in Employee data only.

 

All the Best.....


Viewing all articles
Browse latest Browse all 5008

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>