cancel
Showing results for 
Search instead for 
Did you mean: 

sap business one service layer -Filtering field from Contact Employees of Business partners

kyuvi0786
Explorer
1,155

Dear Experts,

Firstly I would like to inform that we have multiple contact persons for the Business partner (Customer) and we are using third party system for Customer Queries and now we would like to store the Internalcode of ContactEmployees back to the third party system and to do so.

We are trying to filter the Contact Employees of Business partner using the custom user defined field (U_cID) created in Contact employees however getting the below error.

Kindly guide me on the filtering aspect

ankit.chauhan1

wenli.chen

andy.bai

Payload:

https://myserver:50000/b1s/v1/BusinessPartners('C-01849124')/ContactEmployees?$filter=U_C4CContactID eq '104278'

{ "error": { "code": -1000, "message": { "lang": "en-us", "value": "Property 'U_C4CContactID' of 'BusinessPartner'is invalid" } }}

View Entire Topic
Paul_
Explorer

Hi @kyuvi0786 ,

Please use the crossjoin function:

/b1s/v1/$crossjoin(BusinessPartners,BusinessPartners/ContactEmployees)?$expand=BusinessPartners($select=CardCode,CardName),BusinessPartners/ContactEmployees($select=CardCode,Name)&$filter=BusinessPartners/CardCode eq BusinessPartners/ContactEmployees/CardCode and BusinessPartners/CardCode eq '1037' and BusinessPartners/ContactEmployees/Name eq 'Paul'

Here, you need to replace '1037' with your BusinessPartner code and Replace Name to your UDF field name and replace 'Paul' to your contact id.

The expected result like this:

{
    "odata.metadata": "$metadata#Collection(Edm.ComplexType)",
    "value": [
        {
            "BusinessPartners": {
                "CardCode": "1037",
                "CardName": "Hi Customer"
            },
            "BusinessPartners/ContactEmployees": {
                "CardCode": "1037",
                "Name": "Paul"
            }
        }
    ]
}