Skip to Content
0

How do create a new Contact (Business Patner) in SAP ByDesign?

Feb 11 at 07:13 AM

142

avatar image

Hi Experts,

I have a business scenario to create new contacts from Custom Screen. I have tried a piece of ABSL code from custom Business object's Before save event. But I am getting an error "Last Name Missing".

Is there any specific code to create a contact?

//Create a new contact
var createContact : elementsof BusinessPartner;
createContact.CategoryCode = "1";
var resultContact = BusinessPartner.Create(createContact);
var currentCommon : elementsof BusinessPartner.Common;
currentCommon.Person.Name.GivenName = "SDK";
currentCommon.Person.Name.FamilyName = "SDK";
resultContact.CurrentCommon.Create(currentCommon);
10 |10000 characters needed characters left characters exceeded

Is this somehow also related to SAP Contact Center, since it is tagged with it?

Best regards,

Roman

0
* Please Login or Register to Answer, Follow or Comment.

2 Answers

Benny Huang Feb 12 at 02:43 AM
1

Hi Sankaran,

I don't know the reason, but we can use the script, as:

//Create a new contact
var createContact : elementsof BusinessPartner;
createContact.CategoryCode = "1";
var resultContact = BusinessPartner.Create(createContact);

var currentCommon = resultContact.CurrentCommon.Create();
if (currentCommon.IsSet())
{
   currentCommon.Person.Name.GivenName = "SDK22";
   currentCommon.Person.Name.FamilyName = "SDK22";
}

if (resultContact.Common.GetFirst().IsSet())
{
   foreach(var ins_com in resultContact.Common)
   {
     ins_com.Person.Name.GivenName = "SDK22";
     ins_com.Person.Name.FamilyName = "SDK22";
   }
}

resultContact.Activate();

Best Regards,

Benny Huang

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

I have pasted the same code in Before Save event. But it didnt create any new contact.

0
Sujata Sawant May 25 at 05:18 AM
0

Hi Sankaran,

You can use below code to create contact from ABSL:

var contact : elementsof BusinessPartner;
contact.CategoryCode = "1";
var reslt = BusinessPartner.Create(contact);
if(reslt.IsSet())
{
if(reslt.CurrentBusinessCharacters.IsSet())
{
reslt.CurrentBusinessCharacters.ContactPersonIndicator = true;
}

if(reslt.CurrentCommon.IsSet())
{
reslt.CurrentCommon.Person.Name.FamilyName = "SDK Contact";
}
} 

Regards,

Sujata

Share
10 |10000 characters needed characters left characters exceeded