cancel
Showing results for 
Search instead for 
Did you mean: 

No result on querying the Employee BO on ID returned by the Employee OVS

Former Member
0 Kudos

Hi Experts,

I have mapped the OVS component property of an extension field to the Employee 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;

Nothing is returned in the ERresultData. Any thoughts on possible reasons for this issue ?

Regards

Shruti

Accepted Solutions (1)

Accepted Solutions (1)

Former Member

Here is a code sample one of our developers shared that works "out of box" when you need to create an association to the C4C employee BO. This should give you an idea how to query the employee BO. Also included a sample of the BO too.

//query the employee BO to get the employee responsible related data

//if (!this.EmployeeResponsible.IsSet()) {

varquery_EmployeeResp;

varEmployeeResp_selparam;

varEmployeeResp_instance;

varquery_EmployeeResp_result;

query_EmployeeResp = Employee.QueryByIdentification;

EmployeeResp_selparam = query_EmployeeResp.CreateSelectionParams();

EmployeeResp_selparam.Add(query_EmployeeResp.InternalID, "I", "EQ", this.EmployeeResponsibleID);

query_EmployeeResp_result = query_EmployeeResp.Execute(EmployeeResp_selparam);

if (query_EmployeeResp_result.Count() == 0) {

this.EmployeeResponsible.Reset();

}

else {

foreach (EmployeeResp_instanceinquery_EmployeeResp_result) {

this.EmployeeResponsible = EmployeeResp_instance;

break;

}

}



//bo code


import AP.Common.GDT as GDT;

import AP.FO.BusinessPartner.Global;

import AP.CRM.Global;

import AP.Common.Global;

import AP.PC.IdentityManagement.Global;

import AP.FO.Product.Global;

import AP.FO.ServiceLevelObjective.Global;

import AP.PC.ActivityManagement.Global;

import AP.FO.ServiceIssue.Global;

import AP.FO.MOM.Global;

businessobject ServiceTemplate

raises ServiceTemplateCreated, MandatoryFieldMissing, StatusChange, DefaultTemplateError, DefaultTemplateSuccess, CorporateTemplateSuccess, ActivateTemplate

{

        // Root node must not be specified, it is created implicitly

        //

        // Add elements here.

        //

        // To declare an element as alternative key, use the [AlternativeKey] annotation.

        // Please note:

        // - An alternative key of type UUID exists implicitly for each node, enabling the node

        //   to be used as an association target.

        // - The QueryByElements query is created automatically for each node.

        // - Code completion is available with CTRL + SPACE.

[Label("ID")] [Tooltip("ID")] [AlternativeKey] element ServiceTemplateID : ID;

[Label("Description")] [Tooltip("Description")] element Description : LANGUAGEINDEPENDENT_LONG_Description;

[Label("Status")] [Tooltip("Status")] element Status : PartyLifeCycleStatusCode = "1";

[Label("Is Default")] [Tooltip("Is Default")] element IsDefault : Indicator;

[Label("Is Corporate Template")] [Tooltip("Is Corporate Template")] element IsCorporateTemplate : Indicator;

[Label("Is Maintenance Template")] [Tooltip("Is Maintenance Template")] element IsMaintenanceTemplate : Indicator;

[Label("Service Type")] [Tooltip("Service Type")] element ServiceType : BusinessTransactionDocumentProcessingTypeCode;

[Label("Service Description")] [Tooltip("Service Description")] element ServiceDescription : LANGUAGEINDEPENDENT_LONG_Description;

[Label("Service Subject")] [Tooltip("Service Subject")] element ServiceSubject : LANGUAGEINDEPENDENT_LONG_Description;

[Label("Source")] [Tooltip("Source")] element Source : LANGUAGEINDEPENDENT_LONG_Description;

[Label("Priority")] [Tooltip("Priority")] element Priority : PriorityCode;

[Label("Service Category")] [Tooltip("Service Category")] element ServiceCategoryID : ID;

[Label("Incident Category")] [Tooltip("Incident Category")] element IncidentCategoryID : ID;

[Label("Cause Category")] [Tooltip("Cause Category")] element CauseCategoryID : ID;

[Label("Object Category")] [Tooltip("Object Category")] element ObjectCategoryID : ID;

[Label("Resolution Category")] [Tooltip("Resolution Category")] element ResolutionCategoryID : ID;

[Label("Service Status")] [Tooltip("Service Status")] element ServiceStatus : Common.DataTypes:ServiceRequestUserLifeCycleStatusCode ; //SR ticket type code list

[Label("Product")] [Tooltip("Product")] element ProductID : ID;

[Label("Service Level Objective")] [Tooltip("Service Level Objective")] element ServiceLevelObjectiveID : ServiceLevelObjectiveID;

[Label("Customer")] [Tooltip("Customer")] element CustomerID : BusinessPartnerInternalID;

[Label("Contact")] [Tooltip("Contact")] element ContactID : BusinessPartnerInternalID;

[Label("Requires Work")] [Tooltip("Requires Work")] element RequiresWorkIndicator : Indicator;

[Label("Administrator")] [Tooltip("Administrator")] element AdministratorID : BusinessPartnerInternalID;

[Label("Employee Responsible")] [Tooltip("Employee Responsible")] element EmployeeResponsibleID : BusinessPartnerInternalID;

[Label("Agent")] [Tooltip("Agent")] element AgentID : ID;

[Label("Team")] [Tooltip("Team")] element TeamID : ID;

[Label("Technician")] [Tooltip("Technician")] element TechnicianID : ID;

[Label("Technician Team")] [Tooltip("Technician Team")] element TechnicianTeamID : ID;

[Label("Changed On")] [Tooltip("Changed On")] element ChangedOnDate : Date;

[Label("Changed On Time")] [Tooltip("Changed On Time")] element ChangedOnTime : Time;

[Label("Changed By")] [Tooltip("Changed By")] element ChangedByID : BusinessPartnerInternalID;

[Label("Changed By Name")] [Tooltip("Changed By Name")] element ChangedByName : LANGUAGEINDEPENDENT_LONG_Description;

[Label("Created On")] [Tooltip("Created On")] element CreatedOnDate : Date;

[Label("Created On Time")] [Tooltip("Created On Time")] element CreatedOnTime : Time;

[Label("Created By")] [Tooltip("Created By")] element CreatedByID : BusinessPartnerInternalID;

[Label("Created By Name")] [Tooltip("Created By Name")] element CreatedByName : LANGUAGEINDEPENDENT_LONG_Description;

[Transient] element IsMaintenanceTemplateIndc : Indicator;

[Transient] element IsDeletedIndc : Indicator;

[Transient] element IsObsoleteIndc : Indicator;

[Transient] element IsActiveIndc : Indicator;

[Transient] element IsDefaultIndc : Indicator;

[Transient] element IsNotDefaultIndc : Indicator;

[Transient] element IsCorporateTemplateIndc : Indicator;

[Transient] element TargetIDtemp : ID;

[Transient] element SourceIDtemp : ID;

node ServiceTemplateItems [0,n] {

[Label("Quantity")] element Quantity : NumberValue;

[Label("Product")] element ProductID : ID;

[Label("Amount")] element Amount : Amount;

[Label("Cost Amount")] element CostAmount : Amount;

[Label("Description")] [Tooltip("Description")] element Description : LANGUAGEINDEPENDENT_LONG_Description;

[Label("Changed On")] [Tooltip("Changed On")] element ChangedOnDate : Date;

[Label("Changed On Time")] [Tooltip("Changed On Time")] element ChangedOnTime : Time;

[Label("Changed By")] [Tooltip("Changed By")] element ChangedByID : BusinessPartnerInternalID;

[Label("Changed By Name")] [Tooltip("Changed By Name")] element ChangedByName : LANGUAGEINDEPENDENT_LONG_Description;

[Label("Created On")] [Tooltip("Created On")] element CreatedOnDate : Date;

[Label("Created On Time")] [Tooltip("Created On Time")] element CreatedOnTime : Time;

[Label("Created By")] [Tooltip("Created By")] element CreatedByID : BusinessPartnerInternalID;

[Label("Created By Name")] [Tooltip("Created By Name")] element CreatedByName : LANGUAGEINDEPENDENT_LONG_Description;

[Label("Inactive")] [Tooltip("Inactive")] element InactiveIndicator : Indicator;

[Label("Notes")] [Tooltip("Notes")] element Notes : LANGUAGEINDEPENDENT_LONG_Description;

association ChangedBy to Employee;

association CreatedBy to Employee;

association ServiceTemplateItemProduct [0,1] to AP.FO.ProductDataMaintenance.Global:Material;

}

association Customer to AP.FO.BusinessPartner.Global:Customer;

association Contact to AP.FO.BusinessPartner.Global:BusinessPartner;

association EmployeeResponsible to Employee;

association Administrator to Employee;

association ChangedBy to Employee;

association CreatedBy to Employee;

association ServiceLevelObjective to AP.FO.ServiceLevelObjective.Global:ServiceLevelObjective;

association Product to AP.FO.ProductDataMaintenance.Global:Material;

association ServiceCategory to AP.FO.ServiceIssue.Global:ServiceIssueCategoryCatalogue;

association IncidentCategory to AP.FO.ServiceIssue.Global:ServiceIssueCategoryCatalogue;

association Agent to Employee;

association Technician to Employee;

association Team to FunctionalUnit;

association TechnicianTeam to FunctionalUnit;

action SetToActive;

action SetToObsolete;

action SetToDelete;

action SetToDefault;

action SetToNotDefault;

message ServiceTemplateCreated text"Service Template ID:&1 created." : LANGUAGEINDEPENDENT_LONG_Description;

message MandatoryFieldMissing text"Please enter a &1." : LANGUAGEINDEPENDENT_LONG_Description;

message StatusChange text"Service Template set as &1." : LANGUAGEINDEPENDENT_LONG_Description;

message DefaultTemplateError text"There can only be one active default template for Service Type: &1." : LANGUAGEINDEPENDENT_LONG_Description;

message DefaultTemplateSuccess text"This template will be automatically used for Service Type: &1." : LANGUAGEINDEPENDENT_LONG_Description;

message CorporateTemplateSuccess text"This template will be available for all users.";

message ActivateTemplate text"Please set to Active to use template.";

}

Former Member
0 Kudos

Hi Rei,

Thanks a lot for your valuable response. I had set the type of EmployeeResponsible extension field to ID whereas it was supposed to be BusinessPartnerInternalID. The code you posted helped in identifying this error.

Thanks for the help

Regards

Shruti

Answers (0)