My current condition, incidentally, looks like this:
- Code: Select all
$table == "adult" || $table == "student"
It shows up just fine on the Adult and Student tables, but doesn't appear at all in, say, the relationship from Production to Student.
Action Condition: field exists?
9 posts
• Page 1 of 1
Action Condition: field exists?I've got an "email" action set up, which lists all the email addresses in the current set in a nice, tidy, comma-delimited list, ready to copy-and-paste for sending. However, I'm having trouble with the condition for it. I want it to show up if the current table has an "email" field. All I can figure out is checking $query['-table'], which works fine for normal lists, but fails if I have a relationship list. Is there a specific way to check if a field exists?
My current condition, incidentally, looks like this:
It shows up just fine on the Adult and Student tables, but doesn't appear at all in, say, the relationship from Production to Student.
Re: Action Condition: field exists?Your condition can actually call any php function. So you can define your own function to check this and refer to the function from your condition.
e.g. In one of your included files:
In your condition directive in the actions.ini file:
Re: Action Condition: field exists?Yes, I had realised that. This wasn't my actual issue. As I said, I can check $query['-table'] just fine. The problem is that, when you're viewing a relationship, $query['-table'] == the source table, and not the one you can actually see. So if I created the function:
The second result should really return a true, since it's the relationship we're actually concerned with.
Re: Action Condition: field exists?Perhaps your function could take the entire query array as a parameter instead of just the table name.
e.g.
Then this $query array will contain all of the necessary tidbits you need. E.g. $query['-table'] = the current table name $query['-relationship'] = The current relationship name $query['-action'] = The current action (e.g. list, find, view) You might have something like this:
Re: Action Condition: field exists?This seemed like a good idea, so I stole your function (with slight changes):
The code looks just fine. However, it only seems to work, like the previous code, when I'm on the table directly, and not through a relationship. Experimentally, I tacked this line in for debug:
And in viewing the source, I get this little message at the top: "The domainTable is equal to student " Note that there appears to be a space on the end of student, which (I assume) is why it doesn't load it properly. So, what's up with that? ![]()
Re: Action Condition: field exists?That is bizarre. I can't see any way there should be a space there. Can you retry with the output:
instead so that you can see definitively whether a space exists?
Re: Action Condition: field exists?Looks like the space isn't actually part of the variable, since I got this afterwards:
"The domainTable is equal to [student] " This still doesn't explain why that function isn't working, though. If it matters, I'm actually calling it like this:
Re: Action Condition: field exists?Hard for me to comment on where the problem is. Best if you can write a short minimal test case with expected result and actual result, and I can comment on how we might narrow it down.
Re: Action Condition: field exists?No need. I'd like to facepalm now, because I am an idiot. Y'know how there's categories for actions? Here was my previous email action:
It doesn't appear in related lists, naturally. Guess what happens when I add this to the end?
It shows up, the way it's supposed to. Immediately after I refresh. ![]() I think I need to tweak the action slightly to make it actually work on related lists, but this problem is solved. EDIT: Ding! Looks like it all works now. Thanks very much. ![]()
9 posts
• Page 1 of 1
Who is onlineUsers browsing this forum: No registered users and 6 guests |