Skip to Content
0

Service Layer: How To Get Contact Info From ContactPersonCode

Oct 12, 2017 at 02:21 PM

102

avatar image

Hi,

I’m currently using the Service Layer calling the method DeliveryNotes. There is one property called ContactPersonCode as shown below.

I want to ask for this int ID, which method in service layer I can pass the ContactPersonCode to get the contact name?

Regards,

William

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

2 Answers

Best Answer
Ralph Oliveira
Oct 16, 2017 at 12:57 PM
0

Hi Willian.

ContactPerson is a sub object of the BusinessPartner therefore, you need to access the specific BusinessPartner in order to retrieve the ContactPerson details.

You can do that Via Odata Association (3.2. Addressing Links between Entries).

GET https://HANASERVER:50000/b1s/v1/DeliveryNotes(2)/?$select=DocEntry,DocNum,CardCode,ContactPersonCode,BusinessPartner/ContactEmployees&$expand=BusinessPartner

This will return all ContactEmployess from the Business Partner of Delivery Note #2 and also the DocEntry,DocNum,CardCode,ContactPersonCode From Delivery Note #2. See my next reply for a sample of this call response.*

Since chidren's objects filters or "getByKeys" are not supported your code will have to compare which BusinessPartner/ContactEmployee element has the InternalCode property equals to the DeliveryNotes/ContactPersonCode.

But at this point this is trivial :)

Show 3 Share
10 |10000 characters needed characters left characters exceeded
//RESPONSE OF
GET https://hanaserver:50000/b1s/v1/DeliveryNotes(2)/?$select=DocEntry,DocNum,CardCode,ContactPersonCode,BusinessPartner/ContactEmployees&$expand=BusinessPartner

{
    "odata.metadata": "https://hanaserver:50000/b1s/v1/$metadata#DeliveryNotes/@Element",
    "BusinessPartner": {
        "ContactEmployees": [
            {
                "CardCode": "C30000",
                "Name": "Judy Brown",
                "Position": "COO",
                "Address": "4962 Rosewood St, Bronx, 10467",
                "Phone1": "555-0103",
                "Phone2": null,
                "MobilePhone": "555-0103",
                "Fax": "555-0104",
                "E_Mail": "judy.brown@microchips.sap.com",
                "Pager": null,
                "Remarks1": null,
                "Remarks2": null,
                "Password": null,
                "InternalCode": 5,
                "PlaceOfBirth": null,
                "DateOfBirth": null,
                "Gender": "gt_Undefined",
                "Profession": null,
                "Title": "Mrs.",
                "CityOfBirth": null,
                "Active": "tYES",
                "FirstName": null,
                "MiddleName": null,
                "LastName": null,
                "EmailGroupCode": null,
                "BlockSendingMarketingContent": "tNO",
                "ContactEmployeeBlockSendingMarketingContents": []
            },
            {
                "CardCode": "C30000",
                "Name": "Megan Jubinville",
                "Position": "Sales Manager",
                "Address": "1618 James St, Fairport, 14450",
                "Phone1": "555-0141",
                "Phone2": null,
                "MobilePhone": "555-0171",
                "Fax": "555-0142",
                "E_Mail": "megan.jubinville@microchips.sap.com",
                "Pager": null,
                "Remarks1": null,
                "Remarks2": null,
                "Password": null,
                "InternalCode": 6,
                "PlaceOfBirth": null,
                "DateOfBirth": null,
                "Gender": "gt_Undefined",
                "Profession": null,
                "Title": "Mrs.",
                "CityOfBirth": null,
                "Active": "tYES",
                "FirstName": null,
                "MiddleName": null,
                "LastName": null,
                "EmailGroupCode": null,
                "BlockSendingMarketingContent": "tNO",
                "ContactEmployeeBlockSendingMarketingContents": []
            }
        ]
    },
    "DocEntry": 2,
    "DocNum": 2,
    "CardCode": "C30000",
    "ContactPersonCode": 5
}
0

Hi Ralph,

What you shared with me is inline of what I’m looking for.

I want to know if it possible for the query to have a wildcard that returns all the deliveries properties and for Business Partners, only return ContactEmployees?

Regards,

William

0

The post question is "How To Get Contact Info From ContactPersonCode" Which I explained above.

If you have another question, flag this one as answered and please open a new thread.

0
Bhupendra Jadhav Oct 12, 2017 at 02:36 PM
0

Hi William,

You can use Object.getbykey("parameter name") method of Service Layer to get the contact name when passing ContactPersonCode.

Regards

Bhupendra

Show 1 Share
10 |10000 characters needed characters left characters exceeded

Hi Bhupendra,

Are you implying for me to write to write a custom script to get the contact person name from ContactPersonCode? What I was looking for some existing method I can call from Service Layer is I pass in the int for ContactPersonCode and it returns me the contact.

Regards,

William

0