I am trying to find out if the url variable exists, and if not, make sure it is not empty.
This does not work:
<cfif IsDefined('URL.affiliateId') and is not ""> // </cfif>
<cfif structKeyExists(url, 'affiliateID') and trim(url.affiliateID) neq "">...</cfif>
You can also simplify the logic by using <cfparam> so that the URL variable always exists. Then instead of having 2 conditions, you just need 1.
<cfparam name="URL.affiliateId" type="string" default="" /> <cfif trim( URL.affiliateId ) is not ""> do stuff here </cfif>
<cfif IsDefined('URL.affiliateId') and len(trim(URL.affiliateId))> value is defined and not empty </cfif>
...
<cfif IsDefined('URL.affiliateId') and len(trim(URL.affiliateId)) gt 0> value is defined and not empty </cfif>
<cfif IsDefined('URL.affiliateId') and URL.affiliateId neq ""> // </cfif>
:
<cfparam name="URL.affiliateId" type="string" default="" /> <cfif len(trim(URL.affiliateId))> ...do something with the affiliate... </cfif>
structKeyExists isDefined, . " " "len()".