on 02-04-2022 5:23 PM
Dear Expert,
our requirement ist to assign some marketing attribute to a given customer within PDI, if e.g. a quote was sent. But I 'm running across a big problem. The association MarketingAttributes of BO Customer is read only. The association has type BusinessAttributeAssignment.
So if the customer beforehand has no marketing attribute assigment at all, then we will not be able to assign any marketing attribute to this customer within PDI.
It means , if the Customer.MarketingAttributes is already initial, then we can not use e.g. Customer.MarketingAttributes.Item.Create(item) to create new marketing attribute, and neither can I create a "empty" assigment and set it to this , because Customer.MarketingAttributes is read only .
Does anybody have good idea?
Best wishes
Peter
You can still do it within the PDI. I had a similar problem and found a solution.
In case there is no assignment existing, you need to create one via BusinessAttributeAssignment using the UUID of the Business Partner:
var CustomerMarketingAttributes = Customer.MarketingAttributes;<br>
if (!CustomerMarketingAttributes.IsSet())
{
var newBusinessAssignment : elementsof BusinessAttributeAssignment;
newBusinessAssignment.AssignedObjectUUID = this.CustomerUUID.content;
// 147 = Business Partner
newBusinessAssignment.ObjectTypeCode.content = "147"
CustomerMarketingAttributes = BusinessAttributeAssignment.Create(newBusinessAssignment);
}
Now you can add your MarketingAttributes to CustomerMarketingAttributes using CustomerMarketingAttributes.Item.Create(item) without a problem.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi mandeep.shrestha
The code shouldn't change much as Customer is just a special form of BusinessPartner and a contact person is a BusinessPartner. I assume you are already inside the contact person, hence I use "this" in the code snippet, otherwise you should retrieve the contact person in a variable and use the variable instead. I hope this helps.
// use Retrieve with the contact persons UUID if needed
// var contactPerson = BusinessPartner.Retrieve(contactPersonUUID)
var contactPersonUUID = this.UUID;
var ContactMarketingAttributes = this.MarketingAttributes;
if (!ContactMarketingAttributes.IsSet())
{
var newBusinessAssignment : elementsof BusinessAttributeAssignment;
newBusinessAssignment.AssignedObjectUUID = contactPersonUUID.content;
// 147 = Business Partner
newBusinessAssignment.ObjectTypeCode.content = "147"
ContactMarketingAttributes = BusinessAttributeAssignment.Create(newBusinessAssignment);
}
// here "newAttribute" is the object holding elements of the marketing attributes
// here "attribute" is an item I copy form another BusinessAttributeAssignment
var newAttribute : elementsof BusinessAttributeAssignment.Item;
newAttribute.AttributeValue = attribute.AttributeValue;
newAttribute.BusinessAttributeID = attribute.BusinessAttributeID;
newAttribute.BusinessAttributeSetKey = attribute.BusinessAttributeSetKey;
ContactMarketingAttributes.Item.Create(newAttribute)
I resolved this issue by using sap odata service .
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
2 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.