Check if globabls_get exists/is defined

(Grant) #1


I have a problem, I’m trying to use conditions (conditions screen or conditional keywords) to determine if a globals_get_ variable exists.

So say i have a url,

qwert has no value, but I need to use conditions to check if it’s there or not. I can’t use globals_get_qwert^empty: or something similar because it will always be empty whether the ?qwert is there or not. I’ve tried in ssjs and csjs and it still doesn’t work because globals_get_qwert will always output nothing whether its there or not.

Hopefully thats easy to understand. Is there a keyword im unaware of that does this or a way to do this?


(John gill) #2

You could get the whole querystring with %globals_server_query_string% and check that (but of course you’d need to be careful to distinguish between ?qwert and ?search=qwerty

(Grant) #3

Thats what I went with after I realised conditions wouldn’t work, I did it with csjs thought and searched through url params.

Was just curious if there was a way, it feels like there should be

(Hugh McMaster) #4

Couldn’t you use use %globals_get^array_key_exists:qwert%?

That keyword returns True (1) if the keyword exists and is not confused by qwerty or similar variables.

(Grant) #5

I did not know you could access get params like that, good to know!

Thank you, this worked great!

(Hugh McMaster) #6

No problem. That keyword works very well in situations where you need to check whether the variable exists as a non-null key-value pair or just a key/variable (like your situation).