I've also tried:
$listConstraints where ConstraintKind = REQUIRED
$if [ConstraintValue = ‘Required’] Y
$endif
$if [ConstraintValue <> ‘Required’] N
$endif
Post
FollowType of Constraint Kind Required
What is the right to do an if comparison for constraint kind required? The following is my example:
$listConstraints where ConstraintKind = REQUIRED
$if [ConstraintValue = false] N
$endif
$if [ConstraintValue <> 0] Y
$endif
Please sign in to leave a comment.
3 comments
A couple of things on this one. First, make sure you're using constraints in their proper context - Constraints is only valid in the context of Fields, which in turn is only valid in the context of Dictionary. e.g.,
$repeatDictionary
...
$repeatFields
...
$repeatConstraints
...
$endrepeatConstraints
$endrepeatFields
$endrepeatDictionary
Secondly, $list will only repeat the information and keep the context on a single line. As such, the $if/$endif statements you've got are (theoretically, since I don't have the full report) in the context of the current Field, and so will never match up.
There's an added complication with the Required constraint - it's either "Required" or doesn't exist at all if the checkbox isn't ticked, which makes testing for a negative value impossible in the reporting engine. What you can do is is check for the existence of the required constraint using a $when clause to display "Y", and flip the value of a variable within that. Then after the clause, check (using $if) the value of the variable again, and display "N." Here's the full example of what I mean:
$repeatDictionarySortName
$Name
$repeatFields
Field $Name
$set $$IsRequired No
$whenConstraints where ConstraintKind = REQUIRED
Y
$set $$IsRequired Yes
$endwhenConstraints
$if [$$IsRequired = No] N
$endif
$endrepeatFields
$endrepeatDictionary
Ok, I think I understand. It worked on my report. The CRs are a little tricky. :)