Validation AND/OR

Hi,

We have a shared field - schools - which is a required field on all content types. I’m trying to modify this so that’s it’s required for all content types except one.

So in my validation, I like to have

Conditional: sys_contenttypeid=340 OR
Conditional: schools IS NOT NULL AND

However, I can’t get that OR to appear in the rule. When I highlight it, the rule appears in the Rule Details with the OR but in the rule itself it’s always AND.

Am I going about this the right way?

Nick.

Hi Nick

This is bug. To get around it you have to edit the xml of the content type directly in the ObjectStore folder.

Cheers
James

So even though the validation is on the shared field, I need to edit the XML of the content-type itself?

This bit … ?


- <FieldRules>
- <PSXFieldValidationRules maxErrorsToStop="10" name="isValidSysTitle">
- <PSXRule boolean="and">
- <PSXConditional id="1">
- <variable>
- <PSXSingleHtmlParameter id="0">
  <name>query</name> 
  </PSXSingleHtmlParameter>
  </variable>
  <operator>IS NOT NULL</operator> 
- <value>
- <PSXTextLiteral id="0">
  <text /> 
  </PSXTextLiteral>
  </value>
  <boolean>AND</boolean> 
  </PSXConditional>
  </PSXRule>
  <PSXApplyWhen ifFieldEmpty="yes" /> 
- <ErrorMessage>
  <PSXDisplayText>This field cannot be empty</PSXDisplayText> 
  </ErrorMessage>
  </PSXFieldValidationRules>
  </FieldRules>

Hi Nick

Sorry, if it;s on the shared field then you need to update the shared definition xml in the following location

Rhythmyx\rxconfig\Server\ContentEditors\shared

Cheers
James

James,
I made the modifications you suggested by adding


<PSXRule boolean="or">
  <PSXConditional id="0"> 
    <variable>
      <PSXContentItemData id="0">
        <name>sys_contenttypeid</name>
      </PSXContentItemData>
    </variable>
    <operator>=</operator>
    <value>
      <PSXTextLiteral id="0">
        <text>340</text>
      </PSXTextLiteral>
    </value>
    <boolean>OR</boolean>
  </PSXConditional>
</PSXRule>

and the conditional now shows as OR in workbench but the validation still requires that I enter a value. I have restarted Rhythmyx.

Is there anything else I need to do to make this validation work?

Thanks,
Nick.

Nick,

Your problem seems to be that you used <PSXContentItemData> instead of <PSXSingleHtmlParameter> as James did in his example.

Content Item data refers to fields that are stored in the back end tables, and sys_contenttypeid is not one of those fields. It is, however, an HTML parameter that is passed in from the content editor form, so you can test for it that way.

Dave

Thanks, Dave, that works fine.
And apologies to James for not reading his post correctly.

Was this bug ever fixed? We are trying to add rules for the sys_title which is:
Extension:UniqueInFolder AND
Condition:ContentType != folder OR
RegEx: No special characters AND

However, there is no way to set OR. Currently we are whipping up an extension, but it seems silly to create an extension for something that should already exist. I am also assuming in the above example that the rules follow normal short-circuiting rules.