Search code examples
if-statementcoldfusioncoldfusion-9

Check two arguments in ColdFusion?


I have two different arguments and if they are holding specific values I shouldn't execute the block of the code inside of my statement. Here is example:

<cfarguments name="myArg1" type="string" required="yes">
<cfarguments name="myArg2" type="string" required="yes">

<cfif myArg1 NEQ 'MMT' OR myArg2 NEQ 'newMMT'>
  Execute the code
</cfif>

Arguments that I have passed above are myArg1 = 'MMT' and myArg2 = 'newCCS'. My cfif was indicating to true and code inside of the cfif was executed. So if myArg1 is equal to 'MMT' or myArg2 equal to 'newMMT' code inside of the if should not be executed. If I put AND instead of OR in that case I would be looking when both arguments are equal to the required values and that's not what I want. If you hav eany idea how I can get this to work please let me know. Thank you.


Solution

  • You need to use an AND statement. Also, don't forget to scope your variables.

    <cfif arguments.myArg1 NEQ 'MMT' AND arguments.myArg2 NEQ 'newMMT'>