Thursday, October 20, 2016

Convert String to Json Object and Get Particular Values from C# MSCRM

Hi All,

Please find the code below to read string from Configuration Entity and Convert it into Json Object

Eg for Json Data

string json = @"{""12112083"":{""Topic_ID"":""12112083"",""Moved_ID"":""51"",""subject"":""Due to a computer virus, many of my files are \u005CCrypted\u005C,espe"",""Start_date"":""10/6/2012 6:54:37 PM"",""InitialResponseDueDate"":""10/6/2012 7:01:37 PM"",""Locked"":""0"",""QValue"":""$10"",""Status"":""1"",""Author_ID"":""71318191"" }";

QueryExpression getConfigData = new QueryExpression("new_configuration");
getConfigData.ColumnSet = new ColumnSet("new_value");
getConfigData.Criteria.AddCondition(new ConditionExpression("new_key", ConditionOperator.Equal, "getStringValue"));

EntityCollection resultConfigdata = service.RetrieveMultiple(getConfigData);

JToken token = JObject.Parse(resultConfigdata[0].Attributes["new_value"].ToString());
string topicid = (string)token.SelectToken("Topic_ID"); 
string movedid = (string)token.SelectToken("Moved_ID");

string startdate = (string)token.SelectToken("Start_date");

No comments:

Post a Comment

How to Run Microsoft Flow for Every one Month

Introduction: In this Blog we will see how to Run Microsoft Flow for Every one Month. Implementation Steps:   1. Navigate to  https://make.p...