Hi there.

I have a taxonomy for departments, with a taxonomy reference field in the user profile and another taxonomy reference in my webform. The idea is that users can submit forms related to their department and then prepare reports related to their department that include submissions from others in the same department. It also allows a user to change departments without their submissions being lost to the original department.

I'm successfully populating the submission reference from the user reference, and am now seeking to build a view that shows all submissions by people in the same department as the user viewing the report. I started with web submissions as the base table but don't see a way of using the relationship to the taxonomy. Am I just approaching things from the wrong end, or is there functionality missing that would enable this?

(If the later, I'm willing to work on adding it - I just want confirmation that I'm not doing something wrong as I don't use relationships and contextual filters every day).

Thanks in advance!

Comments

NigelCunningham created an issue. See original summary.

bucefal91’s picture

Status: Active » Needs review
StatusFileSize
new5.63 KB

Hello!

To me it sounds like you need an exposed filter or argument on the webform submission. Argument is not available yet. Filter - seems like yes according to my quick test.

Nonetheless I will take this opportunity to write a relationship from a referenced entity in a webform submission to its base table. So you could do to the term reference (in your example) and then place some field from the term into the view result.

nigelcunningham’s picture

Ah, you bet me to it :)

I prepared the attached series of patches. Not sure which is to be preferred.

bucefal91’s picture

hello! :)

Your patch 0001-Correct-incorrect-grammar-in-help-messages.patch definitely goes in :)

As for 02 and 03 patches of yours, I would prefer to use my patch from #2 because it solves the problem on a more generic level - for any webform element that implements entity reference interface. With such approach with a single views data class I have covered term select, entity select, entity autocomplete (and possibly even more element types). Does it make sense to you?

geYdes’s picture

Hi.

First, thanks for the module.

I take this issue to ask for help on a view with which I'm having problems adding a contextual filter that filters the webform submissions by the node's author from which any user can send the webform.

The webform collects all the necessary values of the node (author ID, node ID, author name, ...) and the view shows them perfectly.

Problem: the author of a node can see all webform submissions sent from any node (even if he isn't the author).

Therefore, it would be necessary to add the contextual filter that filters by ID of the identified user. That way, each author could see only the webform submissions made from their own nodes.

I hope you can help me, because I have tried "a thousand" options and I can not find a way to solve it.

I have applied the patch in #2 and the first of #3.

Thanks.

  • bucefal91 committed 6338624 on 8.x-5.x
    Issue #2942666 by NigelCunningham: Fixing grammar in the wording.
    
  • bucefal91 committed 656279f on 8.x-5.x
    Issue #2942666 by bucefal91: Introducing support for relationships from...
bucefal91’s picture

Status: Needs review » Fixed

hello, geYdes!

Your problem hardly fits into this ticket. You do need a contextual filter on author of the webform submission if the "user" is part of the URL. But if you just wanna limit to the currently logged in user, then you should add a relationship to the user and then use a filter "current user" or something like that (I do not recall how exactly it's called).

As far as the main topic of this ticket, I've just committed my #2 + 0001-* patch from #3. As I haven't got feedback from NigelCunningham and there was some time I decided to move forward with the commit.

Thank you for patches, NigelCunningham!

geYdes’s picture

Hi, @bucefal91.

That's the question, find a way to establish the relationship that allows me to apply the contextual filter to the current user.

But the relationship is not possible to establish.

Thanks!

nigelcunningham’s picture

Oh, sorry. I completely missed your reply. I haven't looked at the patch itself but reading your comment #4 - a more generic solution sounds like the way to go. Thanks very much and apologies again for missing the original email.

bucefal91’s picture

StatusFileSize
new206.43 KB

NigelCunningham, no problem at all :) I also lose emails now and then

geYdes, I just had a random view of webform submissions - there is an option to add a user relationship. I believe you do not even need this module (bare bone webform.module will do it). See printscreen enclosed.

geYdes’s picture

Yes, bucefal91, this module is very necessary in this case, and others, because it allows managing the display of results with a wide range of possibilities. With Webform only is not possible.

And yes, the "User" relationship already exists, but it only allows associating it correctly with the user that sent the webform.

In the case of needing to establish the relationship with the node's author from which the webform is sent, the established contextual filter breaks the view, showing no results.

This is the problem that happens and why I raise the issue.

In any case, thanks for the module!!

bucefal91’s picture

StatusFileSize
new211.27 KB

oh now I see. Your "user" is not the author of the webform submission but author of the node where it was submitted. In that case you have to build your view off the "node" table. Right now it is impossible to build a relationship from webform submission to the source entity. Do the following:

  1. Create a view on "content" (aka "node) table;
  2. Add relationship to the "webform submission" (see the screenshot where I highlight the correct relationship);
  3. Add relationship to the "user" from the node author;
  4. At this point you should be set as far as the problem you're speaking of. You can "cook" the rest of the view per your specific case. And yes, in this set up you will need Webform Views. I just didn't understand your problem in full at the 1st glance.

As far as I understand your question, the above is the answer you need :) well, there's still some chance I misunderstood it again :)

bucefal91’s picture

I've just filed a ticket to introduce the relationship from "webform submission" to "webform node". It is #2950742: Relationship from submission to webform node.

But as I said, geYdes, my steps from previous comment should already get you running (as long as you can afford to build the view off the node and not off the webform submission).

geYdes’s picture

Perfect!!

I'm going to do it that way and I'll comment on the result.

Thanks!!

geYdes’s picture

Hi, bucefal91.

I confirm that following the instructions in #12 the issue is fixed.

Thanks!

bucefal91’s picture

geYdes, 8) next time you come across a developer on the street, buy him a beer.

geYdes’s picture

Better to two... ;)

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.