Skip to Content
avatar image
Former Member

How to get Account name by querying of Business Partner with contactID

Hi,

By querying with ContactID I get all address information from BussinessPartner. But Account Name can't be extracted from object model.

Is It possible to get Account Name from BusinessPartner by querying with ContactID?

Pls help me.

Thanks and Regards,

Swati

contact.png (12.2 kB)
Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Best Answer
    Aug 31, 2017 at 05:43 PM

    Hi Swati,

    You can refer following code:

    import ABSL;
    import AP.FO.BusinessPartner.Global;
    var q = BusinessPartner.QueryByIdentification;
    var p = q.CreateSelectionParams();
    p.Add( q.InternalID, "I", "EQ", "1042044"); // Contact ID for whcih account name to be identified
    var r = q.Execute(p);
    if (r.GetFirst().IsSet())
    {
    var n = r.GetFirst();
    	if (n.BusinessPartnerRelationship.GetFirst().IsSet())
    	{
    		var t = n.BusinessPartnerRelationship.GetFirst();
    		if ( t.IsSet())
    		{
    			var b = t.FirstBusinessPartner;
    			if ( b.IsSet())
    			{
    				var name = b.CurrentCommon.Organisation.Name.FirstLineName;
    				var sort = b.CurrentCommon.SortingFormattedName;
    			}
    		}
    	}
    }
    

    Thanks

    Saurabh

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi Saurabh,

      Thank you very much for helping me with a prompt and nice code.

      Furthermore, pls help me to get the values of Contact Permission, Title and Job Title by querying with ContactID.

      Thanks again

      Swati