Can I pull in a specific contentblockbyID using the lookup function in ampscript based on the conditional IF/ELSE statement?
Asked
Active
Viewed 1,081 times
1 Answers
1
Yes. You can use a dynamic variable within your Lookup statement. Here is an example. I have a table with my group names and their respective content block ids. I can use an if statement to set the group name and then use that variable in my Lookup to return the value I needed.
In your email:
%%[
if @p_type=1 then
set @CB_type = "A"
else then
set @CB_type = "B"
endif
set @CB_ID = Lookup("TABLENAME","CONTENTBLOCK_IDS","NAME",@CB_type)
]%%
%%=CONTENTBLOCKBYID(@CB_ID)=%%
DATA EXTENSION NAME: "TABLE NAME"
COLUMNS - NAME / CONTENTBLOCK_IDS
Row 1 - A / 123
Row 2 - B / 124
Here are some great resources:

Nathalie A Starr
- 41
- 5