Adding workflow: previous comment to fields duplicates nodes in view results

kloosm - February 20, 2008 - 12:26
Project:Workflow
Version:6.x-1.0
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:active
Description

I searched the issues already submitted for the workflow module, but couldn't find anything that matched my issue. I'll try to explain:

I created a simple workflow with a few states: new, approved, disapproved. I created two nodes, one in state approved and one in state new.

I created a view to show all the nodes including their workflow state. However, my view returns 4 results. The two nodes I created are duplicated: once with state new and once with state approved. When I remove the workflow: state from the fields in my view, eac node is only shown once.

Attached are some screenshots to explain.

AttachmentSize
nodesareduplicated.JPG19.39 KB
notesarenotduplicatedwhenstatenotshown.JPG10.29 KB

#1

kloosm - March 10, 2008 - 09:43

Anybody who can help me with this?

#2

kloosm - March 10, 2008 - 15:31

OK found it: this was caused by problem with workflow owner module, described here: http://drupal.org/node/226972

#3

rares - January 3, 2009 - 11:53
Version:5.x-1.2» 6.x-1.0
Category:bug report» support request

I'm having the same problem with workflow 6.x-1.0 and views 6.x-2.2.
When I add Workflow: previous comment to the fields, I get an entry in the view for each different comment I entered, not just the most recent one. Does anyone know how to avoid this duplication?
This might have more to do with views than with anything else, but any help is appreciated.

#4

rares - January 3, 2009 - 11:54
Title:Adding workflow: state to fields in view result in duplicated nodes in view results» Adding workflow: previous comment to fields duplicates nodes in view results

changed title, because this pertains only to the comment fields.

#5

voidberg - February 22, 2009 - 23:17

I have the same issue. Any news on that? I am not using workflow owner, just views and workflow.

#6

a_c_m - June 2, 2009 - 09:58
Component:Miscellaneous» Code
Category:support request» bug report

same as #5 - getting double results, even with distinct turned on, on the view.

#7

petrescs - June 4, 2009 - 17:14

Same here for workflow 6.x-1.1 and views 6.x.-2.5

#8

tpainton - August 19, 2009 - 03:11

I am having the same issue. When the field Previous Comments is used, there are duplicates because the node has been in that workflow with more more than one comment. Blanks are essentially a comment with no characters. What is REALLY needed is a field "Workstate Current Comment". I think this is essentially what all of us are looking for. This SHOULD get rid of the duplicates and it's not really a bug if the field is designed to list ALL of the previous comments.. Not just the comment previous to the current. I'm not sure when one would use it as a better field would be "All Previous Comments."

When listing all nodes of a certain workstate, it sure would be nice to list the comment associated with that workstate. At present, I don't think there is a way to do this.

If I am wrong here, please, someone let me know. I really need this functionality.

Thanks.

#9

tpainton - August 19, 2009 - 03:20

One work around I thought might work would be to add an argument "Current State", then use php to return the current state and therefore, only list the comment of the current state.. I have no idea how to do this with php.. Love help, or a new field :)

#10

gtothab - August 30, 2009 - 16:03

I'm having the exact same issue. Anybody know of a fix??

thx

#11

restyler - September 8, 2009 - 20:34

As "distinct" modifier doesn't work for me in views, here is the quick workaround I used to get the most recent workflow comment:

- Install http://drupal.org/project/views_customfield module
- Create a php custom code view field for your view
- Insert the following code inside textearea:

<?php
echo db_result(db_query("SELECT comment FROM {workflow_node_history} WHERE nid=%d ORDER BY stamp DESC LIMIT 1", $data -> nid));
?>

#12

lisacabisa - October 11, 2009 - 21:30

Thanks restyler -- that's perfect!
I adjusted your query a bit to get the immediately previosu workflow state:

<?php
echo db_result(db_query("SELECT ws.state FROM workflow_node_history wh, workflow_states ws
WHERE wh.old_sid = ws.sid and wh.nid=%d ORDER BY wh.stamp DESC LIMIT 1"
, $data -> nid));
?>

Like a charm. :)

 
 

Drupal is a registered trademark of Dries Buytaert.