Rules are fun!

bodyblueprinter's picture

Hi Gang!
So I am trying to figure something out....I am using MyTinyTodo to create user to do lists. I have created a view so that I could use a block for display in certain contexts (using Omega+Context+Delta). The content type that utilizes the TinyTodo field also has a User Reference field that makes it so I can show view blocks based on UID contextual filter. I then created a rule that creates the node upon saving new user account and assigns the UID. When I run the test, the list does not show up. I check the view and enter the UID as a contextual filter and the list displays.

I then fished around and really could not find anything related to the issue. So I decided to edit the node and reset the UID....saved, and now the list displays properly in the theme context.

My question is why would it not display when rules set the UID, but then did display when I edited the UID in the existing node (that was created through the rule)?

Your feedback is appreciated.

Tobin

Comments

When setting up the rule, you

murias's picture

When setting up the rule, you most likely need to add the action "save entity" after you set the appropriate value to that field. It usually helps to "force saving immediately", this last option will become self evident when you are setting up the save entity action.

Hope this leads you in proper direction

Murias

Thanks for the relply

bodyblueprinter's picture

I gave that a go, but it did not seem to make a difference. I will keep digging.

Test your rule

murias's picture

Might I also suggest that you test your rule. Print messages to the screen for what is set / has been set, use this as verification. Then even check your logs and see if it truly indeed sets everything appropriately.

Murias

Any other thoughts?

bodyblueprinter's picture

Hi All,
I am revisiting this because after watching the the DB tables during the rule process, I saw that the values displayed there were as suspected at the time of the rule firing. Interestingly the todo list will still not display until after going to the rule created content and then re-entering the user reference (which is already properly populated), click save and it then show where expected.......bug report? User Reference issue or My tiny todo?

What actions are you taking in the rule?

Torenware's picture

I took a look at the code for My Tiny Todo, and it looks simple enough -- it's just implementing a Field API widget. But with some things in Rules, you do need to worry about timing. Some times, events you use in Rules happen too late, or too early in a request, so something you want to be there isn't there yet, or late enough so something you need to prevent has already happened.

I've seen this with sending out emails based on user information when you create a new user. If you send an email on the event for "user save", then anything that happens when a module handles the user save hasn't happened yet. So often your emails don't fill out right.

The solution in this case is to use a different event to trigger your rule; one that's called later in the request. Or, if you can't find an event that happens when you need it to happen, create your own event, that gets called later (not too hard, but still, coding a bit of PHP).

So what actions are you calling, and in response to what events? You might need to change the event, or the action, depending on what you're doing.

Do you have the Rules debug

darrylri's picture

Do you have the Rules debug listing turned on in the Rules settings page? This always tells me what isn't firing. Then I can figure why and fix it.

Santa Cruz

Group events

Add to calendar

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: