Adding a new account and contact with validation

In this recipe, while the use of scripting is suppressed, we are implementing logic to perform a duplicate detection validation when inserting a new account. The purpose of this recipe is to demonstrate that we can force a user to choose if he/she wants to create a duplicate or not from the get go, rather than relying on a duplicate detection job to run. This approach still uses the system-defined duplicate detection rules, but makes the process dynamic and interactive for the user.

You can easily implement the same functionality for contacts, or you can merge both checks in the same process.

Getting ready

Either create a new solution or use the previously created solution. This recipe will work with dialog processes, and will create a more detailed process to qualify a lead.

How to do it...

To add a new account and contact with validation perform the following steps:

  1. In your solution, add a new process of type Dialog. The associated entity is Lead. Give this process a name of Qualify Lead. Make it available to run on demand.
  2. Add a first stage named Choose Entity Stage, by going to Add Step and then selecting Stage, as shown in the following screenshot:
    How to do it...
  3. Inside this stage add a new page named Select Entities to create.
  4. Inside this page, add a prompt and response. Name it Contact.
  5. Set its properties, as described in the following screenshot:
    How to do it...
  6. Add another prompt and response. Name it Account.
  7. Set its properties, as described in the following screenshot:
    How to do it...
  8. Add a new stage. Name it Check Create Contact Stage.
  9. Add a Check Condition step. Set the rule, as follows:
    How to do it...
  10. Within this condition, add a Query CRM Data step. Name it Query CRM for Contacts with email matching the Lead.
  11. Set the query properties, as follows:
    How to do it...
  12. Add a Check Condition step. Label it No matching Contact records. Set the condition, as follows:
    How to do it...
  13. Add within this condition a Create Record step to create a new contact.
  14. Also add within this same condition an Update Record step to update the Lead customer.
  15. Add a Conditional Branch step to step 12.
  16. Add a new page; label it One or more duplicate Contacts found.
  17. Add on this page a prompt and response, as follows:
    How to do it...
  18. Add another prompt and response to this page, and define them as follows:
    How to do it...
  19. At the same level with the last page added in step 16 add a new Check Condition step. Set the condition, as follows:
    How to do it...
  20. Within this condition defined previously add a new Create step to create a new contact.
  21. Also create an Update step to update the Lead customer.
  22. For the condition in step 19 add a conditional branch.
  23. Within the branch add a new Update step to update the Lead customer.
  24. Create a similar process we used from steps 8 to 23 to create the contact. This time we will apply it to the Account entity.

    Note

    If you want to create only a contact from a Lead, you can skip steps 6 and 7.

  25. Lastly, create a new stage to finalize our process. In this stage we will create the opportunity, mark Lead as Qualified, and add a Stop Dialog step. It should all look like the following screenshot:
    How to do it...
  26. Save and activate this process. If any errors are returned, fix those errors and activate again.
  27. Create a new Lead and run this dialog manually. Eventually, you can create a ribbon button to start this process, but we will demonstrate that in another chapter.

How it works...

The process itself does not have a complex logic. Instead of running the standard Lead qualification process, we start this dialog. It prompts the user if he/she wants to create Account and Contact based on the lead information.

How it works...

The user selects none, one, or both and clicks on Next. For each entity to be created it then checks if other contacts or accounts exists in the system with similar properties. If they don't, it creates new ones. If they do, it brings a list of possible matches to choose from, as shown in the following screenshots:

How it works...
How it works...

Once you have defined new or existing Account and Contact details, the process marks Lead as Qualified and opens an opportunity.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.135.247.219