Serializing and Deserializing Json objects with key value pairs in C#
If we have a json data whose objects have one or more key value pairs also known as properties and we need to separate them into individual objects then Serializing and Deserializing method can be used in C#. Sample Json data : { “FirstName”:”Aditya”, “MiddleName”:”Ashok”, “LastName”:”Somwanshi”, “Phone”:[“9004802526″,”34304235”], “Address”:{“Primary”:”Panvel”, “Secondary”:”Cloudfronts”} } Desired Output: { “FullName”: “Aditya Ashok Somwanshi”, “Primary Phone”: “9004802526”, “Secondary Phone”: “34304235”, “Primary Address”: “Panvel”, “Secondary Address”: “Cloudfronts” } First open Visual Studio and create new project in Console application template. Give your Project a name and click next, you will be directed to a new page where you can start with your code. Now we need to install some packages into our project to use it in our code. So at top in the tools section select NuGet Package Manager and in that select Manage Nuget Packages for Solution Now search for Newtonsoft.Json and install the package The purpose for installing this package is to access serialize and deserialize functions in our code. To add a class to main program you need to right click on your project and then select and choose add new item Select class and name the class and add. Now to write the code we need to use Convert JSON to C# Classes Online – Json2CSharp Toolkit for formatting the json to C# and knowing the classes to be used. using System.Collections.Generic; using Newtonsoft.Json; namespace Human { public class Address { public string Primary { get; set; } public string Secondary { get; set; } } public class Person { public string FirstName { get; set; } public string MiddleName { get; set; } public string LastName { get; set; } public List<string> Phone { get; set; } public Address Address { get; set; } } public class Root { public string FullName { get; set; } [JsonProperty(“Primary Phone”)] public string PrimaryPhone { get; set; } [JsonProperty(“Secondary Phone”)] public string SecondaryPhone { get; set; } [JsonProperty(“Primary Address”)] public string PrimaryAddress { get; set; } [JsonProperty(“Secondary Address”)] public string SecondaryAddress { get; set; } } } Now the main program using Newtonsoft.Json; using System; namespace Human { public class Program { public static void Main(string[] args) { string json = @”{ “”FirstName””:””Aditya””, “”MiddleName””:””Ashok””, “”LastName””:””Somwanshi””, “”Phone””:[“”9004802526″”,””34304235″”], “”Address””:{“”Primary””:””Panvel””, “”Secondary””:””Cloudfronts””} }”;//Defining Json Person human = JsonConvert.DeserializeObject<Person>(json);//Deserializing Json Root rt = new Root(); rt.FullName = human.FirstName + ” ” + human.MiddleName + ” ” + human.LastName; //Concatenating Names rt.PrimaryPhone = human.Phone[0]; rt.SecondaryPhone = human.Phone[1]; rt.PrimaryAddress = human.Address.Primary; rt.SecondaryAddress = human.Address.Secondary; string output = JsonConvert.SerializeObject(rt, Formatting.Indented);//Serializing Json Console.WriteLine(output); } } } OUTPUT:
Share Story :
Quick Tip: Language Translation on Custom PowerApps Page in Model Driven Apps
Hi Everyone, If you are using Custom Pages in your Model Driven App and would like to have multiple languages as per User’s Personal settings? Here’s a quick helpful method for Custom Pages Step 1: Let’s start by creating a Custom Page Go to PowerApps Maker Studio, in your selected environment outside or inside a solution. Add new Custom Page Step 2: Fill your app as per requirement. I’ll just keep it basic. Note: OOTB Tables/Entities will show translated values except custom text/tooltip/custom tables, etc. Below, for my custom Title Label. I have used Language() function to detect the User’s language set in Personal Settings applied on Browser Level. Step 3: Save, Add and Publish the Page on Site Map (Edit in Preview) section. Reload your Model Driven App to see the effect User’s Language set as English User’s Language set as Spanish Select Spanish in Personal Settings That’s how simple it is to set Language in your Custom Page. Note: If you are working with Custom Entities, BPFs you need to add translation for the Language in Data verse manually. Please follow the steps mentioned in this Blog: Enable language translation on Custom solutions in Dynamics CRM. Hope this helps 🙂
Share Story :
Using Live Share in VS Code
Introduction VS Code has recently introduced a new feature using which multiple people can access the same workspace in VS Code and modify files at the same time. This is huge applications in teaching, code reviews as well as prototyping. You can edit modify separate files at the same time in the same folder. Pre-requisites VS Code References Use Microsoft Live Share to collaborate with Visual Studio Code Configuration Install the Live-Share extension in VS Code. Click on the “Live Share” button at the bottom left. Sign in using your Github or Microsoft Account. You can see the session details in the “Live Share” tab along with previously connected. Click on the “Invite Participants” to get the link what can be used to share the session. Now, you can collaborate with different Users and modify the same or different files together. Conclusion Thus we saw how, we can use Live Share for collaborating while developing or reviewing in VS Code. Special thanks to Vaishnavi Joshi for her help in this blog!
Share Story :
Filtering Entity Lookups based on field value
I have a contact record with a role option set field with options Billing, Decision Maker, Client, Influencer. The Requirement is to only show billing contacts i.e. contacts with role billing related to the account selected on the Opportunity in the lookup of the contacts on the Opportunities. Let’s see how I to filtered the contacts lookup to just show billing contacts : Step 1: Create a contacts view such that the role is billing(or any field on which you want to filter is set to the value by which you want to filter that record ). Step 2: Set the filter criteria of the contacts lookup field on the opportunity as shown below. In the Additional properties turn of the view selector and set the default view to the view you created in #1Step 1 In the Field Behavior Tick the “disable most recently used items for this field”. Now you will only see contacts with role billing in the lookup of the contacts on the opportunity form. Hope this helps! Thank you.
Share Story :
How to create a table using Azure Logic Apps with proper formatting
In this blog, we will see how we can create a table using HTML language using the Azure logic app. If you see carefully, there is an action block present which is “Create HTML table” but it does not give formatting flexibility. so in this blog, I will explain how we can use compose block to create a table with HTML syntax Step 1: To start with the logic app I took the recurrence trigger. you can use any trigger as per your requirement (which is set to run once a day) Step 2: Compose block is an important block as we are writing HTML syntax to format our table. For the demo I used sample data otherwise you can enter dynamic fields as well. in the highlighted section. Step 3: So output of Compose block is sent as the body of the email as shown in the below screenshot. Output: Email Hope this blog helps you. Thank you !!
Share Story :
How to create Dynamic Option-set/List based on value from other fields in Canvas PowerApps
Hi Everyone, Consider a scenario where we want to filter out a dropdown/combo-box choice field based on value in other field or dropdown.Since we cannot use scripts in Canvas App, here’s how we can show specific choice based on multiple values For this example, I’ve considered a bunch of basic items belonging to Fruits, Vegetables and Dairy products. For example purpose I’ll be creating a collection of values to representation. This step will be avoided for choices field within a table/entity.Below is the ‘Master Record’ of collection. Step 1: Create an indexed collection. (referring to MasterList in this example) Step 2: Let’s say we would like to classify the Master List into 3 categories (Fruits, Vegetables and Dairy). In this example, I’ll be using a dropdown list for which the main dropdown field is required to filter data. I’ll be adding a hidden button, containing the following code Based on the above code,Type 1 refers to “Fruits”, Type 2 refers to “Vegetables” and Type 3 refers to “Dairy” Step 3: Added dropdown which will hold classification values. Step 4: The main dropdown choice field which will be filtered based on categories mentioned by above dropdown. That’s it. We have successfully implemented the dynamic choice list as per values dependent on other field. Hope this helps you.
Share Story :
Update records in Dynamics CRM using Azure Logic Apps
In this blog, we will see how we can update the records CRM with the help of a logic app workflow. Step 1: Add the recurrence trigger in the logic app and set it to run in a one-day interval. you can set any interval. Without a trigger, you cannot create a logic app. Step 2: Add new step after recurrence trigger Step 3: Add the List records action from Dynamics 365 and connect to CRM with your credentials Select Account entity Step 4: For testing purposes, I have created a test account (account number = 1001)in the UAT environment as shown below. Step 5: Initialize the variable with account number is 1001. The account where you want to change/update the data Step 6: Filter the list of accounts where the account number is equal to 1001 as mentioned above step. Step 7: After finding a record from the account list then we will update the record here I updated the account name and city(Note: Account number should unique) Result Hope this blog helps you Thank you!
Share Story :
How to use Standard Journal Feature In Business Central?
Introduction. They might be some need to copy the data from one batch to another. In Business central there are multiple ways to do so use copy & paste method or use or configuration packages or Use Standard Journal Feature. Let’s understand about the Standard Journal Feature in detail. But please note Standard Journal Function is not present in other journals apart from General Journal. Steps to achieve the goal: Go to batch where you want to move the data from. There will be action to save as a standard Journal. 5. You would be able to see the Standard Journal you have created. Click on Ok. Please note if you change the amount of the line after copying from the Standard Journal. It will not be reflected the same in Standard Journal. As it is used as Template. Conclusion: Thus we saw how we can use Standard Journal Feature in Business central. Thank you very much for reading my work. Hope you enjoyed the article!
Share Story :
Load JSON data from Azure Blob Storage to Microsoft Finance and operation
In this blog we will see how to we can integrate data from Azure Blob storage to Microsoft Finance and operations. In this use case we are updating the data in the finance and operation destination Prerequisite: Azure Blob Storage Azure Finance and operation Step 1 : In this we will create the HTTP Trigger workflow or you can selected any trigger based on requirement. Step 2 : Azure Logic App will read the data stored in the Azure Blob Storage in JSON format. Below is sample JSON format, [ { “MeterId”:”A001″, “MeterRead”:”100″ }, { “MeterId”:”A003″, “MeterRead”:”300″ } ] Step 3: workflow logic, It will read JSON formatted data which contains the Meter ID and Meter Reading. Based on Meter ID it will fetch the record id. Using record id Meter Reading data will be updated in F&O. Destination Finance and operation: Hope this helps!
Share Story :
Configuring NAS in LS Central for automating Data Director jobs
Introduction LS Central Scheduler Jobs are used for automatic background processing. These jobs use the NAS Service under the hood. We are going to see how to configure the NAS Service for LS Central. References https://help.lscentral.lsretail.com/Content/LS-Insight/Setup/LS-Central-In-Cloud-LS-Insight-In-Azure/3-Machine-Or-VM.htm Pre-requisites LS Central v16.4 – OnPrem Data Director Configuration Create a new Server Instance and name it appropriately. Ensure that the account for this new Server Instance is set to User and the User has Administrator privileges. In the General tab, update the “Service Default Company” and “Service Default Time Zone.” In the NAS Services tab, set the following fields: Run NAS Services with Admin Rights: True Startup Argument: NASID,TYPEFILTER=,LOG=1,REPEAT=1 Startup Codeunit: 99001468 Startup Method: LSRSCHEDULER Restart the Server Instance. Open the Scheduler Setup in LS Central and set the “Enable NAS Scheduler” to true. Refresh the page. Conclusion: Thus we saw how to configure NAS Services in LS Central. Happy Coding!
