0

I have an existing email built via content builder but have been asked to make this dynamic. I've been given the AMPScript I need to use, but I'm unsure as to how I embed this within a given block?

I tried opening the block and pasting the script below directly into the block above the code, but this doesn't seem to work? I've been told the code is correct, but I have no idea where it's supposed to be embedded?


%%[SET @showViewRecords = LookupRows('ShowViewsBySubscriber','ShowName', <ShowName>, 'SubscriberKey', <ContactId>)
   IF rowcount(@showViewRecords) > 0
   SET @showViews = Lookup('ShowViewsBySubscriber','ShowName', <ShowName>, 'SubscriberKey', <ContactId>)
  ELSE
    SET @showViews = 0
 ENDIF
]%%
<!--—Switch images based on Show View count ---->
%%[ IF @showViews > 0 ]%%
%%=ContentImagebyID("21001","DefaultImage")=%%
%%=ContentBlockByName("Content Builder\IMAGE1")=%%
%%[ ELSEIF ]%%
%%=ContentImagebyID("21002","DefaultImage")=%%
%%=ContentBlockByName("Content Builder\IMAGE2")=%%
%%[ ELSEIF ]%%
%%=ContentImagebyID("21002","DefaultImage")=%%
%%=ContentBlockByName("Content Builder\IMAGE3")=%%
%%[ ENDIF ]%%

This is the current error I receive:

The specified attribute or custom object field name was not found for this client. Function Call: LookupRows('ShowViewsBySubscriber','ShowName', <ShowName>, 'SubscriberKey', <ContactId>) Attribute or Field Name:

  • You need to add an opening %%[ before your SET @showViewRecords – Samuel Dare Oct 16 '17 at 15:59
  • Thanks , but I added that and still nothing? There is some commented code in there too, but doesn't seem to be causing a problem. When I try to preview on the data extension, I get this error: The specified attribute or custom object field name was not found for this client. Function Call: LookupRows('ShowViewsBySubscriber','ShowName', <ShowName>, 'SubscriberKey', <ContactId>) Attribute or Field Name: <ShowName> – token101 Oct 16 '17 at 16:04
  • Essentially I have just embedded this directly above the block I'm trying change, which doesn't seem correct but no other idea where to put it? – token101 Oct 16 '17 at 16:06
  • Try rendering the script on a email or landing page to see if it works. – Samuel Dare Oct 16 '17 at 16:07
  • So that's what I did. I added that directly into the email and got the above error? That would also suggest to me there is a syntax error with the field name, but ShowName exists, so not sure what that could be suggesting? thanks for your help BTW – token101 Oct 16 '17 at 16:12
0

It looks like you have too many parameters in your LookupRows function:

LookupRows('ShowViewsBySubscriber','ShowName', 'ShowName', 'SubscriberKey', 'ContactId')

That function only supports 3 parameters.

The LookUp for ShowViews also has too many parameters:

Lookup('ShowViewsBySubscriber','ShowName', 'ShowName', 'SubscriberKey', 'ContactId')

This function needs 4 parameters to work correctly.

You may need to nest some functions to get the result you are looking for.

| improve this answer | |
  • Thank you, I've passed this back to the developer and this is essentially what they said- that the syntax is completely wrong. Really appreciate the feedback! – token101 Oct 19 '17 at 16:13

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.