Closed (fixed)
Project:
Rules
Version:
6.x-1.1
Component:
Rules Core
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
5 Jan 2010 at 22:41 UTC
Updated:
11 Dec 2012 at 17:24 UTC
Jump to comment: Most recent
Comments
Comment #1
mitchell commentedFor empty, use the text comparison condition with your user reference field and a blank comparison pattern. For not empty, do the same but also check the "negate" option.
Comment #2
obrienmd commentedGood call. I ended up just using some simple PHP.
Comment #3
colemanw commentedCould you please share your PHP snippet?
The solution in #1 doesn't work, because both fields in the text comparison condition form are required (cannot be left blank).
Comment #4
obrienmd commentedIn my case it was:
return $node->field_proad[0]['uid'] == NULL;
This returns TRUE and allows the rule if the "proad" user reference fields "uid" parameter is empty. For non-empty requirement, just change == to !=, or negate this condition in your rule setup.
Comment #5
obrienmd commentedLet me know if this makes sense... if not, give me some more details and I'll do what I can!
Comment #6
colemanw commentedThanks, that is useful information. I ended up using the "field has value" condition, with this code as the value:
return array( 0 => array('value' => NULL));
I'm not sure which solution is more 'efficient' but it's good to know they both work.
Comment #7
obrienmd commentedNot sure about proper workflow mgmt for support requests like this, but setting status to "closed" for now.
Comment #8
Lucience commentedThank you very much, obrienmd!!!!
After hours of research, your code in post #4 solved my problem.
I just don't understand, why I get an error message, when i close with an "endif".
Cheers
Lucience
Comment #9
sagar ramgade commentedHi Lucience,
You are getting error when closing if statement with endif as you are using curly braces to open and close the if statement. If you want to use endif then if statement should open with colons ":" like this :
Hope this clear your doubt.
Regards
Sagar
Comment #10
open social commentedyou can use
print null;in the second field in the rules interface, this will print nothing. While the requirement is forfilled.Comment #11
leisurman commentedInstead of NULL, how can you rewrite this statement to return true if the field had data?
Comment #12
open social commentedComment #13
leisurman commentedThank you!
Comment #14
elamanHad same problem, but with random type fields. Came back here to share solution:
Comment #15
cmsproducer commentedWe discussed this issue in a PHP community especially to determine a way that can give a true response in situations where the field might be empty (in human terms), but there is some markup in it ( ,
Comment #16
amaisano commentedThe first proposed solution will work (doing it using Textual Comparison) if you check "Evaluate as RegEx" and enter ^$ as the pattern, which matches an empty string.