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

Day 11 - Customizing Option Sets Dropdown Fields with JavaScript

  In this Blog, we will see how to Customizing Option Sets Dropdown Fields with JavaScript label1 = formContext.getAttribute( "bosch_op...