cancel
Showing results for 
Search instead for 
Did you mean: 

Not able to pass account owner to contact Owner in SAP SDK C4C

madhurirawat19
Explorer
0 Kudos

Dear Team,

As per requirement , I need to pass account owner to Contact owner whenever account owner get changed. Please find below code. It's passing account owner uuid to contact owner uuid but it's not changing contact owner as the account owner on UI.

var accowneruuid = this.ToRoot.EmployeeResponsibleSales.EmployeeUUID;

var Contactowner = this.ToRoot.CurrentDefaultHasContactPerson.RelationshipBusinessPartnerUUID;

Contactowner.content =accowneruuid.content;// but it's passing uuid , not changing contact owner as per the account owner uuid

Thanks and Regards,

MD.

Accepted Solutions (1)

Accepted Solutions (1)

0 Kudos

Hi Madhuri

Try the below code in Customer Object After-Modify or Before-Save.

import ABSL;
import AP.FO.BusinessPartner.Global;
var root = this;
var accountEmpUUID;
if (root.IsSet())
{
if (root.CurrentEmployeeResponsible.Count() > 0)
{
if (root.CurrentEmployeeResponsible.GetFirst().IsSet())
{
if (!root.CurrentEmployeeResponsible.GetFirst().EmployeeUUID.IsInitial())
{
accountEmpUUID = root.CurrentEmployeeResponsible.GetFirst().EmployeeUUID.content;
}
}
}
}
if (!accountEmpUUID.IsInitial() && root.IsSet())
{
var contactList = root.HasContactPerson;
if (contactList.Count() > 0)
{
foreach (var contact in contactList)
{
if (contact.RelationshipBusinessPartner.IsSet())
{
if (contact.RelationshipBusinessPartner.HasContactTeamMember.Count() > 0)
{
var contactTeam = contact.RelationshipBusinessPartner.HasContactTeamMember.Where(n => n.RoleCode.content == "BUR027-2");//Has Contact Team Member
if (contactTeam.Count() > 0)
{
if (contactTeam.GetFirst().IsSet())
{
contactTeam.GetFirst().RelationshipBusinessPartnerUUID.content = accountEmpUUID;
}
}
else
{
var createContactTeam : elementsof BusinessPartner.Relationship;
createContactTeam.RoleCode.content = "BUR027-2";
createContactTeam.RelationshipBusinessPartnerUUID.content = accountEmpUUID;
contact.RelationshipBusinessPartner.HasContactTeamMember.Create(createContactTeam);
}
}
else
{
var createContactTeam : elementsof BusinessPartner.Relationship;
createContactTeam.RoleCode.content = "BUR027-2";
createContactTeam.RelationshipBusinessPartnerUUID.content = accountEmpUUID;
contact.RelationshipBusinessPartner.HasContactTeamMember.Create(createContactTeam);
}
}
}
}
}
Br,Sooriya
madhurirawat19
Explorer

It's working fine now. 🙂

Answers (2)

Answers (2)

0 Kudos

Hi Madhuri,

Can you try the below and see if its updating the Contact Owner same as that of Account Owner.

var accowneruuid = this.ToRoot.EmployeeResponsibleSales.EmployeeUUID;
this.ToRoot.CurrentDefaultHasContactPerson.RelationshipBusinessPartnerUUID = accowneruuid.content;

Br,

Sooriya

madhurirawat19
Explorer
0 Kudos

Hi Sooriya,

I have tried this code. what is happening here.

this.ToRoot.CurrentDefaultHasContactPerson.RelationshipBusinessPartnerUUID = accountuuid; // it's changing the contact person name instead of contact owner name

But Owner of contact is part of contact team of contact, which is readable in business partner BO. But I am writing my code in customer bo.

So I need to do read contact team in account bo through association. but I am not able to do association between business partner bo and customer bo.

Thanks and Regards,

MD.

MJVEERHUIS
Active Participant
0 Kudos

Hi,

Did you try Root.AccountOwnerID and Root.ContactOwnerUUID for the contact owner? This field appears when trying to set up a rule for achieving this (which unfortunately does not work).

MJ

madhurirawat19
Explorer
0 Kudos

I have done below code. Can you please correct me where I am doing mistake as it's passing UUID but not changing contact owner.

var Contactowner = this.ToRoot.CurrentDefaultHasContactPerson.RelationshipBusinessPartnerUUID;

var accowneruuid = this.ToRoot.EmployeeResponsibleSales.EmployeeUUID;

Contactowner.content =accowneruuid.content;

Thanks and Regards,

MD.