Views:

Scenario Overview

In this business scenario the requirement is to determine all the 'Sales Team'  members of an Opportunity (i.e. an Access Team, new security feature in CRM 2013) & send them an Individual Email when the Opportunity reaches the 'Close' stage.

In the screenshot below we can see that the Sales Team currently has 3 members on the Opportunity.

North52 Decision Suite Solution

The North52 Decision Suite solution works like this,

  • We create a formula to execute whenever the Stage of an Opportunity changes
  • If the Stage is set to 'Close' then will perform our processing
  • First we will execute a Fetch-Xml query to retrieve all the Team Members for the current Opportunity
  • Next we will loop over these Users one by one calling an Action
  • The Action takes a User & the total number of recipients as parameters to generate & send the email

North52 Decision Suite Steps

Formula Steps

  • Create a new formula of type 'Save - Perform Action'
  • Set the Source entity to 'Opportunity'
  • Set the Source Property field to 'Stage'
  • Copy & paste the formula below into the formula description field & click save 



 

Formula Detail Steps

  • Scroll half way down the formula & click to add a new formula detail record (i.e. add the fetch-xml query)
  • Set the Name to 'RetrieveTeamMembers'
  • Copy & paste the fetchxml below into the query field & click save

Action Steps

  • Create a new Action within MS CRM
  • Set the name of the Action to 'Send Email Closing Opportunity'
  • Set the Unique Name to 'SendEmailClosingOpportunity'
  • Create an Argument called 'emailto', set the Type to EntityReference and make it required 
  • Create an Argument called 'numberofrecipients', set the Type to Integer and make it required 
  • Now add a 'Send Email' step to the Action
  • Use the 'emailto' to set the 'To' field of the email 
  • Use the 'numberofrecipientsemailto' within the description field of the email


Formula

if( FindValue('processstage',
               SetFindAnd('processid', 'processstageid'),
               SetFindAnd([opportunity.processid], [opportunity.stageid]), 'stagename') = 'close',

  ForEachRecord(

           FindRecordsFetchXml( StringFormat(GetFetchXml('RetrieveTeamMembers'),
                            [opportunity.opportunityid])),

           ExecuteAction('new_SendEMailClosingOpportunity', 
                                'opportunity',
                                [opportunity.opportunityid],
                                SetAttributeActionLookup('emailto', 'EntityReference', 'systemuser', 
                                                         CurrentRecord('systemuserid') ) ,
                                SetAttributeAction('numberofrecipients', 'Integer', RecordTotal() )
                               ))
 ,'NoOp')

Fetch-XML

<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false">                                                                
   <entity name="teammembership">
       <link-entity name="team" from="teamid" to="teamid" alias="ab">
            <filter type="and">
                <condition attribute="regardingobjectid" operator="eq"  value="{0}" />
            </filter>
       </link-entity>
   </entity>
</fetch>

Did you know?

North52 TestShield benefits Dynamics 365 apps testing

Benefits of using North52 TestShield's automated testing framework for Dynamics 365 apps:

1. Accelerate Automated Testing
  • Enables continuous testing of Dynamics 365 apps with speed and agility
  • No-code test designer enables non-developers to build tests
2. Improves Test Coverage
  • Better ROI by a reduction in UAT defects and production defects
  • Defect prevention at early stages of the project life cycle
3. Fix Defects Faster
  • Get fast feedback on the impact of process changes
  • Repeatable automated test execution simplifies problem solving
  • Quickly resolves failing conditions from complex end-to-end tests
4. Faster Delivery and Higher Quality
  • Broader test coverage and fewer defects released to production
  • Reduced risk and faster release cycles through earlier and automated testing
  • Lower costs related to complex test environment management
  • Reduces time to market by validating builds faster
5. Increased Testing Productivity
  • Assist in the generation of automated test scripts that are repeatable and extensible
  • Detailed analysis of test trace logs enable easy detection of errors to be fixed
  • Automation can perform regression tests which ensures system stability while enhancing the application continuously
  • No manual operation increases efficiency and quality of testing

Learn more about TestShield