Views:

Scenario Overview

Note : This Article is for pre version 9 of CRM , since then Microsoft has given the Process Stages its own Entity. 

In this scenario we had a business requirement to ensure that at least 1 Decision Maker stakeholder has been assigned to an Opportunity before allowing the Opportunity to the Develop step.



N52 Formula Manager Solution

The Formula Manager solution works like this,

  • A formula of type Validation is created
  • It is configured so that it executes each time the Process Stage field changes on the Opportunity entity
  • On execution it runs a FetchXML query that checks the Process Stage is Develop
  • It then uses another FetchXML query that checks if there is a Stakeholder with a role of Decision Maker connected to the Opportunity
  • If any approved Stakeholders are found it allows the Opportunity Stage to progress to the Develop stage
  • Otherwise it displays an error message to the user

Sample Error Message




North 52 Formula


N52 Formula Manager Steps

The following set of steps outline how to create this Formula

  • Create a new formula of type Validation, mode Server Side, event: Create & Update
  • Set the Source Entity to Opportunity
  • Set the Source Property to Process Stage
  • Copy and paste the formula below into the N52 Formula 
  • Create the 2 FetchXML queries and copy in the code into them
  • Click Save
  • You are now ready to test

Formula

Iftrue (FindValueFD( 'GetCurrentStageName', 'stagename', '?',true)= 'develop'  and
    
        FindCountFD('CountConnections', 
                  'connectionid', 
                  '0',
                  true,
                  SetParams(FindValue('connectionrole', 
                                      'name',
                                      'Decision Maker',
                                      'connectionroleid',
                                      '?',
                                       true) ) ) = 0,                          
        
      'You cannot go to the develop stage without at least 1 decision maker stakeholder!'
) 

FetchXML : GetCurrentStageName

<fetch count="50" >
  <entity name="processstage" >
    <attribute name="stagename" />
    <filter type="and" >
      <condition attribute="processid" operator="eq" value="@processid@" />
      <condition attribute="processstageid" operator="eq" value="@stageid@" />
    </filter>
  </entity>
</fetch>

FetchXML:CountConnections

<fetch count="50" >
  <entity name="connection" >
    <attribute name="connectionid" />
    <filter type="and" >
      <condition attribute="record1id" operator="eq" value="@opportunityid@" />
      <condition attribute="record2roleid" operator="eq" value="{0}" />
    </filter>
  </entity>
</fetch>

Wizard - FindValueFD

Please see below the wizard you can use to create the FindValueFD() function call used in this formula. 

Note you will need to create the Fetch Xml GetCurrentStage beforehand.