Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
This may be chalked up to my not understanding Rules fully, but how can I set field values for a flag from Rules?
My use case is a wedding registry: I set a 'purchased' flag on a product on Checkout, which has already been flagged for 'added to registry' by the Wedding Couple. The problem is that after checkout, I'm not able to specify the quantity that was purchased, which should be a field attached to the flag?
Thanks!
Comments
Comment #1
akalata CreditAttribution: akalata commentedRules integration with the 7.x-3.x branch is limited (possibly non-existent). The Flag maintainers have requested help with Rules (see #1736524: Rules maintainer / decouple Rules integration to a new project) but nobody has stepped up yet.
You may want to try the 7.x-2.x branch and see if that helps you better?
Comment #2
shabana.navas CreditAttribution: shabana.navas commentedIf I understand you correctly, the process works fine in the 7.x-3.x branch. Here are the steps you need to perform:
1. Set up your flag
2. Go to rules, add a new rule, which, triggers upon checkout.
a. The condition for the rule (this basically allows you to see the field values for that content type when you setup your action):
- Content is of type,
- Parameter: Content: [flagged-node], Content types: Article (your content type in this case)
b. The action for the rule:
- Set a data value
- Parameter: Data: [flagged-node:field-my-field] (the purchase field in your case), Value: [site:current-user:uid] (the quantity no. in your case)
Basically, if you figure out how to use the data selectors, then, understanding the way Flags and Rules work becomes a lot easier. In my opinion, I really don't think Flags integration with Rules is non-existent.
Comment #3
shabana.navas CreditAttribution: shabana.navas commentedComment #4
shabana.navas CreditAttribution: shabana.navas commentedMarking as fixed. Since there are no responses for it, I am going to believe it worked.
Comment #5
RuarriS CreditAttribution: RuarriS commentedActually, I was not able to get it to work.
I had problems with the Content:[flagged-node] part: it doesn't know what node is flagged, if you set the rule to trigger on checkout. The Content would be the Order, right? In this scenario, the flagged product is attached to the line item, if that sounds correct.
Is my logic off, in how to get this to work with rules?
Comment #6
shabana.navas CreditAttribution: shabana.navas commentedWill take a look at this again and hopefully post a solution to it.
Comment #8
akalata CreditAttribution: akalata commentedComment #9
Yuri CreditAttribution: Yuri commentedAny updates on this? I'm trying to set Flagging field values in Rules, but can't see how to fetch the flagging entity in order to get the fields available.
Tried php also..without luck.
Comment #10
shabana.navas CreditAttribution: shabana.navas commentedAnswer to #9 is in issue #2269391: Add rules action to fetch flagging by user for a particular entity.
Comment #11
kopeboy CreditAttribution: kopeboy commentedI don't think the answer is in that issue (I replied there).
Comment #12
joachim CreditAttribution: joachim commentedClosing this as the other support request is the same question.
Comment #13
kmstf CreditAttribution: kmstf commenteddear shabana.navas can you tell me in same situation how we can change the field value filled a term.
for e.g. a node has a taxonomy term field filled a value "newyork"
i want to change this value as "boston" which is already predefine in vocabulary
thanks a lot!