1

Currently using the AMPscript below to set some variables for some IF and ELSEIF function for dynamic content. We need to pull these data fields into the data extension used to send the campaigns each time. Is there a way to set these variables from records in another data extension or contact data?

Editing to show what the full script is doing:

%%[ Var @Level1RewardsAvailable__c Set @LV1 = [Level1RewardsAvailable__c] ]%% 
%%[ Var @Level2RewardsAvailable__c Set @LV2 = [Level2RewardsAvailable__c] ]%% 
%%[ Var @Level3RewardsAvailable__c Set @LV3 = [Level3RewardsAvailable__c] ]%% 

Then

%%[ Var @Level1RewardsAvailable__c Set @LV1 = [Level1RewardsAvailable__c] ]%% 
%%[ Var @KLevel2RewardsAvailable__c Set @LV2 = [Level2RewardsAvailable__c] ]%% 
%%[ Var @Level3RewardsAvailable__c Set @LV3 = [Level3RewardsAvailable__c] ]%% 


%%[IF @LV1 == "0" AND @LV2 == "0" AND @LV3 == "0" THEN]%% %%=ContentBlockByName("Content Builder\Iris Campaigns\Dynamic Content Modules\Rewards Modules\1_Rewards_LHS_Getscanning")=%% 

%%[ELSEIF @LV1 != "0" AND @LV2 == "0" AND @LV3 == "0" THEN]%% %%=ContentBlockByName("Content Builder\Iris Campaigns\Dynamic Content Modules\Rewards Modules\2_Rewards_LHS_freeside")=%% 

%%[ELSEIF @LV1 != "0" AND @LV2 != "0" AND @LV3 == "0" THEN]%% %%=ContentBlockByName("Content Builder\Iris Campaigns\Dynamic Content Modules\Rewards Modules\3_Rewards_LHS_freesnack")=%%

%%[ELSEIF @LV1 == "0" AND @LV2 != "0" AND @LV3 == "0" THEN]%% %%=ContentBlockByName("Content Builder\Iris Campaigns\Dynamic Content Modules\Rewards Modules\3_Rewards_LHS_freesnack")=%%

%%[IF @LV1 != "0" AND @LV2 != "0" AND @LV3 != "0" THEN]%% %%=ContentBlockByName("Content Builder\Iris Campaigns\Dynamic Content Modules\Rewards Modules\4_Rewards_LHS_5off")=%%

%%[ELSEIF @LV1 == "0" AND @LV2 != "0" AND @LV3 != "0" THEN]%% %%=ContentBlockByName("Content Builder\Iris Campaigns\Dynamic Content Modules\Rewards Modules\4_Rewards_LHS_5off")=%%

%%[ELSEIF @LV1 != "0" AND @LV2 == "0" AND @LV3 != "0" THEN]%% %%=ContentBlockByName("Content Builder\Iris Campaigns\Dynamic Content Modules\Rewards Modules\4_Rewards_LHS_5off")=%%

%%[ELSEIF @LV1 == "0" AND @LV2 == "0" AND @LV3 != "0" THEN]%% %%=ContentBlockByName("Content Builder\Iris Campaigns\Dynamic Content Modules\Rewards Modules\4_Rewards_LHS_5off")=%%%%[ENDIF]%%


%%[ Var @KFCP_Level1RewardsAvailable__c Set @LV1 = [KFCP_Level1RewardsAvailable__c] ]%% 
%%[ Var @KFCP_Level2RewardsAvailable__c Set @LV2 = [KFCP_Level2RewardsAvailable__c] ]%% 
%%[ Var @KFCP_Level3RewardsAvailable__c Set @LV3 = [KFCP_Level3RewardsAvailable__c] ]%% 

%%[IF @LV1 != "0" AND @LV2 != "0" AND @LV3 != "0" THEN]%% %%=ContentBlockByName("Content Builder\Iris Campaigns\Dynamic Content Modules\Rewards Modules\4_Rewards_LHS_5off")=%%

%%[ELSEIF @LV1 == "0" AND @LV2 != "0" AND @LV3 != "0" THEN]%% %%=ContentBlockByName("Content Builder\Iris Campaigns\Dynamic Content Modules\Rewards Modules\4_Rewards_LHS_5off")=%%

%%[ELSEIF @LV1 != "0" AND @LV2 == "0" AND @LV3 != "0" THEN]%% %%=ContentBlockByName("Content Builder\Iris Campaigns\Dynamic Content Modules\Rewards Modules\4_Rewards_LHS_5off")=%%

%%[ELSEIF @LV1 == "0" AND @LV2 == "0" AND @LV3 != "0" THEN]%% %%=ContentBlockByName("Content Builder\Iris Campaigns\Dynamic Content Modules\Rewards Modules\4_Rewards_LHS_5off")=%%

%%[ELSEIF @LV1 != "0" AND @LV2 != "0" AND @LV3 == "0" THEN]%% %%=ContentBlockByName("Content Builder\Iris Campaigns\Dynamic Content Modules\Rewards Modules\3_Rewards_LHS_freesnack")=%%

%%[ELSEIF @LV1 == "0" AND @LV2 != "0" AND @LV3 == "0" THEN]%% %%=ContentBlockByName("Content Builder\Iris Campaigns\Dynamic Content Modules\Rewards Modules\3_Rewards_LHS_freesnack")=%%

%%[ELSEIF @LV1 != "0" AND @LV2 == "0" AND @LV3 == "0" THEN]%% %%=ContentBlockByName("Content Builder\Iris Campaigns\Dynamic Content Modules\Rewards Modules\2_Rewards_LHS_freeside")=%%

%%[ELSEIF @LV1 == "0" AND @LV2 == "0" AND @LV3 == "0" THEN]%% %%=ContentBlockByName("Content Builder\Iris Campaigns\Dynamic Content Modules\Rewards Modules\1_Rewards_LHS_Getscanning")=%% %%[ENDIF]%%
1

If you are using this data to populate the necessary values in the email at send time, you should use SQL queries to generate your audience and desired fields before you send. That way all of your necessary data is already within the sendable DE and ready to go.

If you are unable to pre-generate your audience with queries before the send, then you need to look into using something like the LookupRows ampscript function in order to do a lookup in an external data extension for additional data at send time.

1
  • Being able to do this would mean not having to pull these records over all the time when building data extensions, it would also mean fewer automations to keep the data refreshing. This lookup works great if I wanted to display a single field %%[set @contactId =[ContactId]]%% %%=Lookup('Contact_Strategy_Master','KFC_ActualLoyalty__pc','ContactId',@contactId)=%% But what if I wanted to then surface dynamic content with an if function afterwards? – Ben Owen Jun 27 '19 at 8:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.