1

I have the following AMPscript code which should lookup some data based on the subscriber key:

%%[

var @rows, @row, @rowCount
var @lookupValue
set @lookupValue = AttributeValue("uuid") 
set @lookupValue = "_subscriberkey" 

set @rows = LookupRows("DE_Name","uuid", _Subscriberkey)
set @rowCount = rowcount(@rows)

if @rowCount > 0 then

  var @registrationDate, @purchaseDate
  set @row = row(@rows,1)
  set @registrationDate = field(@row,"registrationDate")
  set @purchaseDate = field(@row,"purchaseDate")

]%%

registrationDate is %%=v(@registrationDate)=%%, purchaseDate is %%=v(@purchaseDate)=%%

%%[ else ]%%

No rows found

%%[ endif ]%%

Normally I would expect the output from the registrationDate and purchaseDate, but it generates nothing but also doesn't give an error.

The following fields are included in the Data Extension which I'm retrieving the data from and sending to:

  • CTN / Primary Key / Text
  • uuid / Primary Key / Text
  • registrationDate / Date
  • purchaseDate / Date
  • imageUrl / Text
  • productUrl / Text
  • sourceID / Text

For testing I only tried to fetch the dates with the AMPscript. The send relation is uuid with Subscriber Key. Some rows from the DE aren't in the all subscribers yet, but most of them are.

What am I doing wrong?

9
  • Is the code complete? I don't see lookupvalue used in the lookup and CTN doesn't seem to be set in the script Apr 14, 2019 at 16:36
  • 1
    In addition you need to change how you set the lookupvalue. With the current syntax in "" you are setting a fixed string. If you want to use the system key it has to look like this: = _Subscriberkey. In general you can leave out the second lookupvalue set statement because it is already set by the Attributevalue statement. There you also have to add the underscore at the beginning of Subscriberkey Apr 14, 2019 at 16:41
  • @StephandePaly thanks for your reply. I've used the _subscriberkey as a lookupvalue, but now I'm receiving the following error: The specified attribute or custom object field name was not found for this client. I've pasted the edited code above. Apr 14, 2019 at 17:20
  • 1
    With your current LookupRows statement you don't need any of the lookupvalue statements because you aren't using it. Can you confirm that uuid is a field name in the data extension you are making the lookup in? Apr 14, 2019 at 17:36
  • @StephandePaly, yes it is! It's one of the Primary Keys in de Data extension Apr 14, 2019 at 18:36

1 Answer 1

1

Assuming the uuid contains the the value for retrieving the row:

%%[

var @rows, @row, @rowCount, @sk

set @sk = AttributeValue("uuid") 

set @rows = LookupRows("DE_Name","uuid", @sk)
set @rowCount = rowcount(@rows)

if @rowCount > 0 then

  var @registrationDate, @purchaseDate
  set @row = row(@rows,1)
  set @registrationDate = field(@row,"registrationDate")
  set @purchaseDate = field(@row,"purchaseDate")

]%%

registrationDate is %%=v(@registrationDate)=%%, purchaseDate is %%=v(@purchaseDate)=%%

%%[ else ]%%

No rows found

%%[ endif ]%%
4
  • Thanks Adam, this removed the errors I got, but the Dates are not being generated. I've double checked most of the rows and they are present in the Data Extension. Can you think of any reason why this is happening? Apr 14, 2019 at 18:47
  • 1
    Have the (potential) subscribers been sent to before? If not, they might not exist in AllSubcribers and don't have a subscriber key, yet. If this might be the case use the uuid field from your send data extension (I assume from your code, that this field is present there and represents the subscriber key. It will look like this: LookupRows("DE_Name","uuid", uuid) Apr 14, 2019 at 19:57
  • Alternatively you can use uuid in the Attributevalue statement to stay with Adams code: AttributeValue("uuid") Apr 14, 2019 at 19:59
  • @StephandePaly, thanks for your help. The output seems to be fixed as some other AMPscript was getting in the way of my output. Thanks for your help! Apr 16, 2019 at 8:22

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.