Controls in Dynamics 365 for Mobile App: Flip Switch

By | April 23, 2018

Introduction:

In our previous blogs of the ‘Controls in Dynamics 365 for Mobile App’ series, we discussed Input MaskMultimediaWebsite PreviewAuto-CompleteOption setStar Rating controls and Contract Calendar. The Contract Calendar Control may help you to view the time table in order to understand what time the task needs to be performed on weekly basis. Contract calendar Control can be used as Task Scheduler on weekly basis on Mobile and Tablet.

Controls_Flip Switch

Today in this blog let’s discuss about another control in Dynamics 365 called ‘Flip Switch’.

What is Flip switch and how it can help users?

The Field Type to use Flip Switch would be ‘Two options’.

If you go by UI perspective, Flip switch control- Yes/No (Boolean) options would give the nice field look in the web, mobile app and Tablet. Instead of using check boxes and radio buttons, this control adds a visual effect like the On/Off switch way.

Let us see an example where we have added Flip Switch control on the Account entity record:

In this example, we will add the Flip Switch control on the Account entity record. We need to use the visual effect of Flip Switch to see whether the Account is Taxable or not.

1. First, create a new field ‘Taxable’ with ‘Data type’ as ‘Two Options’ as seen in the screenshot below:

Controls in Dynamics 365 for Mobile App: Flip Switch

Here, we have kept the default value of “Taxable” field as “No”.

2. Now, add this field on Account Form and click on the ‘Field ‘ Select the ‘Controls’ tab and click on ‘Add Control.’ Then choose the Flip-Switch control as shown in the screenshot below:

Controls in Dynamics 365 for Mobile App: Flip Switch

Controls in Dynamics 365 for Mobile App: Flip Switch

Note: When you add the control, the “Visible by default” for the field sets to “No”. So once done adding the controls, need to again set the “Visible by default” value as “Yes”.

3. Click on ‘Save’ and ‘Publish’ the customizations. Once you save the record, log in to Dynamics 365 Mobile and Tablet app and open the Account entity record in which you have put the Taxable field. You will now see Yes/No represented as Flip switch as seen in the screenshot below:

Controls in Dynamics 365 for Mobile App: Flip Switch

4. This control also works on web client. To view Flip switch control on web client, navigate to Account entity and see the look of the “Taxable” field.

Controls in Dynamics 365 for Mobile App: Flip Switch

Conclusion:

The Flip Switch control is helpful in situations where a user needs to show the simple Yes/No two options in an effective way. It adds an interactive visual element for users in Dynamics 365 web, Mobile and Tablet app!

Export Dynamics CRM Reports

6 thoughts on “Controls in Dynamics 365 for Mobile App: Flip Switch

  1. Vatsal

    Nice Article!
    May I know how to set value in this control using JavaScript?
    Thanks

    1. inogic

      Yes we can set the field using JS by using the below code:

      formContext.getAttribute(“donotemail”).setValue(true);

      Please find the sample scenario below:

      function flipSwitchExample(executionContext) {
      var functionName = “flipSwitchExample “;
      try {
      var formContext = executionContext.getFormContext();
      var creditonhold = formContext.getAttribute(“creditonhold”).getValue();// on change of the field set the “donotemail”
      //validate creditonhold = Yes(true)
      if (creditonhold) {
      //set donotemail(i.e. Flipswitch)
      formContext.getAttribute(“donotemail”).setValue(true);
      }
      } catch (error) {
      Xrm.Utility.alertDialog(functionName + “: Error: ” + (error.message || error.description));
      }
      }

      Thanks!

  2. Swaroop

    Hi.

    I have added this control for my Two option attibutes. I am not able to fire the javascript code on change of this control.
    Does it not support onchange event?

    Is there any change required to fire my onchange event upon setting fip-switch control?

    1. inogic

      Hi,

      Yes, It supports on change event. You do not have to do any change to fire on change event after setting flip-switch control.

      I have tried the same and its working for me.

      Could you please confirm how you are triggering this on change event? Means are you updating this field manually or through custom JavaScript code? If you are updating through custom java script code then you need to add “fireOnChange()” event on that attribute.

      Please refer this link : https://docs.microsoft.com/en-us/powerapps/developer/model-driven-apps/clientapi/reference/attributes/fireonchange

      Thanks!

  3. Pranali Nerkar

    How to enable this control on Business Process Flow?
    I have added this Two Option field in BPF and want to update it as Flip-Switch Control
    I am not finding a way to do this
    Thank you in advance

Comments are closed.