webform_handler_field_submission_link makes an assumption that webform_submissions is the base table of the view. If the submission was reached through a view relationship, this is not the case and the submission link field cannot be added to the view.

The message reported is that node_uid field is not reachable (not the exact wording). It results from an exception during the query (inside the call to ensure_table, as I recall) in class webform_handler_field_submission_link in webform_handler_field_submission_link.inc. Alas, I don't currently know enough about how relationships are implemented in views to help more, but I'm guessing that the join is not right in query:

  function query() {
    $this->ensure_my_table();

    // Join to the node table to retrieve the node UID.
    $join = new views_join();
    $join->construct('node', $this->table_alias, 'nid', 'nid');
    $this->query->ensure_table('node', $this->relationship, $join);

    $this->add_additional_fields();
  }

To reproduce the problem, you will need a table with a relationship that gets you (presumably via an sid) to the submission table. Create a view using this base table. Add the relationship to the submissions. Try to add a link field, such as view or edit. Ajax error results.

Comments

quicksketch’s picture

Status: Active » Fixed
StatusFileSize
new555 bytes

Thanks, I ran across this exact same problem two days ago. Looks like the existing Webform views implementation sadly misnamed one of its views tables. It should have specified "webform_submissions" (plural) but instead it specified "webform_submission" (singular). Since we can't change this without breaking all existing views that use Webform, we'll have to compensate by manually specifying the JOIN relationship between the node table and the webform_submissions table. This patch corrects the problem. Committed to both 3.x branches.

Status: Fixed » Closed (fixed)

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

kscheirer’s picture

Version: 7.x-3.x-dev » 6.x-3.17
Status: Closed (fixed) » Needs work
StatusFileSize
new2.55 KB

I don't think the patch fixed the issue unfortunately, sorry to reopen this ticket.

I'm using the relationship Node: Webform submissions, which is what the patch above was trying to correct.

The SQL join ends up as:

LEFT JOIN webform_submissions webform_submissions_node ON node.webform_submission = webform_submissions_node.nid

where node.webform_submission is obviously not a valid field, that should be node.nid = webform_submissions_node.nid.

Here's the entire final query:

SELECT node.nid AS nid, node.title AS node_title
FROM node node
LEFT JOIN webform_submissions webform_submissions_node ON node.webform_submission = webform_submissions_node.nid
WHERE node.type in ('webform');

and attached the export of the View I'm working on (simplified to just show this problem). This is with Commons 6.x-2.6, which uses Views 6.x-2.16 and Webform 6.x-3.17. I've tried different things in webform_views_data_alter() but I'm just not getting the right syntax to have Views make the join properly.

danchadwick’s picture

Issue summary: View changes
Status: Needs work » Fixed

@kscheirer - Your bug in unrelated. I finally got to the bottom of it:
#2208931: Using views, submission table unreachable from node or user table

Status: Fixed » Closed (fixed)

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