0

I am using this function:

%%=Lookup("ENT.SBQQ__QuoteLine__c_Salesforce","SBQQ__ProductName__c","sbqq__quote__c", "a0n5E000002KZHQQA4", "SBQQ__Required", @required)=%%

which works all the times (it returns the proper value) except when @required is null (it should return a string in such case as well).

I tried with @required = '' or @required = null but with no luck.

How can I solve it?

My goal is to get SBQQ__ProductName__c where sbqq__quote__c is a0n5E000002KZHQQA4 AND where SBQQ__Required is null.

thank you

6
  • What field type is SBQQ__Required? Commented Apr 14, 2020 at 13:41
  • SBQQ__Required is a text
    – eeadev
    Commented Apr 14, 2020 at 13:52
  • not even = "null" is working
    – eeadev
    Commented Apr 14, 2020 at 13:52
  • 1
    @eeadev Did you tried empty function %%=Empty(@required )=%% ? I believe this should work.
    – Naveen VM
    Commented Apr 14, 2020 at 14:13
  • Yes @eeadev is right, empty will return true if required = "" Commented Apr 14, 2020 at 14:50

1 Answer 1

0

@required attribute needs have a value. You would need to handle the logic if its empty. So, if the @required is empty then set a different value. @required value should be in the lookup data extension.

See the below code:

%%[
Set @required = AttributeValue("SBQQ__Required") 
If Empty(@required) THEN
Set @required = "NULL"
set @result = Lookup("ENT.SBQQ__QuoteLine__c_Salesforce","SBQQ__ProductName__c","sbqq__quote__c", "a0n5E000002KZHQQA4", "SBQQ__Required", @required)
Else
set @result = Lookup("ENT.SBQQ__QuoteLine__c_Salesforce","SBQQ__ProductName__c","sbqq__quote__c", "a0n5E000002KZHQQA4", "SBQQ__Required",@required) 
ENDIF
]%%
SBQQ__ProductName__c - %%=v(@result)=%%

Let me know if you need anything.

3
  • Thanks for your time @razor, unfortunately it does not work. if u set required to "NULL", in my opinion ampscript set the value to the string "NULL" and when it search doing a lookup it returns no value because there is no such entry having the "NULL"
    – eeadev
    Commented Apr 15, 2020 at 7:45
  • @eeadev yes that's correct. You need a value 'NULL' in the look up data extension instead of blank. Then the value will populate. In short, you need to have a value for the field to look up. If you don't have a value then it wont return anything.
    – Naveen VM
    Commented Apr 15, 2020 at 7:57
  • I edited my initial message to make it clearer
    – eeadev
    Commented Apr 16, 2020 at 5:15

You must log in to answer this question.

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