Tag: Author:Rawish

Make All fields Mandatory/Optional On Form Using Javascript

This should be a very quick blog on JavaScript helper which will let you make all fields on the form mandatory or optional. This requirement is hypothetical; I have not received any till now.

I am going to be calling below function on OnLoad event of the form based on a field value but you can very well call is on OnSave of record, or OnChange event of field.

For Dynamics CRM below v9:

function SetRequiredLevel()    
  var attributes = Xrm.Page.data.entity.attributes.get();
    for (var i in attributes) {

For Dynamics CRM v9 or above use below and make sure pass the context as first parameter ( checkbox) on the form editor while calling the function.

function SetRequiredLevel(executionContext)    
  var context = executionContext.getFormContext();
  var attributes =  context.data.entity.attributes.get();
    for (var i in attributes) {



1. If you need to check some value you can do that i.e.

If ( fieldAValue = 1)

//the above code goes here//


2. If you have to make fields optional rather then mandatory , do this:

I hope this helps!!

Quick Note: Dynamics 365 CE Limitations


I often find myself struggling to get collated information on limitations on number of different component you can create in dynamics CRM.

I researched and found below link very useful, could not re-blog hence sharing them here. full credits to the owner of this content.

Dynamics 365 CE Limitations On Technet

Limitations On Creating CRM Metdata

If you don’t find anything related to Business Process Flow & Alternate Key Limitations :

  • There can be no more than 10 activated business process flow processes per entity.
  • Each process can contain no more than 30 stages.
  • Multi-entity processes can contain no more than five entities.
  • There can be a maximum of 5 alternate key definitions for an entity

Reference : Business Process Flow Overview  & Define Alternate Keys

Please note – It is strictly applicable to Dynamics CRM 365 Online, May or May not be true for other versions.

Please feel free to comment down below if you know any other limitation on any component in dynamics CRM.


MB2-877 Field Service Exam Retiring…….

As we all know or for those who are not aware, Microsoft plans to restructure its certifications path due to which below dynamics CRM certification are going to retire:

Retiring on April 30, 2019

  • MB2-715 Microsoft Dynamics 365 customer engagement Online Deployment (originally published Feb. 24, 2017)
  • MB2-717 Microsoft Dynamics 365 for Sales (originally published Feb. 21, 2017)
  • MB2-877 Microsoft Dynamics 365 for Field Service (originally published Dec. 8, 2017)

If you have been following my blog , I have been preparing and also creating blog for MB2-877 Field Service exam. However because of this news I have stopped publishing more blogs. I might continue with these blog once we get the updated syllabus from Microsoft. 

Below blogs have been created so far:

  1. Overview
  2. Part -1 
  3. Part -2
  4. Part -3
  5. Part -4
  6. Part -5
  7. Part -6
  8. Part -7
  9. Part -8
  10. Part -9
  11. Part -10
  12. Part -11
  13. Part -12

I will restructure or create content again for this exam once we have updated exam on field service for dynamics crm.

See you soon!

Quick Fix : Mandatory Field Error Shows Schema Name Instead Of Display Name

Quick blog on how to fix the error you get when you save a record which has some required fields on the header of the form and CRM shows the schema name instead of display name like below:


it shows the error which includes specific field logical name instead of display name which might be confusing for user and doesn’t look very much user friendly. In my case its still very much understandable but sometimes people change name on the form and in that case it will be worse situation.


All you have to do is put the same field on the form which is there on the header and hide it on the form. Open the form editor > select the section > look for the field and add it. Go to field properties and hide it by unchecking the visible by default box:


Save and publish all your changes and now try to save the record:


I hope this help!

Get Api Version Dynamically For WebApi Requests

In this post I will quickly cover the requirement of dynamically getting API version of dynamics CRM in JavaScript rather then hard coding it , so that in next releases your JavaScript doesn’t break. I am referring to this:


For Dynamics CRM version 8.2 or below, do this:

var apiVersion = Xrm.Page.context.getVersion();

For Dynamics CRM version 9 or above, do this:

var apiVersion = Xrm.Utility.getGlobalContext().getVersion();


It will give you an expanded version which includes minor and major versions. Now, all you have to do is crop the number to get only initial numbers such as 9.1 in this case:

var shortVersion= apiVersion.substring(3, myStr.indexOf(“.”) -1);

then finally use it in your request as:

    req.open("GET",Xrm.Utility.getGlobalContext().getClientUrl()+ "/api/data/"+shortVersion+"/systemusers

Hope this helps!

A bit About “Post” In Dynamics 365 CE

What Is It?

Do not get confused between a note & a post, They are two different things. With Posts you can get attention of other users to show some crucial information, they can be auto generated by the system or a user can manually add them. You can do a great collaboration between organisation members using posts. 

On the other hand, Notes are added by a user always and can consist of attachments (posts cannot have attachments).

How to enable post for custom entity OR how to turn on/off post for out of the box entities.

Whenever you create a custom entity a “post configuration” record is created in CRM. for out of the box entities, the post configuration already exists such as opportunity , cases etc.

For any entity (Custom or OOTB) if you have activities/notes enabled; you can have post enabled for it. but for any reason if you dont see it. Go to Settings > Activity Feeds configurations :


look for the entity, i.e in my case I would like to look for contact:


If you don’t see your entity listed here, try to look for it in the “inactive post configurations” view.  Also refresh the feeds from ribbon button, the configuration should appear:


Open the record, you have option to enable it or turn it off:


In my case for my custom entity “Loan” which I have enabled post but those were not appearing on the wall & all i was seeing is Activities and Notes:


So I followed steps mentioned above , went to Settings > Activity feeds configurations > couldn’t see the entity > clicked on refresh button and then I could see the entity and it was in inactive status:


LEARNING : For a custom entity by default the posts are in inactive status & has to enabled manually:

So I opened it,  activated it and enabled for the wall: 


Make sure you publish the related entity and then open the record, you will the post has been enabled:


That’s for this blog – I will try to cover few important features of post in dynamics CRM.


This is the 13th blog of this series, before this I have created a blog from module 3 on the topic “Implement the Schedule Assistant”  which you can check here: MB2-877 MICROSOFT DYNAMICS 365 FOR FIELD SERVICE MODULE 3 TOPIC – IMPLEMENT THE SCHEDULE ASSISTANT

In this blog we are starting with the topic – Optimize resource scheduling from module 3 “Scheduling and dispatch work orders”:


  1. Identify licensing requirements for resource scheduling add-on

    Resource Scheduling Optimization(RSO) is an add-on capability for the Dynamics 365 for Field Service application that enables you to automatically schedule work orders for the most appropriate resources, by optimizing bookings for the shortest travel time, available work hours, and many other constraints. Below licenses are required in order to use RSO.

    ⦿ Requires a valid production instance of Field Service
    ⦿ Licensed per resource you want to optimize


  2. Create optimization profiles

    Optimization is based on profiles that define what you want to optimize and how you want to optimize it       Example: Optimize currently scheduled items for the next three hours to minimize travel time.

    I would really suggest you to go through the brief article here : RSO Configuration   as I will not be able to perform these steps to show you how its done. It requires a valid field service license. So we will need to just understand the concept!


  3. Define objectives and constraints 

    When setting up RSO , you will have objectives and constraints that needs defining.  Objectives are nothing but your primary goal i.e what you want to achieve using RSO, while constraints are boundaries you apply to your goal.

    Objectives can be:

    Maximize total working hours: The version of the engine results (iteration) with the total highest aggregate work time will win this objective.
    Minimize total travel time: The version of the engine results (iteration) with the total lowest aggregate travel time will win this objective.
    Locked Booking: The engine will try and schedule the iteration/scenario that successfully creates/assigns the most “Locked” schedules to appropriate resources.
    High priority Requirement: The fitness function will evaluate this objective, and will give priority to the solutions with the highest score for priority.

    Constraints can be:

    Schedule Within Working Hours: Verifies that the task is not scheduled out side of the resource’s working hours.
    Meets Required Characteristics: Verifies the resource meets all the required skills needed to complete the work.
    Locked to Resource: If marked, Resource Scheduling Optimization will not change any locked resources in the booking requirement.
    Scheduling Windows: If marked, Resource Scheduling Optimization will not change any locked scheduling windows in the booking requirement.
    Restricted Resources: If marked, Resource Scheduling Optimization will check resource preference to see if it’s “restricted”. If the requirement has a restricted resource in which there is no expiration, or expiration in the past, Resource Scheduling Optimization will not schedule this resource for this booking requirement.

  4. Configure resource optmization
    You can configure resource optimization, which majorly covers three points, When  RSO will run, What RSO will optimize & How booking will be optimized.


We could not do much  handson on this topic due to the limitation of having a paid field service trial but will try/focus on as much as handson on other topics. see you in the next blog!


This is the 12th blog of this series, before this I have created last blog from module 3 on the topic “Implement the Schedule Board”  which you can check here: MB2-877 MICROSOFT DYNAMICS 365 FOR FIELD SERVICE MODULE 3 TOPIC – IMPLEMENT THE SCHEDULE BOARD

In this blog we are starting with the topic – Implement the Schedule Assistant from module 3 “Scheduling and dispatch work orders”:


  1. Apply constraints to resource queries  & Filter data
    Using scheduling assistant you can apply below constraints resource query, Scheduling assistant really helps to find the right resource for your work order by allowing you to enter filters like Duration , Radius within which you need a resource , Start and End time , Territory , Resource type etc.

    To schedule a work order using scheduling assistant, go to a work order which needs scheduling and click on “Book” from the ribbon command bar and you will be presented below. Based on your criteria you get resource > select the resource and click on book.  A resource booking will be auto created:

  2. Specify a search radius 
    You can specify/modify a default search radius for your organisation by using Resource Scheduling > Administration > Schedule Parameters


  3. Troubleshoot Schedule Assistant

    If items are not populating on the Schedule Assistant, there are few things you can try:A. Try increasing your search radius so that you get some more resources and slots.

    B. Check the work location

    C. Verify correct addressing (the addresses on various records)

    • Account
    • Work Order
    • Resource


That’s it for this, it was a really short one! I will see you in the next blog “Optimize resource scheduling”.


This is the 11th blog of this series, before this I have created last blog from module 3 on the topic “Manage Scheduling options”  which you can check here: MB2-877 MICROSOFT DYNAMICS 365 FOR FIELD SERVICE MODULE 3 TOPIC – MANAGE SCHEDULING OPTIONS

In this blog we are starting with the topic – Implement the Schedule Board from module 3 “Scheduling and dispatch work orders”:

  1. Identify features and uses of the booking requirements view
    Here are some important points regarding the requirement view which you can find below when using scheduling board:


    A. Unscheduled items are displayed at the bottom of the Schedule Board in Booking Requirements
    B. Will display all unscheduled requirements for any entity that has been enabled for the universal scheduling
    C. Predefined view for unscheduled Work Orders is included as part of the Field Service Solution
    D. Additional requirement views can be defined to provide a more customized scheduling environment

  2. Implement the integrated map feature

    A. Helps determine best resource for job based on proximity
    B. Each resource is color coded for easy identification
    C. Routes are created and updated as resources are assigned jobs


  3. Manually schedule work orders

    You can manually schedule orders – Ways to manually schedule a Work Order:

    • Drag unscheduled Work Order from list view
    • Drag unscheduled Work Order from map view
    • Blocking out a spot on the Schedule Board directly
  4. Re-assign and re-schedule work order 

    for re-assigning or re-scheduling a work order a user can simply drag and drop the work order to other placeholder ( time + resource).


  5. Move incomplete work orders

    As seen above where in we have dragged and dropped a work order to other resource and rescheduled it to a different type , you can in similar way to move incomplete orders to a future date. i.e if you notice at the end of the day an order has not completed which was scheduled to be completed today, you can schedule it for available time tomorrow.

  6. Generate driving instruction for field agents 

    with your schedule board you have option to generate driving route and email your agents or get the print outs. To do this click on the work order and click on actions > Get directions:

    then click on Directions post verifying the address and click on print or email:


  7. Create additional schedule boards

    You can create new schedule board for your organization, by default each organization has one schedule board. to click a new one , click on + button and define the properties such as default views, map settings etc:


    You can create Private or Public boards.

  8. Create web resources to define custom booking rules

    Booking rules in Dynamics 365 for Field Service allow a System Administrator to create warning or error messages that users see when creating or editing a resource booking record, based on custom conditions. For example, a booking rule could be created to warn a user when they attempt to book a work order to a resource on the schedule board that doesn’t have the skills required for the job.

    Set up booking rules to validate a booking when it is created or modified.

    1. From the main menu, click Field Service > Administration, and then choose Booking Rules.
    2. On the Active Booking Rules screen, click +New in the upper left corner.
    3. Type a Name for the new booking rule.
    4. Select a Web Resource that has been previously created by the System Administrator to contain the validation logic and warning text.
    5. Enter the Method Name.
    6. Click Save.

That’s it for this blog – I will see you in the next blog.


With the Dynamics 365 v9, you can add an auto-number attribute for any entity. Currently, you can add the attribute programmatically. There is no user interface to add this type of attribute. 

I have in my other blog showed how you can achieve this using C#(console application) : CREATE AUTO-NUMBER ATTRIBUTE IN DYNAMICS CRM 365 USING ORGANIZATION SERVICE + SIMPLE CONSOLE APPLICATION

In this blog I am going to show you how you can achieve this using a simple WebApi request, By default this blog will also help you to learn and see how you can use postman to connect with dynamics 365 online to perform certain WEBAPI operations as we will be suing postman to fire a web api request.

  1. If you don’t already have POSTMAN, download desktop application here it here : POSTMAN Desktop Client  or simply add a chrome extension : Chrome Extension . In my case I am using a chrome extension. Launch the application and select Action as “POST”:

  2. Enter below URL in the next url section:
    Enter the correct organization url and entity logical name on which you need to create an auto number field.

  3. Now click on “Headers” and add below:
  4. Now click on “Body” tab and select “raw” option:
  5. Enter below Json request in the editor:
 "AttributeType": "String",
 "AttributeTypeName": {
  "Value": "StringType"
 "Description": {
  "@odata.type": "Microsoft.Dynamics.CRM.Label",
  "LocalizedLabels": [
    "@odata.type": "Microsoft.Dynamics.CRM.LocalizedLabel",
    "Label": "Serial Number of the widget.",
    "LanguageCode": 1033
 "DisplayName": {
  "@odata.type": "Microsoft.Dynamics.CRM.Label",
  "LocalizedLabels": [
    "@odata.type": "Microsoft.Dynamics.CRM.LocalizedLabel",
    "Label": "Serial Number",
    "LanguageCode": 1033
 "RequiredLevel": {
  "Value": "None",
  "CanBeChanged": true,
  "ManagedPropertyLogicalName": "canmodifyrequirementlevelsettings"
 "SchemaName": "new_AutoNumber",
 "AutoNumberFormat": "WID-{SEQNUM:5}-{RANDSTRING:6}-{DATETIMEUTC:yyyyMMddhhmmss}",
 "@odata.type": "Microsoft.Dynamics.CRM.StringAttributeMetadata",
 "FormatName": {
  "Value": "Text"
 "MaxLength": 100

       6. change the “SchemaName” of the field as per your need in my case its “new_AutoNumber” and also you can change the AutoNumberFormat as we discussed in the last post : : CREATE AUTO-NUMBER ATTRIBUTE IN DYNAMICS CRM 365 USING ORGANIZATION SERVICE + SIMPLE CONSOLE APPLICATION

    7. Okay its starting to look really good. but here comes the important part how do we setup the authentication – to do this click on “Authorization” Tab and select Type as “OAuth 2.0”:

    8. When you select Type as “OAuth 2.0” you have option to “Generate Access Token”


    9.Click on Generate New Access Token:

    10. Enter Details as below : 

      Token Name : Desires Name i.e dynamics crm Online

      AuthURLhttps://login.windows.net/common/oauth2/authorize?resource=%5Byour dynamics crm plain URL i,e https://passion4dynamicscrm.crm8.dynamics.com%5D

     Access Token URL : https://login.microsoftonline.com/common/oauth2/token 

     Client ID : follow this blog i have created to get client id of your dynamics CRM : REGISTER DYNAMICS CRM APP WITH AZURE FOR OAUTH 2.0 AUTHENTICATION

   11. Now click on Request Access token, you will be asked to login to your dynamics CRM, after successful login you will have a screen below:

     Select the token which we have setup and change “Add token to” to Header and click on “Use Token” which will add this to headers.


    13.  we are all set to execute our request , so click on “Send” , if everything was setup properly you will get success with no response:

   14. Open you dynamics CRM and navigate to Settings > Customizations > Customize the system > entity name > fields and notice the field has been created:

   15. Go ahead and put this field on the form and create some records.


   There you go! I hope this helps! Please feel free to let me know if you face any issues during this operation.