public static void FetchLegislationData(CrmServiceClient existingService = null, string outputPath = "legislation.integration.js") { CrmServiceClient service = null; try { service = existingService == null?CrmSdkHelper.Connect() : existingService; if (service != null) { Console.BackgroundColor = ConsoleColor.DarkGreen; Console.WriteLine("Connected to the organization server for " + service?.CrmConnectOrgUriActual?.AbsoluteUri ?? service?.ConnectedOrgFriendlyName); if (service.IsReady) { Console.WriteLine(Environment.NewLine + "-----FETCHING LEGISLATION DATA-----" + Environment.NewLine + ":)"); var result = CrmSdkHelper.ExecuteLegislationFetchXml(); JToken jsonFormatted = JToken.Parse(result); var beautified = jsonFormatted.ToString(Formatting.Indented); string before = $"/* eslint-disable indent */{Environment.NewLine}export default {{{Environment.NewLine} data: "; string after = $"{Environment.NewLine}}}{Environment.NewLine}"; beautified = beautified.Replace("\"", "'"); using (StreamWriter file = File.CreateText(outputPath)) { file.Write(before); file.Write(beautified); file.Write(after); } Console.WriteLine(outputPath); Console.WriteLine("opening legislation fetch results"); Process myProcess = new Process(); Process.Start("notepad++.exe", outputPath); myProcess.Dispose(); } else { const string UNABLE_TO_LOGIN_ERROR = "Unable to Login to Common Data Service"; if (service.LastCrmError.Equals(UNABLE_TO_LOGIN_ERROR)) { Console.WriteLine("Check the connection string values in cds/App.config."); throw new Exception(service.LastCrmError); } else { throw service.LastCrmException; } } } } catch (Exception ex) { CrmSdkHelper.HandleException(ex); } finally { if (service != null) { service.Dispose(); } } }