0

I am trying to populate custom field in Email template using amp-script

%%[
VAR @ContactType, @fname, @lname
Set @ContactType = "Contact Type"
Set @fname = "FirstName"
Set @lname = "LastName"
]%%

First Name:%%=v(@fname)=%% 
Last Name:%%=v(@lname)=%% 
Contact Type:%%=v(@ContactType)=%%

Here contact type is custom field in salesforce and this is already created in profile management in marketing cloud

Now i wanted to display this field in Email template

Can you help me how to achieve this

8
  • are the values in SF core or marketing cloud?
    – 0xsegfault
    Commented May 25, 2017 at 14:54
  • these values are in SF as well as Marketing cloud, In profile management i have created fields and mapped with SF fields
    – Josyula
    Commented May 25, 2017 at 14:57
  • if you have added those field in Profile management, then you should try like this %%attribute_name%%
    – SFMC_User
    Commented May 25, 2017 at 15:26
  • Hii @vikas, I believe this is personalization right?? Not AMPscript
    – Josyula
    Commented May 25, 2017 at 15:31
  • Yes! your purpose is to display these fields in Email Template, by that way you can fetch your field.
    – SFMC_User
    Commented May 25, 2017 at 15:38

1 Answer 1

0

You can try this code to fetch profile attribute without using Personalization:

%%[ 
SET @SubscriberKey= _subscriberkey 

SET @Subscriber = CreateObject("RetrieveRequest") 

SetObjectProperty(@Subscriber, "ObjectType", "Subscriber") 
AddObjectArrayItem(@Subscriber,"Properties","SubscriberKey") 
AddObjectArrayItem(@Subscriber,"Properties","EmailAddress") 
AddObjectArrayItem( @Subscriber, "Properties", "Status") 
AddObjectArrayItem(@Subscriber,"Properties","ID") 

SET @filterObj = CreateObject("SimpleFilterPart") 
SetObjectProperty(@filterObj, "Property", "SubscriberKey") 
SetObjectProperty(@filterObj, "SimpleOperator", "equals") 
AddObjectArrayItem(@filterObj, "Value",@SubscriberKey) 

SetObjectProperty(@Subscriber, "Filter", @filterObj) 

SET @sub_rowset= InvokeRetrieve(@Subscriber) 

IF ROWCOUNT(@sub_rowset) == 1 THEN 
SET @sub_row = ROW(@sub_rowset,1) 

/*To fetch Attribute */ 

SET @attributes = FIELD(@sub_row,"Attributes") 
SET @sub_rowAtt= Row(@attributes,1) 
SET @Profile_Attributename1= Field(@sub_rowAtt,"Profile_Attributename1") 
SET @Profile_Attributevalue1= Field(@sub_rowAtt,"Value") 
SET @sub_rowAtt= Row(@attributes,2) 
SET @Profile_Attributename2= Field(@sub_rowAtt,"Profile_Attributename2") 
SET @Profile_Attributevalue2= Field(@sub_rowAtt,"Value") 
SET @sub_rowAtt= Row(@attributes,3) 
SET @Profile_Attributename3= Field(@sub_rowAtt,"Profile_Attributename3") 
SET @Profile_Attributevalue3= Field(@sub_rowAtt,"Value") 
SET @sub_rowAtt= Row(@attributes,4) 
SET @Profile_Attributename4= Field(@sub_rowAtt,"Profile_Attributename4") 
SET @Profile_Attributevalue4= Field(@sub_rowAtt,"Value") 
.....
ENDIF 
]%% 

%%=v(Profile_Attributevalue1)=%% 
%%=v(Profile_Attributevalue2)=%% 
%%=v(Profile_Attributevalue3)=%% 
%%=v(Profile_Attributevalue4)=%%
......

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .