on 07-29-2013 5:25 PM
Hi ByD'ers
Can some help me find the correct way of determining an employees company based on the input of EmployeeID?
I have a ByD form that has a public OVS to look up employee ID, and with a script I can use this to determine employees full name.
What I am having difficulty with is then determining the same employees Org Centre assignment and Company assignment.
I can see these attributes are available, but seem unable to get any data from them.
I am using this so that the form I have designed can be used to create a purchase order that will dynamically add user Buying Party data based on the employee selected, not necessarily the currently logged in user (so cant use context as a the starting point)
Help with a code snippet perhaps would find me eternally grateful.
John Meadows
+44 7449 944666
Hi John.
There you go, just made a simple query without parameters, is just matter of setting the EmployeeID to it
var CompanyID = Employee.QueryByIdentification.Execute().GetFirst().Position.OrganisationalCentreAssignment.Company.GetFirst().ID;
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
John,
Can you please share the script to fetch the Employee name ? I have also used the EmployeeID OVS, but when I query the Employee BO on the returned ID the result set is empty. Following is the script I have used:
Here "EmployeeResponsible" is an extension element with type ID
import AP.FO.BusinessPartner.Global;
var ERquery = Employee.QueryByIdentification;
var ERresultData = ERquery.ExecuteDataOnly();
var ERselectionParams = ERquery.CreateSelectionParams();
ERselectionParams.Add(ERquery.InternalID, "I", "EQ", this.EmployeeResponsible.RemoveLeadingZeros());
ERresultData = ERquery.ExecuteDataOnly(ERselectionParams);
var ER = Employee.Retrieve(ERresultData.GetFirst().UUID);
this.EmployeeResponsibleDescription = ER.CurrentCommon.BusinessPartnerFormattedName;
Regards
Shruti
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
There is one problem with the above code. The association OrganisationalCenterAssignment is actually 0:n enabled and you need to filter out the correct entry related to the Company.
just use the following where clause
var CompanyID = Employee.QueryByIdentification.Execute().GetFirst().Position.OrganisationalCentreAssignment.Where(n=>n.BusinessCharacterCode == "1").Company.GetFirst().ID;
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.