Dynamics CRM Archives - Page 8 of 16 - - Page 8

Category Archives: Dynamics CRM

Change Business Process Flow Based on Form Type Using Java Script.

There are situations where you might need different business process flows based on the form type you choose let us take an example. Consider you want a Business Process flow on the lead entity Such that Lead form will show –BPF with stage Discover, Demo, Propose Sales Lead form will show – BPF with stage Discover, Requirement Gathering, Qualify The case be achieved by doing the following. Lets begin with the implementation. Solution – Step 1: Make a Solution for your customizations and add the lead entity in your solution. Step 2: Make 2 main forms for the lead entity namely “Lead form” and “Sales Lead form” Step 3: Go to process – > Add a new process -> names It Lead creation. Step 4: In the same solution under lead entity add a field of type single line of text namely “Form Type”. Step 5: Add this new field on the lead form and the sales lead form. Note : This field will carry the form type of the form hence will be kept hidden and locked on both the forms. Step 6 : Next step is to get the form type in our form type field to achieve this we will use a web resource that      is a java script code Step 7 : By doing so we successfully bring the form type written in our single line of text field. Step 8 : Next step is to create a business process flow in the solution go to process and make a new business process flow. Step 9 : The above snapshot shows the business process flow to achieve the functionality here the create stage we take the form type as a parameter this is then passed to the condition to check the form type Step 10 : So, if the form type is Lead form it will be true and take business process flow for lead form. Step 11 : Else it will be false and will take the business process flow for the sales lead form. Note: – Make sure to add the business process flow as an entity to the solution and select the form and the business process flow in the site map of the app designer. Java Script code : (Onload of the Form) ChangeBPFByType = (executionContext) => {     debugger;     try {         let formContext = executionContext.getFormContext();         const selectedFormName = formContext.ui.formSelector.getCurrentItem().getLabel();         const getFormIdFromTxtBox = formContext.getAttribute(“cfs_formtype”).getValue();         //formContext.getControl(“header_process_cf_leadform”).setVisible(false);         if (formContext.data.entity.getId() == “”) {             formContext.getAttribute(“cfs_formtype”).setValue(selectedFormName);         }         else {             var getAllForms = formContext.ui.formSelector.items.get();             let navigateFormGuid = “”;             for (var i = 0; i < getAllForms.length; i++) {                 if (getFormIdFromTxtBox == getAllForms[i]._label) {                     navigateFormGuid = getAllForms[i]._id.guid;                     break;                 }             }             if (getFormIdFromTxtBox != selectedFormName) {                 formContext.ui.formSelector.items.get(navigateFormGuid).navigate();             }         }     } catch (e) {         alert(“Something went wrong please try again later”);     } } Hope that helps.!

Share Story :

Change ‘Lookup For’ in Party list Using JavaScript

Introduction: Party list like “TO” usually contain record of type Accounts, Contacts, Knowledge Articles, Leads, Users If you want to restrict the Lookup values, write the below script on load on the form and also on change of the partly list Here for each value in fieldlist, the lookup for will be set to account. This is not applicable to “FROM” as it has OOB restrictions.

Share Story :

Disable field on Click of Button in D365 CE using JavaScript.

Use Case – One of my requirements is to disable the field on click of button Reopen Project on Project form. Let’s see how we can achieve this. Solution – Create Web resource and add below function: Here my function name is “markFieldsReadOnly“. Create Solution in CRM which contains only a single entity on where we have button called “Reopen Project”. Open same solution in XRM Toolbox -> Ribbon Customization.          In Order to get form Context from Ribbon, Pass CRM Parameter – Primary Control  Select Library which is your web resource and add Function Name and publish. Hope this helps!

Share Story :

Let’s get started with Azure Function for Dynamics 365 CRM: Part 1

In this blog, we will learn how to create an Azure Function App to connect it with Dynamics 365 CRM and perform the CRUD operation in Dynamics 365 CRM. First, we will create an Azure Function project for Dynamics 365 CRM from Visual Studio, and below are the steps for the same. Open Visual Studio and create a new Azure Function Project. Filter platform as Azure, select Azure Function, and click on Next. Name your project and click on Create button. After clicking on Create, you will get the below screen where you need to select the Trigger and Azure Function v1 (.Net Framework) and click on Create. In my case, the Azure Function trigger will be Http Trigger which means when an azure function will receive an HTTP request it will trigger. Your Azure Project will be created and the following will be the structure of the project. Now, we will create Azure Function to connect with the Dynamics 365 CRM we need to add the required NuGet Package [Microsoft.CrmSdk.CoreAssemblies]. To add the NuGet Package right-click on the Project and click on Manage Nuget packages. Add Microsoft.CrmSdk.CoreAssemblies in your Project. Following is the code to connect the Dynamics 365 CRM. Currently, we are going to use the credential by specifying them in the C# Code or you can use it as constant. Later in the series, we will learn how to use Environment Variable and pass the credential more secure way in Azure Function using Azure Key Vault. [Stay tuned..!!] Now, select the code and Refactor the code and make the connection function that will return the IOrganizationService if the connection is established else return null. Now, the final code will be as below: Now, we will create a customer with a Hardcoded name when the function is triggered with an HTTP request. Update the existing code with the below code: Testing: We will require the API testing tool, here I am using Postman and the following is the link to download “Postman”. https://www.postman.com/downloads/ To test the application, click on the Start button on top of Navbar as mentioned below in the screenshot [Button will have Project Name]. It will take a few minutes to Load the Azure Emulator Following is the screen you will be able to see and copy the URL highlighted in the red below and paste that URL in Postman. Open the Postman and click on the create a new tab; Select request as POST and paste the URL: After pasting the URL, click on Send You will get the following response on the Azure Function Tool and Postman If there any error or issue with the Azure Function code, the request will be failed and will be displayed on both Azure Function Tool and Postman [Status will be “4**” or “5**” ] Now, we will take look at Dynamics 365 CRM environment and check whether the account is created or not. We are justing getting started with Azure Function for Dynamics 365 CRM and stay tuned for more in this series. Upcoming blogs 1. How to use Dynamics 365 Credentials securely using Azures Function. 2. How to create Dynamics 365 integration with Third-party Applications. Many more……

Share Story :

Change Currency format in D365 Customer Engagement

In this blog we will see how we can change the currency format in D365 CE. We are using the Currency field named Price on Account form and we wanted to price in XX,XX,XXX.XX format Let see how we can achieve this. Solution: Go to Settings and click on Personalization settings. After clicking on Personalization setting, In Set Personal Options click on Format. Click on Customize -> in Number, Digit group change the format as per requirement. After updating click on Apply and Ok. In our requirement, we wanted currency in XX,XX,XXX.XX  format on Account Entity. Price field Before Changing – Price field after changing –

Share Story :

Track an Entity record form opening / retrieve activity by system user in Dynamics 365 CRM

If you want to track a user who has opened records of any specific entity then you are on the right blog because today we are going to see how we can do simple customization to track the user activity of who has open which record for how many times. Step 1: Create an Entity to track the log of retrieve activity of the registered entity. Following are fields in the entity to track user activity tracking activity 1. Name — Logical name of Retrieved Entity. 2. Record Id — Record Id of that Retrieved Entity. 3. No of Time Retrieved — Stored number of times a user has retrieved that specific record. Step 2: Create a Plugin to create a Retrieved Log record The record will be created or updated whenever the user opens the entity form to check details and the following is code for the same. Explanation: 1. When the plugin will trigger it will check if the retrieved log of that record is already present or not. 2. If retrieve records is not present it will simply create a log record with the following details a. Name — Type of records which user has opened [Entity] b. Record Id — Record Id of record which user has opened c. User — which the user has opened the record. d. Count = 1 3. If the retrieved record is already existing in the system then it will increment the count of the number of times a user has retrieved that record by 1 so that we can track how many times the same user has open that specific record. Step 3: Register the Plugin on Retrieve of Entity on entities for which you want to add tracking. Retrieve: It will trigger whenever an entity form is open by any user. While registering the new step for the plugin please make sure that Run in User’s Context must be “Calling User” so that we can have a track that which user has opened which record. Note: All security roles which are given to the user should have read, create and update right to “Entity Tracker” Entity. Also, the stage of execution of Plugin and execution mode must be “PostValidation” and “Asynchronous” so that it will not affect any system jobs and it can run in the background process. If you want to track a retrieve activity of opportunity then you just need to register the new step and select Primary Entity as an opportunity as I have already done for Account and Contact. Now, your system is ready to track the user’s entity retrieve activities, and you will see the following records: Using the above record you can create any type of custom charts and put them in your admin dashboard or you can create a Power BI report to track activity. I hope this helps you, if yes please like the blog. And, the next blog will be on the dashboard & charts based on our Entity Tracker records so stay tuned for that!

Share Story :

Send Email to not resolved Email Ids from Workflow/Cloud flows

Introduction: We might have a requirement to send emails from Workflow/cloud flows to Ids that cannot be resolved as Contacts, Accounts, Users in CRM. Solution: We need to make changes to system settings to allow messages to unresolved recipients In case of Workflow, directly add email address in the field( It will show ? as it is not resolved address) For Cloud flow, in create a new email record, click on “Switch to Input entire array”, populate the email in addressused field. This will let you send emails to an unresolved email address.

Share Story :

Autosave quick create a form record on fields change and open the created record

Requirement: The user will create the record from the Quick Create and on change of specific field, the record should automatically save. Whenever the record will be saved it should open the created record. In our scenario, we are going to use the Account Entity. When the user will enter the main phone data in the Account Quick Create Form, the record will automatically save and it will open the created account record. Steps: Go to Default Solution or your customization solution and Open the Quick Create Form from Account Entity 2. Click on the Form Properties to edit the form properties of Account Quick Create Form and add the script on the form. 3. Click on the +New button to add the JavasScript web resources on the form so that you can use the script function on Form Events 4. If you wanted to use an existing Web Resource then you add it or else create new by click on new 5. Create a new Script and add it on form 6. Now, we need to add the event list and bind the calling function to it. To do it click on the + New on Event Listener of Form Properties. Note: Please don’t forget to pass the execution context as the first parameter to the function. 7. We will use formContext.data.save() function to get the created record’s GUID and open entity record using that GUID. Following is code for your reference: 8. Code Explanation: a. quickCreateonSave is a function that is trigger on change of Main phone fields of Account Quick Create. b. When the function is triggered we are using formcontext.data.save to save the save so that we can get the GUID of the recently created record. c. On formcontext.data.save() we can assign two functions — on success and failure as parameter to .then() [Reference] d. On Success, the function will return the following response where you can get the entityType, entity id, and name of the record. e. After getting the entity id and entity type, we can use the open form to open the record as mentioned in the Code. 9. Publish all the customization that you have done on the Account Entity Demo: I hope it helps you guys!!

Share Story :

Filter Regarding using JavaScript

Introduction: In this blog we will learn how to filter regarding based on another option set field. Also, we shall understand how we can set the default view for regarding. Solution: The below script will run on field change of “Type”, this is the option set based on which the regarding will be filtered. Regarding: function (execContext) { var formContext = execContext.getFormContext(); if (formContext.getAttribute(“type”).getValue() != null) { Type = formContext.getAttribute(“type”).getValue(); switch (Type) { case 1: formContext.getControl(“regardingobjectid”).setEntityTypes([“contact”]); formContext.getControl(“regardingobjectid”).setDefaultView(“{00000ABC-0000-0000-00BG-000010000147}”); break; case 2: formContext.getControl(“regardingobjectid”).setEntityTypes([“quote”]); formContext.getControl(“regardingobjectid”).setDefaultView(“{00000ABC-0000-0000-00BG-000010000147}”); break; } } } Here, the Entity Type- will be entity you want to show in regarding and default view will be the view whose id is set in this script. Output:

Share Story :

Filter and Set Default Required Attendee using JavaScript

Introduction: Here is JavaScript code that you can use to  make the required field show only system user records and also in case you have a requirement to the set the owner of record as default required attendee. Solution: Add below function to your web resource on load event. Conclusion: On load of form the Required attendee will be owner of record and we can add new attendee easily as the dropdown will show only user records. Instead of users, if you need contact records, just change the set entity type->  formContext.getControl(“requiredattendees”).setEntityTypes([“contacts”]);

Share Story :

SEARCH BLOGS:

FOLLOW CLOUDFRONTS BLOG :


Secured By miniOrange