Category Archives: Blog
What is “Does not support untyped value in non-open type” ODataException in creating records in D365 CE?
One of the most common errors we come across while calling API to create records in Dynamics but isn’t clear what it means? One such issue is – “An error occurred while validating input parameters: Microsoft.OData.ODataException: Does not support untyped value in non-open type.” On the console of the browser, you’ll see this – But, if you open the <objectName>.responseText of the Failure message of the call, you’ll see the below – A more zoomed view of the error would be below – This is because of my typo in the code [Which is the case for most scenarios] where you mistype a name of the field and neither does the error itself doesn’t specify which field you’re missing out on nor what it means! Reason This is because of a simple typo in one of the fields in the object I was creating using AJAX In my case, this should have been “entity.duration” and not “entity.durationn“. It was a simple issue which led me wander troubleshooting in areas which I shouldn’t look into. Hope this saves you some valuable time! Happy 365ing!
Share Story :
Post Entity and its Relationship with Lead Entity
Problem Statement: We have a recent requirement, where we had to make an SSRS report that will display the latest post against a Lead. Post as an Entity is not visible in customization, also in advance find of Lead, we do not have any related attributes from post. This makes it difficult to generate the query. Solution: When we check the relationship between lead and POST, we find the below The entity named Post regarding is not present in customization and neither is visible in Advanced Find. If we check the advanced find for posts, we will not find any field that is providing related details of lead. But if we go to edit columns and check the available columns, we will get a column named regarding. We can use the below XML Query to generate our SSRS Report. Conclusion: Some entities like POST,POST regarding and their attributes are hidden in CRM. Metadata Document Generator in XRM Toolbox can be used to view these hidden entities and fields. You can refer my blog Find hidden entities in CRM using metadata document generator from XRM Toolbox to know how to use Metadata Document Generator in XRM Toolbox.
Share Story :
How to use Expand Query in MS Flows
Introduction This blog explains how to use Expand Query (N:1 Relationship) in the Common Data Service List Records Connector. Steps to be followed: Initialize Variable of type string. Using Expand in list RecordsExpand Query: cf_Project($select=cf_projectname,cf_projectabbreviation) Here cf_Project is the Schema Name of Project Lookup field on location entity. Pass the field names of the project entity that you want. Here I have passed cf_projectname and cf_projectabbreviation. Result of list record: You can see we get Project value in the below format to use this we have to parse the JSON. “cf_Project”: “{\r\n \”cf_projectname\”: \”Client Commercial\”,\r\n \”cf_projectabbreviation\”: \”CC\”,\r\n \”cf_pmtrackerid\”: \”3b576605-9c82-e911-a839-000d3a07f695\”\r\n}” Retrieving Project Values. Use “Apply to each” to get the value of the Project. Pass “Value” of “List Records” from Dynamic Content in “Select an output from previous steps” Now Set the Value in the “Project” variable which we had initialized earlier. Go To Expression and type: items(‘Apply_to_each’)[‘cf_Project’] Note: Here “cf_Project” is what we had retrieved in the output of ‘list records’. Make sure you pass this value correctly. “cf_Project“: “{\r\n \”cf_projectname\”: \”Client Commercial\”,\r\n \”cf_projectabbreviation\”: \”CC\”,\r\n \”cf_pmtrackerid\”: \”3b576605-9c82-e911-a839-000d3a07f695\”\r\n}” Result of Project Variable: Parsing JSON. Use “Parse JSON” action Add “Project Variable” in Content from “Dynamic Content” Click on “Generate from sample” to generate JSON Schema Enter sample JSON payload and click on done. { “cf_projectname”: “Test Project”, “cf_projectabbreviation”: “TR”, “cf_pmtrackerid”: “3b576605-9c82-e911-a839-000d3a07f695” } It will generate a JSON Schema automatically. Using Project Values. After parsing Json successfully you can use the values of the project entity field. You can use “Compose” to get and check the value. Enter “cf_projectname” in “Compose” inputs. OutputEntire FLOW: NOTE: You can add multiple expand queries in List Record:Query: cf_Project($select=cf_projectname,cf_projectabbreviation),cf_ParentLocationId($select=cf_name)
Share Story :
Send an e-mail to any audience when Power BI data alert is triggered
In this blog I am going to explain you how to send an e-mail to any audience when a Power BI data alert is triggered. Step 1: Create a sample of Power BI report using visuals like gauge, KPI or card title. Step 2: Publish your Power BI report on app.powerbi.com site. Step 3: Pin individual visuals like gauge, KPI or card title. Step 4: Go to dashboard page, select chart and click on ellipsis Step 5: Click on Manage alerts, click on Add alert rule Here you can set the threshold condition and based on above and below amount. Also set maximum notification frequency either at most every 24 hours or at most once an hour. Step 5: Login to https://flow.microsoft.com/ Step 6: Create a Templates “Send an e-mail to any audience when a power BI data alert Is triggered” After clicking on continue button Set Alert Id that have been created on manage alert in Power BI. Click on Save button. Step 7: Whenever data changes on Power BI dataset and alert rule condition satisfied this Power Automate flow is triggered and send mail to target audiences. I hope this will help you.
Share Story :
Conversion of Time and Date in MS flow
Introduction We had a requirement where we wanted to create a price list with current date time with respect to current country. In this blog we will use the OOB date conversion functionality. Use Case : (UTC with ) We created a flow where we had used UTC now functionality but this was returning the value time value with -5.30 hours. After doing RND I come to know that it automatically adjust the time using our time zone. As you can see in the below screen shot. Solution: To over come with this issue we need to use the inbuilt functionality convertTimeZone. It takes below parameter Sr No Parameters Example Explanation 1. <timestamp> Utcnow() It is a string or function which contains the timestamp 2. <sourceTimeZone> UTC The name for source time zone . We can write source time zone which we want to convert into 3. <destinationTimeZone> India Standard Time The name for the target/destination time zone. In this case we want to convert UTC into India Standard Time. So the India Standard Time is a destination TimeZone 4. <format> dd/MM/yyyy HH:mm Its a format in this case we wanted to convert into date and time dd/MM/yyyy HH:mm As you can see in the below screen i have converted UTC to India time zone. convertTimeZone(utcnow(),’UTC’,’India Standard Time’,’dd/MM/yyyy HH:mm’) Result: As you can see in the below screen shot it shows the date time in the mentioned format or you can say indian format. Conclusion: Hope this will help you to over come the time zone issue while working with different country time. For more Time Zone conversion refer : https://docs.microsoft.com/en-us/previous-versions/windows/embedded/gg154758(v=winembedded.80)?redirectedfrom=MSDN
Share Story :
Share Records in D365 CRM by Code
Introduction: This blog details steps how to share entity record in D365 CRM by Code. Scenario: We have client requirement to share record with multiple set of Users in D365 CRM based on criteria selected by User on Form and needed to be automated. Implementation Step: Below code to be developed for OnCreate of record. Create new method ShareRecords private static void ShareRecords(IOrganizationService service, Entity entity, Entity segmentUser) { var CreatedReference = new EntityReference(“systemuser”, segmentUser.Id); var grantAccessRequest = new GrantAccessRequest { PrincipalAccess = new PrincipalAccess { AccessMask = AccessRights.ReadAccess | AccessRights.WriteAccess | AccessRights.AppendToAccess, Principal = CreatedReference }, Target = new EntityReference(entity.LogicalName, entity.Id) }; service.Execute(grantAccessRequest); } Retrieve User List of Users and execute ShareRecords method EntityCollection segmentUsers = service.RetrieveMultiple(new FetchExpression(fetchXMLUsers)); foreach(Entity segmentUser in segmentUsers.Entities) { ShareRecords(service, entity, segmentUser); } Below code to be developed for OnUpdate of record. Create new method UnShareRecords private static void UnShareRecords(IOrganizationService service, Entity entity, Entity segmentUser) { var CreatedReference = new EntityReference(“systemuser”, segmentUser.Id); var revokeUserAccessReq = new RevokeAccessRequest { Revokee = CreatedReference, Target = entity.ToEntityReference() }; service.Execute(revokeUserAccessReq); } Retrieve existing shared Users and remove there Access private static void RetrieveSharedUsers(IOrganizationService service, EntityReference entityRef) { var accessRequest = new RetrieveSharedPrincipalsAndAccessRequest { Target = entityRef }; var accessResponse = (RetrieveSharedPrincipalsAndAccessResponse) service.Execute(accessRequest); foreach(PrincipalAccess principalAccess in accessResponse.PrincipalAccesses) { EntityReference prAcc = principalAccess.Principal; Entity entity = new Entity(entityRef.LogicalName, entityRef.Id); Entity segmentUser = new Entity(prAcc.LogicalName, prAcc.Id); UnShareRecords(service, entity, segmentUser); } } Implement code for ShareRecords explained in step 1 & step 2. Conclusion: Hope this blog helps you to to share and unshare records by code in D365 CRM based on custom criteria data on record dynamically.
Share Story :
Add effects to Power BI Buttons
Hello Friends, in this blog we will see how to add effects to Power BI buttons. Steps: Open Power BI desktop and select blank button from ribbon. Now add a rectangular strip to your button to look more attractive with the following configuration. Now add another button with transparency 50 % in default state just to create the feel of not focused state. Make sure to turn off background. Add hover state configuration for fill property of newly added button. Place the button on your old button. Final button will look like this. You can add click state for button Hope this helps.
Share Story :
Calculated Field in Dynamic 365 CE
Introduction In this blog we will see how to use Calculated field. Use Case : Its common requirement of Project to set calculated date to specific date field by adding or Subtracting the no. of days. Implementation : Step 1: Let say we have date field in an Account Entity. Step 2: Create one more date field with data type as date with field type as calculated field. Select field type -> Calculated -> Edit Step 3: Click on Edit. and add condition. In this scenario , I want to add 3 days to the selected date which is date created field. So the condition is if current entity date created field contains data And then add action. Save and close Result :
Share Story :
Order fulfillment notifications in Dynamics 365 Retail (Commerce)
The order fulfillment operation in the point of sale provides a single work area in the point of sale that can be used to process orders. This includes everything from accepting the order, to marking it as shipped, or initiating store pickup. In my case we wanted a notification to appear on POS whenever a customer order is created. This is useful in a situation where the goods are stored in the store room and you want the store room person to be notified about a new order creation. This will enable him to start preparing the goods as soon as the order is created in POS. Which will be picked up by the customer later. For this to work, the front desk store worker and and the store room worker both need to have POS registers. The following setup needs to be done at HQ to enable this functionality Add order fulfillment button on POS, Enable live content on button Enable notifications for an operation Set up a notification interval Update the POS permission1. Add order fulfillment button on POS, Enable live content on button 2. Enable notifications for an operation Go to Retail > Channel setup > POS setup > POS > Operations. Search for the Order fulfillment operation, and select the Enable notifications 3. Set up a notification interval Go to Retail > Channel setup > POS setup > POS profiles > Functionality profiles. In the Notification interval field, specify how often notifications should be pulled. 4. Update the POS permission Go to Retail > Employees > Workers >, under Retail tab, open the POS permissions associated with the worker. Expand the Notifications FastTab, add the Order fulfillment operation, and set the Display order field to 1. After the setup please run staff and and channel configuration jobs and you are all set. Activate/relaunch the POS On POS create a customer order and select Pick up from store option. Once the order has been created, it would appear in the notification window depending on the refresh interval Now click on order fulfillment button, you will see all the orders. They would be in the accepted state by default. Now you can mark it as Pick, Pack to process the order. If the order needs to be shipped, you will have to click on Ship and then process it Hope this helps!
Share Story :
Convert Email Body from HTML format to Text
Introduction: We had a requirement , wherein when an Email is received a Case will be created in CRM and the body of the email will be set the description of the case. However we faced a problem because the Email body was in HTML format so we have to convert it and set it as the description. Solution: We have to write a plugin in which just take the HTML part of the email and eliminate every HTML tags so that we can get the Text part of the body. Steps: Register the plugin in PostOperation PipeLine Stage and in Asynchronous Mode. First, get the body of Email in a String variable and call the function. string description = currentRecord.GetAttributeValue<string>(Email.ATTR_DESCRIPTION); string actualDescription = StripHTML(description); 3.Then write a function to convert all the HTML Tags in the following way. private static string StripHTML(string source) { try { string result; // Remove HTML Development formatting // Replace line breaks with space // because browsers inserts space result = source.Replace(“\r”, ” “); // Replace line breaks with space // because browsers inserts space result = result.Replace(“\n”, ” “); // Remove step-formatting result = result.Replace(“\t”, string.Empty); // Remove repeating spaces because browsers ignore them result = System.Text.RegularExpressions.Regex.Replace(result, @”( )+”, ” “); // Remove the header (prepare first by clearing attributes) result = System.Text.RegularExpressions.Regex.Replace(result, @”<( )*head([^>])*>”, “<head>”, System.Text.RegularExpressions.RegexOptions.IgnoreCase); result = System.Text.RegularExpressions.Regex.Replace(result, @”(<( )*(/)( )*head( )*>)”, “</head>”,System.Text.RegularExpressions.RegexOptions.IgnoreCase); result = System.Text.RegularExpressions.Regex.Replace(result,”(<head>).*(</head>)”, string.Empty,System.Text.RegularExpressions.RegexOptions.IgnoreCase); // remove all scripts (prepare first by clearing attributes) result = System.Text.RegularExpressions.Regex.Replace(result,@”<( )*script([^>])*>”, “<script>”,System.Text.RegularExpressions.RegexOptions.IgnoreCase); result = System.Text.RegularExpressions.Regex.Replace(result,@”(<( )*(/)( )*script( )*>)”, “</script>”,System.Text.RegularExpressions.RegexOptions.IgnoreCase); //result = System.Text.RegularExpressions.Regex.Replace(result, //@”(<script>)([^(<script>\.</script>)])*(</script>)”, //string.Empty, // System.Text.RegularExpressions.RegexOptions.IgnoreCase); result = System.Text.RegularExpressions.Regex.Replace(result,@”(<script>).*(</script>)”, string.Empty,System.Text.RegularExpressions.RegexOptions.IgnoreCase); // remove all styles (prepare first by clearing attributes) result = System.Text.RegularExpressions.Regex.Replace(result, @”<( )*style([^>])*>”, “<style>”,System.Text.RegularExpressions.RegexOptions.IgnoreCase); result = System.Text.RegularExpressions.Regex.Replace(result,@”(<( )*(/)( )*style( )*>)”, “</style>”,System.Text.RegularExpressions.RegexOptions.IgnoreCase); result = System.Text.RegularExpressions.Regex.Replace(result,”(<style>).*(</style>)”, string.Empty,System.Text.RegularExpressions.RegexOptions.IgnoreCase); // insert tabs in spaces of <td> tags result = System.Text.RegularExpressions.Regex.Replace(result,@”<( )*td([^>])*>”, “\t”,System.Text.RegularExpressions.RegexOptions.IgnoreCase); // insert line breaks in places of <BR> and <LI> tags result = System.Text.RegularExpressions.Regex.Replace(result,@”<( )*br( )*>”, “\r”,System.Text.RegularExpressions.RegexOptions.IgnoreCase); result = System.Text.RegularExpressions.Regex.Replace(result, @”<( )*li( )*>”, “\r”,System.Text.RegularExpressions.RegexOptions.IgnoreCase); // insert line paragraphs (double line breaks) in place // if <P>, <DIV> and <TR> tags result = System.Text.RegularExpressions.Regex.Replace(result,@”<( )*div([^>])*>”, “\r\r”,System.Text.RegularExpressions.RegexOptions.IgnoreCase); result = System.Text.RegularExpressions.Regex.Replace(result,@”<( )*tr([^>])*>”, “\r\r”,System.Text.RegularExpressions.RegexOptions.IgnoreCase); result = System.Text.RegularExpressions.Regex.Replace(result,@”<( )*p([^>])*>”, “\r\r”,System.Text.RegularExpressions.RegexOptions.IgnoreCase); // Remove remaining tags like <a>, links, images, // comments etc – anything that’s enclosed inside < > result = System.Text.RegularExpressions.Regex.Replace(result,@”<[^>]*>”, string.Empty,System.Text.RegularExpressions.RegexOptions.IgnoreCase); // replace special characters: result = System.Text.RegularExpressions.Regex.Replace(result, @” “, ” “,System.Text.RegularExpressions.RegexOptions.IgnoreCase); result = System.Text.RegularExpressions.Regex.Replace(result,@”•”, ” * “,System.Text.RegularExpressions.RegexOptions.IgnoreCase); result = System.Text.RegularExpressions.Regex.Replace(result,@”‹”, “<“,System.Text.RegularExpressions.RegexOptions.IgnoreCase); result = System.Text.RegularExpressions.Regex.Replace(result,@”›”, “>”,System.Text.RegularExpressions.RegexOptions.IgnoreCase); result = System.Text.RegularExpressions.Regex.Replace(result,@”™”, “(tm)”,System.Text.RegularExpressions.RegexOptions.IgnoreCase); result = System.Text.RegularExpressions.Regex.Replace(result, @”⁄”, “/”,System.Text.RegularExpressions.RegexOptions.IgnoreCase); result = System.Text.RegularExpressions.Regex.Replace(result,@”<”, “<“,System.Text.RegularExpressions.RegexOptions.IgnoreCase); result = System.Text.RegularExpressions.Regex.Replace(result,@”>”, “>”,System.Text.RegularExpressions.RegexOptions.IgnoreCase); result = System.Text.RegularExpressions.Regex.Replace(result,@”©”, “(c)”,System.Text.RegularExpressions.RegexOptions.IgnoreCase); result = System.Text.RegularExpressions.Regex.Replace(result,@”®”, “(r)”,System.Text.RegularExpressions.RegexOptions.IgnoreCase); // Remove all others. result = System.Text.RegularExpressions.Regex.Replace(result,@”&(.{2,6});”, string.Empty,System.Text.RegularExpressions.RegexOptions.IgnoreCase); // for testing // System.Text.RegularExpressions.Regex.Replace(result, //this.txtRegex.Text,string.Empty, // System.Text.RegularExpressions.RegexOptions.IgnoreCase); // make line breaking consistent result = result.Replace(“\n”, “\r”); // Remove extra line breaks and tabs: // replace over 2 breaks with 2 and over 4 tabs with 4. // Prepare first to remove any whitespaces in between // the escaped characters and remove redundant tabs in between line breaks result = System.Text.RegularExpressions.Regex.Replace(result,”(\r)( )+(\r)”, “\r\r”,System.Text.RegularExpressions.RegexOptions.IgnoreCase); result = System.Text.RegularExpressions.Regex.Replace(result, “(\t)( )+(\t)”, “\t\t”,System.Text.RegularExpressions.RegexOptions.IgnoreCase); result = System.Text.RegularExpressions.Regex.Replace(result,”(\t)( )+(\r)”, “\t\r”,System.Text.RegularExpressions.RegexOptions.IgnoreCase); result = System.Text.RegularExpressions.Regex.Replace(result, “(\r)( )+(\t)”, “\r\t”,System.Text.RegularExpressions.RegexOptions.IgnoreCase); // Remove redundant tabs result = System.Text.RegularExpressions.Regex.Replace(result,”(\r)(\t)+(\r)”, “\r\r”,System.Text.RegularExpressions.RegexOptions.IgnoreCase); // Remove multiple tabs following a line break with just one tab result = System.Text.RegularExpressions.Regex.Replace(result,”(\r)(\t)+”, “\r\t”,System.Text.RegularExpressions.RegexOptions.IgnoreCase); // Initial replacement target string for line breaks string breaks = “\r\r\r”; // Initial replacement target string for tabs string tabs = “\t\t\t\t\t”; for (int index = 0; index < result.Length; index++) { result = result.Replace(breaks, “\r\r”); result = result.Replace(tabs, “\t\t\t\t”); breaks = breaks + “\r”; tabs = tabs + “\t”; } // That’s it. return result; } catch { //MessageBox.Show(“Error”); return source; } } 4. This is the Output. This is the Test Email that is been send to test. This is the email that is received in the Dynamics 365 CRM. This is the Case which is created. The description of the Case is the same as the Email