diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index 0e9ea50a1..af10de1c4 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -38,6 +38,7 @@ - fixed #10689: Version Tag Modes (Henry Tang, Long Term Results B.V.) - fixed #10733: viewing pending version tags - added Survey JSON performance warning for people with non-wre-standard JSON modules/versions (Patrick Donelan, SDH Consulting) + - rfe #10423: Provide a way to access the instance of the thing that was added, modified, or deleted via workflow. (Eric Kennedy) 7.7.16 - fixed #10590: Session::DateTime->secondsToInterval doesn't allow 7 weeks diff --git a/lib/WebGUI/Asset/Wobject/Thingy.pm b/lib/WebGUI/Asset/Wobject/Thingy.pm index 149a3b399..27defee9d 100644 --- a/lib/WebGUI/Asset/Wobject/Thingy.pm +++ b/lib/WebGUI/Asset/Wobject/Thingy.pm @@ -473,14 +473,14 @@ sub deleteThingData { return undef unless $self->canEditThingData($thingId, $thingDataId);; - $self->deleteCollateral("Thingy_".$thingId,"thingDataId",$thingDataId); - my ($onDeleteWorkflowId) = $db->quickArray("select onDeleteWorkflowId from Thingy_things where thingId=?" ,[$thingId]); if ($onDeleteWorkflowId){ - $self->triggerWorkflow($onDeleteWorkflowId); + $self->triggerWorkflow($onDeleteWorkflowId, $thingId,$thingDataId); } + $self->deleteCollateral("Thingy_".$thingId,"thingDataId",$thingDataId); + return undef; } @@ -598,13 +598,13 @@ sub editThingDataSave { my ($onAddWorkflowId) = $session->db->quickArray("select onAddWorkflowId from Thingy_things where thingId=?" ,[$thingId]); if ($onAddWorkflowId){ - $self->triggerWorkflow($onAddWorkflowId); + $self->triggerWorkflow($onAddWorkflowId,$thingId,$newThingDataId); } }else{ my ($onEditWorkflowId) = $session->db->quickArray("select onEditWorkflowId from Thingy_things where thingId=?" ,[$thingId]); if ($onEditWorkflowId){ - $self->triggerWorkflow($onEditWorkflowId); + $self->triggerWorkflow($onEditWorkflowId,$thingId,$newThingDataId); } } @@ -1390,7 +1390,7 @@ sub purge { #------------------------------------------------------------------- -=head2 triggerWorkflow ( workflowId ) +=head2 triggerWorkflow ( workflowId, thingId, thingDataId ) Runs the specified workflow when this Thingy changes. @@ -1404,12 +1404,17 @@ sub triggerWorkflow { my $self = shift; my $workflowId = shift; - WebGUI::Workflow::Instance->create($self->session, { + my $thingId = shift ; + my $thingDataId = shift ; + my $workflowInstance = WebGUI::Workflow::Instance->create($self->session, { workflowId=>$workflowId, className=>"WebGUI::Asset::Wobject::Thingy", methodName=>"new", parameters=>$self->getId - })->start; + }); + $workflowInstance->setScratch("thingId", $thingId); + $workflowInstance->setScratch("thingDataId",$thingDataId); + $workflowInstance->start; return undef; }