Views:

Scenario Overview

In this scenario we need to add a validation rule when a user marks an Opportunity as 'Close as Won'.

The validation rule states that there must be at least one user with the role 'Sales Professional' associated with the Opportunity. You can see in the screenshot that the user John Grace has the role 'Sales Professional' so the validation rule would pass. 

Otherwise it would fail and display an error message to the user who tried to mark the Opportunity as 'Close as Won'

N52 Formula Manager Solution

The Formula Manager solution works like this,

  • A formula of type 'Process Genie' is created so it can execute as a step within a workflow
  • When it reaches the 'Process Genie' step in the workflow it will execute the formula
  • The formula executes a fetch-xml query that returns a count of the number of records with the type 'Sales Professional'
  • If this is equal to zero then we throw an error message which stops the Opportunity being marked as Won

N52 Formula Manager Steps

The following set of steps outline how to create this Formula

  • Create a new formula of type 'Process Genie'
  • Set the Source Entity to 'Opportunity'
  • Set the Display Format pick-list to 'Whole Number'
  • Copy & paste the formula below into the formula 
  • Click save

Formula

FindCountFD('GetOppRoleCount', 'connectionid',  '0' )

Formula Detail Steps

The following set of steps outline how to create this Formula

  • Create a new formula detailed called  'GetoppRoleCount'
  • Copy & paste the fetch-xml from below into the query field
  • Click save

 
Fetch

<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false">
  <entity name="connection">
    <filter type="and">
      <condition attribute="record2id" operator="eq" value="@opportunityid@" />
      <condition attribute="record1roleidname" operator="eq"  value="Sales Professional" />
    </filter>
  </entity>
</fetch>

Workflow Steps

The following set of steps outline how to create this Workflow

  • Create a new workflow named 'Opportunity Validation' on the Opportunity entity
  • Set it to execute as a real-time workflow
  • Set it to execute only when the 'Record Status Changes'
  • Create the workflow steps as shown below in the screenshot
  • Set the formula shortcode on the Process Genie to be the one on the formula
  • Publish the workflow
  • You are now ready to test


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

Wizard - FindCountFD

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

Note 1 : You will need to have created the Fetch Xml beforehand.