1

I want to create a email which has a link depending on a certain value.

In the data extension candidate_discipline__c_Salesforce, the primary key is candidate__c and the column where I want to look in is Name.

This data extension is a related list in Salesforce.

So depending on which discipline a candidate has i want to show a different URL.

For instance: If he is a "Drilling engineer" then show URL in mail www.surveygizmo.com/drilling-engineer. If he is a Rigger then show URL in mail www.surveygizmo.com/rigger.

I'm quite new to AMPscript, this is what i tried doing but it's not working:

%%[
    var @discipline
    set @discipline = Lookup("Candidate_Discipline__c_Salesforce", "Candidate__c", "Name", "Surveyor")
]%%


%%[IF @discipline == "Surveyor" THEN]%% <a href="https://www.surveygizmo.com/surveyor">Surveyor</a>

%%[ELSEIF @discipline == "Rigger" THEN]%% <a href="https://www.surveygizmo.com/rigger">Rigger</a>

%%[ELSEIF @discipline == "Trainer" THEN]%% <a href="https://www.surveygizmo.com/trainer">Trainer</a>

%%[ELSEIF @discipline == "Outlander" THEN]%% <a href="https://www.surveygizmo.com/engineer">Engineer</a>

%%[ ENDIF ]%%

Can someone help me with this code?

Please find below a sample of de Data Extension:

Name                    Candidate__c                        BusinessLine__c                     Job_Title__c
Chief Engineer      003200000142TJAAA2         a1Sw00000033FFYEA2         a0cw0000008yEaEAAU
Able Seaman         003w0000018fYM3AAM        a1Sw00000014jMbEAI         a0cw0000006qk50AAA
Skipper                 003w000001LBxFMAA1        a1Sw00000014jMbEAI         a0cw0000006YD7SAAW



Desired output: I am going to run a journey for all Chief Engineers, Able Seamans and Skippers. Those will receive a email with a link which is specific for THAT discipline. Skippers will get a link to a self-assessment form for Skippers and Chief Engineers will receive a link to a self-assessment form for Chief Engineers.

The journey will be on the Contact_Salesforce Data Extension. The Candidate_Discipline__c_Salesforce will be AMPscripted in the email as i tried to do.

1
  • What in Contact_Salesforce indicates Chief Engineer, Able Seaman, etc? Is it Candidate__c? Jan 26, 2018 at 12:50

1 Answer 1

3

Here's how I would approach it:

%%[

var @ContactID, @Candidate__c, @discipline, @name, @surveyCode

/* id for contact from send context */
set @ContactID = AttributeValue("ID") 

/* retrieve column value from Contact for discipline name lookup */
set @Candidate__c = Lookup("Contact_Salesforce", "Candidate__c", "ID", @ContactID)

/* retrieve discipline name from Candidate_Discipline__c */
set @discipline = Lookup("Candidate_Discipline__c_Salesforce", "Name", "Candidate__c", @Candidate__c)

/* set survey code based on discipline */
if @discipline == "Surveyor" then
  set @surveyCode = "surveyor123" 
elseif @discipline = "Rigger" then
  set @surveyCode = "rigger284" 
elseif @discipline = "Trainer" then
  set @surveyCode = "trainer381" 
elseif @discipline = "Outlander" then
  set @surveyCode = "outlander582" 
else
  raiserror("survey code not found")
endif


]%%
<a href='%%=redirectto(concat(https://www.surveygizmo.com/",lowercase(@surveyCode)))=%%'>Complete Survey</a>
6
  • Hi Adam, thanks for your help. The link behind surveygizo.com will be generated by surveygizmo. So for surveyor it could be surveygizmo.com/surveyor4342. So i want to put all links in the AMPscript manually. How could i do that? + I want to do a lookup to all disciplines not only surveyor, so this shouldn't be static value.
    – eazy4me
    Jan 25, 2018 at 13:16
  • Updated my answer above Jan 25, 2018 at 13:51
  • Adam you're the king. Only thing is our data model is a little bit weird. So "Name" is not a name of a person but the name of a discipline (for instance Surveyor). "Candidate_Discipline__c_Salesforce" is a related list, so if two records in the related list are "Surveyor" AND "Rigger" then i want to show both links.
    – eazy4me
    Jan 25, 2018 at 14:49
  • If you could update your question with a sampling of data from your Candidate_Discipline__c_Salesforce DE that'd be helpful. Also include the desired output. Jan 25, 2018 at 14:54
  • Hi Adam, sorry for the late reply, i was off work. Now i am on again. I updated my question above with a DE sample + desired output. Hope you can help
    – eazy4me
    Jan 26, 2018 at 8:25

You must log in to answer this question.

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