Tag Archives: Dynamics

Microsoft Dynamics 365: Varying Form Behavior On Form-type and Save-mode

Microsoft Dynamics 365 offers the ability to vary the behavior of forms based on the form type and how the form is saved, using JavaScript. In this blog post, we cover how we can make use of this flexibility offered by the platform to deliver unique solutions for end users.

Summary of the key syntax

Here is a high-level summary of the main Microsoft Dynamics 365 JavaScript syntax covered in this blog post.

  • Getting the type of form:
    formContext.ui.getFormType();
  • Hide a tab on a form (where “TabName” represents the name of the tab you would like to hide):
    formContext.ui.tabs.get("TabName").setVisible(false);
  • Get the object with methods to manage the Save event:
    executionContext.getEventArgs();
  • Get the form Save Mode:
    executionContext.getEventArgs().getSaveMode();
  • Inhibit the default save behavior on a form
    executionContext.getEventArgs().preventDefault();
  • Check if the default save behavior was inhibited
    executionContext.getEventArgs().isDefaultPrevented();
  • Get the form context
    executionContext.getFormContext();

Form Type

To get the Form Type, you use the following JavaScript code:

formContext.ui.getFormType();

Here are the different Dynamics 365 form types and their respective JavaScript return values:

Form type Return Value
Undefined0
Create1
Update2
Read Only3
Disabled4
Bulk Edit6

Application Example: Varying form behavior on Form Type

In this application example, we will hide the Products and Services tab on the Create type form (with JavaScript Return Value = 1). However, it will be still be visible on all other applicable form types. This prevents users from adding information to the Products and Services tab before a Contact record has been created and saved. Therefore, the user must first create the Contact record (using the Create form type) and after the record has been created, the users will be presented with the Update form type (with JavaScript Return Value = 2) and will be able to access the Products and Services tab as well as its contents.

The Contact entity’s create form type will look similar to this (i.e. the Products and Services tab is hidden):
Contact - Create form type

In contrast, the Update form type still shows the Products and Services tab.
Contact - Update form type

Here is the code to executes the requirement above.

//Hide Products and Services tab on Create form 
function HideProductsServicesTab(executionContext) {   
  //Get form context   
  var formContext = executionContext.getFormContext();   
  //Get form type   
  var formType = formContext.ui.getFormType();   
  //If formtype is Create, hide Products and Services tab on form     
  if (formType == 1) {
    formContext.ui.tabs.get("productsandservices").setVisible(false);   
  }   
  //To see the form type return value in your browser console
  console.log("Form type = " + formType); 
}

Save Mode

To get the form’s Save Mode, you use the following JavaScript code:

executionContext.getEventArgs().getSaveMode();

Here are Dynamics 365’s different Save Modes and their respective JavaScript return values as well as the applicable entities.

Entity Save Mode Return Value
AllSave1
AllSave and Close2
AllDeactivate5
AllReactivate6
EmailSend7
LeadDisqualify15
LeadQualify16
User or Team owned entitiesAssign47
ActivitiesSave as Completed58
AllSave and New59
AllAuto Save70

Application Example: Varying form behavior on Save Mode

Here is an example of how you can vary the form’s behavior on the Save Mode.

//Inhibit auto save functionality on a form
function InhibitAutoSave(executionContext) {
  var eventArgs = executionContext.getEventArgs();
  //To see the Save Mode return value in your browser console
  console.log("Save Mode = " + eventArgs.getSaveMode());
  //If save mode is 'Save and Close' or 'Auto Save', inhibit default behavior i.e. save 
  if (eventArgs.getSaveMode() == 2 || eventArgs.getSaveMode() == 70) {
    eventArgs.preventDefault(); 
  } 
  //To see if the auto save behavior was prevented in your browser console
  console.log("Default behaviour prevented: " + eventArgs.isDefaultPrevented());
 }

If you have some unsaved changes on a form, the code above inhibits the regular form auto save behavior as well as inhibits the regular Save and Close auto save behavior, that you ordinarily get when you navigate away from from a form with unsaved changes. Instead of auto-saving (i.e. the default behavior), if you try to navigate away from a form with an unsaved changes, the JavaScript code above will block the auto save behavior and offer you the pop up notification below. If you choose “OK”, you will loose all your unsaved changes, and if you choose “Cancel”, you will remain the same form. With the default auto save behavior inhibited, users have to manually save the form, by clicking on the Save button or using the keyboard shortcut: “Control + S”.
Auto Save Inhibited: Do you want to loose your changes?

What if you want to inhibit the auto-save behavior throughout your Dynamics 365 organization (i.e. disable auto-save on all forms), instead of a specific form? It would be inefficient to implement the JavaScript code above on all forms across all your Dynamics 365 organization entities. An efficient way execute such a requirement (i.e. on all forms) is to:

  1. Go to Settings > Administration.
  2. Click on System Settings.
  3. Click on the General tab
  4. Set the Enable auto save on all forms option, to No.
  5. Click OK, in the footer of the window.

Disabling Auto Save in a Dynamics 365 Organization

Microsoft Dynamics 365: How to Set Up a Free Online Trial Version

For organizations seeking a comprehensive, robust and extendable customer relationship management platform, it is worth considering the Microsoft Dynamics 365 platform. In this post, we will cover a quick case for considering Microsoft Dynamics 365 for your customer relationship management and provide a guide on how set up a free Dynamics 365 Online 30 day Trial Version.

A Quick Case for Microsoft Dynamics 365

Why should you choose Microsoft Dynamics 365 over other customer relationship management platforms? Here are 6 reasons to choose Microsoft Dynamics 365 over its competitors:

  • Familiar, intuitive and easy to adopt user interface: If an organization is familiar with the Microsoft Office suite, it is easy to adopt the Microsoft Dynamics 365 user interface, as they are designed by the same organization. You can spend less on change management.
  • Integration with the Microsoft ecosystem: You can easily integrate Microsoft Dynamics 365 with the rest of the Microsoft ecosystem like Outlook, Office 365 (Word, Excel, PowerPoint, Outlook, etc), Windows Server, Exchange Server, Skype for Business, SharePoint, Power BI, and PowerApps.
  • Powerful analytics, social sales and embedded intelligence features like LinkedIn Sales Navigator Application Platform and Relationship Assistant, to enhance productivity, efficiency and effectiveness.
  • Flexible and extendable architecture, deployment options, and pricing, making it easy for an organization to customize Dynamics 365 to its specific requirements and only pay for its unique needs.
  • Detailed, flexible and seamless security model: Dynamics allows you to control who can access general sections and specific areas like fields. Users only see areas they have been granted access to.
  • Microsoft’s commitment to the product quality and innovation as well as partner support: Microsoft is committed to quality and regularly releases updates, continuously innovating and improving the product. Also, Microsoft has a global network of partners to support clients across the world.

Setting up a Microsoft Dynamics 365 Free Online Trial Version

Are you convinced about Microsoft Dynamics 365? If you are, and ready to take it to the next level, here are the steps you need to set up a Microsoft Dynamics 365 online trial version:

Step 1: Go to the Microsoft Dynamics 365 product home page.
Dynamics 365 product home page

Step 2: Click on “Schedule a demo”.
Click on "Schedule a demo"

Step 3: Click on “Sign up for a free trial”.
Sign up for a free trial

Step 4: Click on “Sign up here”.
Click on "Sign up here"

Step 5: On the pop-up, if you are not a Microsoft employee or partner organization, click on “No, continue signing up”.
If you are not a Microsoft employee or partner organization, click on "No, continue signing up"

Step 6: Enter the required information and click “Next”.
Enter the required information and click on "Next"

Step 7: Enter the required information about the Microsoft Dynamics 365 trial organization you are about to create and click on “Create my account”. Also, if you would like to hear from Microsoft or its partner in your geographical location to provide support on your Dynamics 365 journey, select the options provided below.
Click "Create my account"

Step 8: Enter your phone number for Microsoft to verify that you are not a robot. You will receive an automated text or phone call, depending on the option you select.
Enter your phone number to verify that you are not a robot

Step 9: Hooray!!! You have created your Office 365 and Dynamics 365 organizations, you will get the page below. Take note of the “Sign-in page’ and “Your user ID”, you will need this information to sign into your new organization.
You have created a D365 organization

Step 10: Go to the Microsoft Office 365 home page. If you are requested to sign in, click on “Sign in” and login using the user ID from step 9 and the password you created earlier, in step 7.
Go to Microsoft Office 365 home page and sign into the organization you created in Step 9.

Step 11: After logging in, click on the “Admin” app, to access your Office 365 organization’s administration options and configurations.
Office 365 home - select Admin app

Step 12: Adding other users to your new Office organization and Dynamics 365 organization: In the Admin app, navigate to Users >>> Active Users. You will get a page similar to the one below. Click on ‘Add a user’ to start the process of adding a new user to the Office 365 organization.
Add other users

Step 13: Enter the user’s basic information and click Next:
User's basic info

Step 14: You can add a user to your Office 365 organization without giving them access to the Dynamics 365 organization. However, if you if you want the user to be both a member of the Office 365 organization and Dynamics 365 organization, you have to grant the user a Dynamics 365 license (see the image below). You can also assign the user other product licenses from this section. Click Next.

The creator of the organization has a Global Administrator role, in Office 365, as well as System Administrator and System Customizer security roles, in Dynamics 365, giving them the rights to add users to both Office 365 and Dynamics 365.
Assign licenses

Step 15: You can also assign administration roles to the user if you wish. These settings are optional. Click Next.
Optional settings

Step 16: Review the user details. If you have happy with the setup details, click on ‘Finish adding’ to add the user to the organization.
Finish adding user

Step 17: After successfully adding the user, you will get a page similar to image below. You can add more users from this window. After you finish add users, click ‘Close’.
Successfully added user

Step 18: Back in the Admin page, in the left navigation, navigate to ‘All admin centers ‘. If you cannot see ‘All admin centers ‘ in your left navigation panel, click on ‘Show all’. In the main window, click on ‘Dynamics 365’ to access the Dynamics 365 administration center, in order to complete the set up of your Dynamics 365 organization.
All Admin Centers

Step 19: To complete your Dynamics 365 setup, select the apps you are interested in. If you are not interested in the provided apps, you can select “None of these. Don’t customize my organization” for a vanilla Dynamics of 365 organization. Click on ‘Complete Setup’.
Select the Dynamics 365 apps you are interested in.

Step 20: Depending on the app(s) you selected in the previous step, you will get a launch pad similar to this:
D365 Published Apps

Step 21: Select the Dynamics 365 app you would like to launch by clicking on it and you will get the app’s home page. Here is an example of the Dynamics 365 Customer Service app home.
D365 -Customer Service

Your brand new Dynamics 365 instance has been set up and is ready for your adventures. Feel to explore and play around with the environment. You just have entered the fascinating world of Dynamics 365. Welcome!!!