on 07-21-2023 11:57 AM
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.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
It's working fine now. 🙂
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
User | Count |
---|---|
64 | |
8 | |
7 | |
6 | |
6 | |
6 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.