Picking Dynamic CRM Forms in ADX Studio Web Forms

Printer-friendly version

ADX Studio provides a powerful way to display CRM forms and orchestrate multi-step web flows on the web. A web flow step can be configured to display a particular CRM form on the CRM level. Unfortunately, this happens on the CRM level of the ADX portal configuration, which hardcodes a certain form to a step. This makes things complicated  if the flow needs to be more dynamic and we need to display different forms based on the value of a data field that the user has entered in a previous step. Example: The user enters a particular product in step 1 and a different form is being displayed based on the type of the product. 

There is one way to solve this issue without having to rely on a customized .NET user control which involves using conditional steps. 

This approach works well if we are dealing with a strictly binary option. Since conditional steps currently only support Boolean evaluations, there can only be two possible outbound paths. A potential workaround would be to chain multiple conditional steps together, but this can get out of hand quickly especially when we’re dealing with a whole set of different forms that need to be displayed according to the condition. 

In order to create a true Dynamic CRM form picker step, we need to create a custom WebFormUserControl, which will require us to do some .NET coding. 

The markup is as simple as it can get:

<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="Test.ascx.cs" Inherits="Site.Areas.Test.Test" %>

<adx:CrmDataSource ID="MyDataSource" runat="server" />

<adx:CrmEntityFormView ID="EntityForm" runat="server" EntityName="custom_my_entity" Mode="Edit"></adx:CrmEntityFormView>

We define a CRMDataSource and CRMEntityFormView that is going to display the entity from our previous step within a CRM form that we determine during runtime. 

Consequently, we need to load the CRM data source with the entity from our previous step. We can use a very generic statement to accomplish that, which is going to fit most common scenarios:

MyDataSource.FetchXml = string.Format(

@"<fetch mapping='logical'>                                                             

    <entity name='{0}'>

       <all-attributes />

       <filter type='and'>

         <condition attribute = '{1}' operator='eq' value='{2}'/>

       </filter>

     </entity>

  </fetch>",PreviousStepEntityLogicalName, PreviousStepEntityPrimaryKeyLogicalName, PreviousStepEntityID);

After that, we are going to link the CRMEntityFormView control to the data source:

EntityForm.DataSourceID = "MyDataSource";

Now, we can dynamically pick the form we want to be displayed by setting the value of its FormName attribute.

EntityForm.FormName = “My CRM Form”;

Obviously, this value can also come directly from the previous step entity or other sources. Example: we can add a custom field to the Product entity that contains the name of the form to display when that product is referenced in this particular WebForm. 

Since ADX studio will automatically render a submit button for this particular form, I would recommend to hide that button (Example: by applying Bootstrap’s hidden class to the button via EntityForm.SubmitButtonCssClass = "hidden";) and process the entity form once the user moves to the next step / submits the Webform. 

protected override void OnSubmit(object sender, WebFormSubmitEventArgs e)

{

     EntityForm.UpdateItem();

}

This will embed the CRM form nicely into the WebForm and prevent having two separate Submit buttons on our page.

About the Author:

TopLine Strategies delivers the complete integration and development of sales, marketing and customer service technologies that enable corporate clientele to improve revenue streams and strengthen customer interactions. Our project management and consulting is designed to achieve timely delivery, 100 percent user adoption of the technologies we implement and deliver measurable returns on investments for our clients.

Comments (0)

Related Blogs

TheReact Native Open Source roadmap was announced in Q4 2018 after they decided to invest more in the React Native open source community.

October is not just about pumpkins, fall foliage, and cooler temps anymore. October 2018 also means the exciting introduction of Microsoft Dynamics 365 for Customer Engagement.

Back in 2016, Microsoft introduced its intentions to refresh its CRM and ERP strategy with Dynamics 365. At the heart of its services was the Common Data Model (CDM).