1

I have a webform, and I'd like to be notified whenever someone edited his own submits. I'm using the Webform module.

I found the Webform Rules module but I didn't get how to use it, any way to set this up?

1
  • Thank you @Pierre.Vriens I greatly appreciate your instructions, i like your answer it's logical and very helpful, i will try it for my next project cause the technical specifications of this one have been changed, and they don't need this function any more – Imanelek Oct 4 '16 at 15:01
2

Using Webform Rules (and Rules of course), it's a peace of cake to send an eMail using Rules Event "After a webform submission is updated". To actually do so, refer to the answer from CodeNext. However, the real challenge in this question here, is to address this part of the question: "someone edited his own submits". Read on for more details on how to implement that part of it.

Assumptions:

  1. It should also work for "someone edited 'her' own submits".
  2. The question is NOT about anonymous users (for that you might need things like IP address, session API, etc ... be my guest to also get that to work ...).

With these assumptions in mind, you'll need to have something in your webform available to store, as part of the submitted webform, the uid of the user who actually submitted the webform. I've not found (yet) any such data that is available as a token to Rules (you'll need it in Rules to get this challenge to work). So therefor I'd use an approach like adding an extra (hidden?) webform field that is automatically set (eg using Rules) when the webform is first submitted, let's say using a field with machine name field_webform_submitter_uid.

After all the above is in place and agreed about, you're in good shape to address the challenge "someone edited 'his/her' own submits": all you'd have to do is to further enhance the rule detailed in the prior answer, by adding an appropriate Rules Condition, to check if the uid of the currently logged in user matches field_webform_submitter_uid.

But, there is 1 more challenge to implement that extra Rules Condition: how should the Rules token look like for the value of field_webform_submitter_uid? To find the answer to this, refer to the README.txt of Webform Rules: based on what's documented there, the token to be used in that extra Rules Condition should be [data:field_webform_submitter_uid-value].

Voilà ...

Note (about the token for the uid of the user who submitted the webform): each submission has data like "submitted by" and "submitted on", however from all uid-variations I've experimented with, none of them contain the value that always matches the "submitted by" (not to be confused by tokens like node:author:uid, those are for sure not what matches the "submitted by"). To convince yourself, try a scenario where the user who submitted the webform is different from the one who edits that submission ...

6
  • 1
    @NoSssweat : I did an experiment with various tokens I had available (about 4 I believe) , such as node:author:uid and by displaying their value via a Rules Action "Show a message on the site" (with no Rules Condition). However I did not find any that correspond with "the userid who submitted the webform". Are you sure node:author:uid contains a value of the user who submitted the webform? I think it is actually the uid of the creator of the webform itself ... – Pierre.Vriens Aug 7 '16 at 9:57
  • @NoSssweat : your last comment made me doubt (again). So I re-did various tests/scenarios. I'm testing with a submission from a user that is different from the currently logged in user. But in my scenario all uid-tokens always have a value of the uid I'm logged in with. So in your scenario, are you also testing with a current uid that is different from the uid who submitted the form? If you're using the same uid, then IMO your testcase works "by accident", understand what I mean? – Pierre.Vriens Aug 7 '16 at 13:14
  • Very smart and creative solution, thanks @Pierre.Vriens i will try it – Imanelek Aug 7 '16 at 17:04
  • Nice brainstorming at Pierre.Vriens + NoSssweat. Knowledgeable inputs, learned things. Pierre.Vriens..+1 for answer & explanation. – CodeNext Aug 7 '16 at 18:52
  • @CodeNext Merci for the kudos ... know however that I'm still struggling with the last comment from NoSsssssssssssssssweat ... as detailed in my latest comment before this one ... I'd be interested to learn from you also, if you can, what the value of node:author:uid actually is, in the scenario where the user who submitted the webform is different from the one who edits that submission ... – Pierre.Vriens Aug 7 '16 at 18:57
1

Note: Please Do not follow this Answer, as I misunderstood the requirement previously. You can follow this to get the general idea of how to create Rules

You have right module sets, You need Rules and Webform Rules, as webform rules module depends on rules module.

Now, if you go to Admin/Config/Workflow/rules.

1. Create a new Rule and select event, as shown in following image I have created a new rule named Webform Edit Notification. Then select a Event, as you can see in image, I have selected a option under Webform After a webform submission is updated

enter image description here

2. Select the Action, from options I did choose Send a mail as shown in following image. If you save a move to next step it will open a new page for sending a email setup.

enter image description here

3. TO: Now first field is TO whom you want to send. As you click the button switch to the direct input mode and click on the data selector the options as shown in image will open.
Now form the image I am selecting node:...(The webform node). After selection it will show options which are under that under that. So I am selecting node:author:...(Author). Then again same in next step I am selecting Email.

Hence, It will end up as node:author:email which translate, **Email address of Author of that particular node** So this will make a TO:

enter image description here

enter image description here

enter image description here

Then you can add,

Subject:

Add message:

From:

So, this way it will send a mail to the mail to the author of that webform.

I have not used this as I am not using in my site, But this is the logic. You can try it to validate it before finalizing for Live site.

13
  • 1
    Nice instructions, well done! Though I think you're still missing a crucial piece in it to address this part of the question: "someone edited his own submits". I trust you know how to further enhance your answer to also cover that. If not let me know. PS: no need for the introduction note (if you ask me), I would remove that from this answer ... but that's up to you of course. – Pierre.Vriens Aug 5 '16 at 16:22
  • 2
    No need to delete your answer, don't worry. I suggest I'll add an answer then with something like "to complete the answer fro Codenext, make sure to also do so and so" ... OK? – Pierre.Vriens Aug 5 '16 at 16:40
  • 1
    That will be perfect, so questioner will get better knowledge. +1 – CodeNext Aug 5 '16 at 16:43
  • 2
    Hmmm.... and I just understand this question, you were right, it is not that way. It is like admin(One contact point) should be notified whenever someone updating his/her own created webform. – CodeNext Aug 5 '16 at 17:56
  • 2
    Aha, now you seem to get my point (understanding the problem is often 50% of the solution, right?). Just in case you want some homework for the weekend: find the appropriate token that you can use in rules ... Actually, I might post that soon as a new question (related to this one) ... think it would be a good (though possibly tough) question? – Pierre.Vriens Aug 5 '16 at 18:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.