cancel
Showing results for 
Search instead for 
Did you mean: 

C4C: How to create Marketing Attribute within PDI

siwei_yang
Participant

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

Accepted Solutions (1)

Accepted Solutions (1)

philipphahn
Discoverer
0 Kudos

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.

mandeep_shrestha1
Participant
0 Kudos

Hi philipphahn ,

How can I use the above code to create marketing assignment for a contact person? Please suggest a code snippet to achieve the same.

philipphahn
Discoverer
0 Kudos

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)

Answers (1)

Answers (1)

siwei_yang
Participant
0 Kudos
mandeep_shrestha1
Participant
0 Kudos

Hi siwei.yang, Can you please guide me as well on how you achieved. We are trying to achieve a requirement where marketing attributes can be added to Contacts?

siwei_yang
Participant
0 Kudos

Hi Rohit,

Now I 'm using the solution of Philipp , it is better than mine.

mandeep_shrestha1
Participant
0 Kudos

Thanks. I am also using his solution to achieve my requirement.