Creating a followup opportunity in the workflow leads to the new opportunity ending up in a wrong workflow state

SOLVED

Hi there,

we want our employees to create a followup opportunity whenever they lose or win an opportunity so that they can work on it again in a year or so when the opportunity presents itself again. To do this we integrated the task of creating a new opportunity inside our opportunity workflow. The oppo_stage in the new opportunity rule is set to default to "Lead" and the oppo_status is set to "followup", a new status I created. When I try to go through this workflow and create the followup opportunity howerver the new opportunity gets the WorkFlowCurrentStateValue of "Sold" which is the WorkFlowCurrentStateValue of the old opportunity which I was going through before. This means that the workflow buttons only offer the possibilites that an opportunity, that has already gone through the workflow up until the sold stage, offers.

Is it possible to create a followup opportunity that starts from scratch inside the workflow? The followup opportunity should take as many details from the first opportunity as possible because the employees should have as little work as possible. To achieve that by default fields like the oppo_description, oppo_note, oppo_forecast are set to the same values as the first opportunity. We are working on the CRM version 2019 R2 if that matters.

If it is not possible I would create an Escalation rule based on a view joining together the opportunity, workflowinstance and workflowstate tables and update the workflowinstance table accordingly so that the WkIn_CurrentStateId matches the corresponding oppo_stage value. Any suggestion whether that would be a feasible solution?

Kind regards

Norman

  • +1
    verified answer

    Just an update for future reference for anyone dealing with the same problem: I created an Escalation rule that seems to work. 

    I created a new view in the opportunity entity using code I found here.

    CREATE VIEW vOpportunitiesAndWorkflowState
    AS
    SELECT Oppo_OpportunityId,Oppo_PrimaryCompanyId,Oppo_Description,Oppo_Stage,WkSt_Name
    
    FROM opportunity
    
    LEFT JOIN WorkflowInstance on oppo_opportunityId = wkin_currentRecordId AND WkIn_CurrentEntityId = 10
    
    LEFT JOIN Workflowstate on WkIn_CurrentStateId = wkst_stateId AND wkst_deleted IS NULL

    I then selected this view and the opportunity table in the escalation rule and in the trigger field I put: 

    Oppo_Stage LIKE 'Lead' AND (WkSt_Name LIKE 'Verkauft' OR WkSt_Name LIKE 'Verloren')

    (the workflowstate-names are the german names for 'Sold' and 'Lost').

    I then created a new escalation action for this rule which triggers an SQL statement:

    UPDATE WorkflowInstance
     SET WkIn_CurrentStateId = 61
     FROM WorkflowInstance 
    
    LEFT JOIN Opportunity on oppo_opportunityId = wkin_currentRecordId AND WkIn_CurrentEntityId = 10
    
     WHERE oppo_stage LIKE 'Lead' AND oppo_status LIKE 'followup' AND WkIn_CurrentStateId != 61

    (the oppo_status 'followup' is a custom status I created to mark the follow-up-opportunities and the WkIn_CurrentStateId 61 is the corresponding 'Lead' value)

  • 0 in reply to Norman Zaczyk

    There are several ways you can do this, I tend to 'close' the original opportunity and then using an escalation rule on the opportunity table to trigger X time later to call on a stored procedure which creates a whole new opportunity (linking to the original) so they can process this new opportunity separately, whilst maintaining the required link for historic purposes. (For reporting purposes it keeps the original one as 'lost' but then a new one for the potential future sale).