Highlighted

Is not Defined versus Is not populated

Silver Contributor
Silver Contributor

Hi -

when writing conditional logic on a Set Data Values extension, what is the difference between "is not defined" and "is not populated"?

 

I would like to set something like this...

set variable_A (js_page) to variable_B (UDO var)

when variable_A (js_page) is not set

AND variable_B (UDO var) is set

 

thanks, John

5 REPLIES 5
Highlighted

Is not Defined versus Is not populated

Tealium Employee

@john_gautreau

 

Is not defined means the variable is declared. Whether or not its value is empty is not of importance. An example of a defined variable is:

var variable_A;

 

Is not populated means that variable is declared AND that it has a value. An example of a populated variable is:

var variable_A="test";

 

In your case I would do:

set variable_A (js_page) to variable_B (UDO var)

when variable_A (js_page) is not defined

AND variable_B (UDO var) is defined

AND variable_B (UDO var) is populated

 

This will ensure variable_B exists with a valid value before updating variable_A.


Cheers,

-Dan

 

Is not Defined versus Is not populated

Silver Contributor
Silver Contributor

To give a more technical response to your question I would say,

Is Not Defined would be evaluated as,

(typeof d['your_variable_here'] == 'undefined')

and Is Not Populated would be evaludated as,

(typeof d['your_variable_here'] != 'undefined' && d['your_variable_here'] == '')

 

Highlighted

Is not Defined versus Is not populated

Silver Contributor
Silver Contributor
great - thank you
Highlighted

Is not Defined versus Is not populated

Silver Contributor
Silver Contributor
thank you
Highlighted

Is not Defined versus Is not populated

Community Manager
Community Manager

@john_gautreau @Yoosuf @dan_george

To add on to the other answers: the actual JavaScript code generated by each condition is documented here: Generated JavaScript Code for Load Rule/Extension Conditions

Remember to "Accept as Solution" when your question has been answered and to give kudos to helpful replies.