Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

System.IO.FileNotFoundException running custom workflow activity CRM365 online

(0) ShareShare
ReportReport
Posted on by 190

Hi, I am getting the following error when trying to fire a workflow activity that runs in CRM2011 on premise but fails in D365 online:

Unhandled Exception: System.ServiceModel.FaultException`1[[Microsoft.Xrm.Sdk.OrganizationServiceFault, Microsoft.Xrm.Sdk, Version=8.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]: System.IO.FileNotFoundException: Microsoft Dynamics CRM has experienced an error. Reference number for administrators or support: #BCBDEE75Detail:
<OrganizationServiceFault xmlns:i="www.w3.org/.../XMLSchema-instance" xmlns="schemas.microsoft.com/.../Contracts">
<ActivityId>8906ac72-50ac-481a-8add-19e39e2c1aee</ActivityId>
<ErrorCode>-2147220970</ErrorCode>
<ErrorDetails xmlns:d2p1="schemas.datacontract.org/.../System.Collections.Generic" />
<Message>System.IO.FileNotFoundException: Microsoft Dynamics CRM has experienced an error. Reference number for administrators or support: #BCBDEE75</Message>
<Timestamp>2017-10-26T17:00:52.6165966Z</Timestamp>
<ExceptionRetriable>false</ExceptionRetriable>
<ExceptionSource>PluginExecution</ExceptionSource>
<InnerFault i:nil="true" />
<OriginalException>System.IO.FileNotFoundException
at Microsoft.Crm.Sandbox.SandboxAppDomainHelper.Execute(IOrganizationServiceFactory organizationServiceFactory, String customActivityTypeName, IExecutionContext requestContext, Dictionary`2 sandboxServices, Boolean useDrawbridgeEnabled, Boolean chaosFailAppDomain)
at Microsoft.Crm.Sandbox.SandboxWorker.ExecuteCustomWorkflowActivity(SandboxCallInfo callInfo, SandboxCustomActivityExecutionContext requestContext, Guid pluginAssemblyId, Int32 sourceHash, String assemblyName, Guid pluginTypeId, String pluginTypeName, SandboxRequestCounter&amp; workerCounter, Boolean returnTraceInfo)</OriginalException>
<TraceText i:nil="true" />
</OrganizationServiceFault>

Server stack trace:
at System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc& rpc)
at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs)
at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)

Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at Microsoft.Crm.Sandbox.ISandboxHost.ExecuteCustomWorkflowActivityAndReturnTraceInfo(SandboxCallInfo callInfo, SandboxCustomActivityExecutionContext requestContext, Guid pluginAssemblyId, Int32 sourceHash, String assemblyName, Guid pluginTypeId, String pluginTypeName, String assemblyContents, Boolean returnTraceInfo)
at Microsoft.Crm.Sandbox.SandboxCustomActivity.Execute(SandboxClient client, SandboxCallTracker callTracker, IExecutionContext requestContext, String assemblyContents, Boolean returnTraceInfo)
at Microsoft.Crm.Sandbox.SandboxCodeUnit.Execute(IExecutionContext context)

There are several workflow activities in the assembly and some run ok but several give me this error. Happy to provide any info needed.

Any advice appreciated

Phil

*This post is locked for comments

  • fillcrocker Profile Picture
    fillcrocker 190 on at
    RE: System.IO.FileNotFoundException running custom workflow activity CRM365 online

    Ok, thanks for your advice Andrew

  • Suggested answer
    a33ik Profile Picture
    a33ik 84,325 Most Valuable Professional on at
    RE: System.IO.FileNotFoundException running custom workflow activity CRM365 online

    Phil,

    I don't see anything suspicious. You will have to troubleshoot your code - community.dynamics.com/.../debugging-workflow-custom-activities-with-plugin-registration-tool

    Good luck.

  • fillcrocker Profile Picture
    fillcrocker 190 on at
    RE: System.IO.FileNotFoundException running custom workflow activity CRM365 online

    Hi Andrew, WriteAssessment code:

    public void WriteAssessmentFile(String accountId, String levyYear, String sharedServicesPhoneNumber, String sharedServicesEmailAddress,

                                               XmlWriter writer, Xrm.Account regEmp, Xrm.cs_levyreturn levyReturn,

                                               bool jobModeLive, DateTime returnDate, Xrm.XrmServiceContext xrm, ref string workflowResultMessage, IOrganizationService service, CodeActivityContext executionContext)

           {

               ITracingService tracingService = (ITracingService)executionContext.GetExtension<ITracingService>();

               if (jobModeLive)

               {

                   tracingService.Trace("Entered LevyReturnUtils - WriteAssessmentFile...");

                   // Collect the remaining information

                   Xrm.SystemUser user = null;

                   bool hasAppointedAccountManager = false;

                   // get the details of the account manager if there is one

                   if (regEmp.cs_AppointedAccountManager != null)

                   {

                       user = GetAccountManager(regEmp.cs_AppointedAccountManager.Id.ToString(), xrm, ref workflowResultMessage, executionContext);

                       hasAppointedAccountManager = true;

                   }

                   Xrm.Contact contact = null;

                   bool hasInsolvencyContact = false;

                   if (regEmp.cs_InsolvencyContact != null)

                   {

                       contact = GetContactDetails(regEmp.cs_InsolvencyContact.Id.ToString(), xrm, ref workflowResultMessage, executionContext);

                       hasInsolvencyContact = true;

                   }

                   else

                   {

                       if (regEmp.cs_LevyContact != null)

                       {

                           contact = GetContact(regEmp.cs_LevyContact.Id.ToString(), xrm, ref workflowResultMessage, executionContext);

                       }

                   }

                   // Add record to file

                   writer.WriteStartElement("LevyAssessment");

                   String indicator = String.Empty;

                   if (levyReturn.cs_TemplateType != null)

                   {

                       switch (levyReturn.cs_TemplateType.Value)

                       {

                           case ProcessBulkJobs.LevyReturn.TemplateType.BONAFIDE_WITH_DD_BOX_C:// new LevyReturn Template types for Bulk Assessment as req for Bulk Assessment new CR 05/01/2016 GG

                               indicator = "1";

                               break;

                           case ProcessBulkJobs.LevyReturn.TemplateType.BONAFIDE_NON_DD_BOX_C: // new LevyReturn Template types for Bulk Assessment as req for Bulk Assessment new CR 05/01/2016 GG

                               indicator = "2";

                               break;

                           case ProcessBulkJobs.LevyReturn.TemplateType.BONAFIDE_WITH_DD_BOX_F:// new LevyReturn Template types for Bulk Assessment as req for Bulk Assessment new CR 05/01/2016 GG

                               indicator = "3";

                               break;

                           case ProcessBulkJobs.LevyReturn.TemplateType.BONAFIDE_NON_DD_BOX_F:// new LevyReturn Template types for Bulk Assessment as req for Bulk Assessment new CR 05/01/2016 GG

                               indicator = "4";

                               break;

                          case ProcessBulkJobs.LevyReturn.TemplateType.ESTIMATED:

                               indicator = "5";

                               break;

                       }

                   }

                   writer.WriteElementString("Indicator", indicator);

                   writer.WriteElementString("CurrentDate", levyReturn.cs_AssessmentDate.HasValue ? levyReturn.cs_AssessmentDate.Value.ToLocalTime().ToString("dd MMM yyyy") : String.Empty);

                   writer.WriteElementString("LevyYear", levyYear);

                   writer.WriteElementString("NextLevyYear", (int.Parse(levyYear) + 1).ToString());

                   writer.WriteElementString("EmployerID", String.IsNullOrEmpty(regEmp.cs_RegistrationNumber) ? String.Empty : regEmp.cs_RegistrationNumber);

                   //CR96

                   var companyTypeCode = ((OptionSetValue)regEmp.cs_CompanyType).Value;

                   string companyTypeLabel = Utils.RetrieveOptionSetLabel(service, "account", "cs_companytype", companyTypeCode);

                   //alter company name heading depending on the company type

                   if (companyTypeLabel.ToString().Equals("Joint Venture"))

                   {

                       //mandatory field, will contain data.

                       writer.WriteElementString("TradingName", String.IsNullOrEmpty(regEmp.cs_TradingName) ? String.Empty : regEmp.cs_TradingName);

                       //not mandatory field, may contain data.

                       if (regEmp.cs_CompanyName == null)

                       {

                           writer.WriteElementString("VenturePartners", "");

                       }

                       else

                       {

                           writer.WriteElementString("VenturePartners", String.IsNullOrEmpty(regEmp.cs_CompanyName) ? String.Empty : regEmp.cs_CompanyName);

                       }

                   }

                   else if ((companyTypeLabel.ToString().Equals("Ltd Company")) || (companyTypeLabel.ToString().Equals("PLC")))

                   {                  

                       //not mandatory field, may contain data.

                       if (regEmp.cs_TradingName == null)

                       {

                           writer.WriteElementString("TradingName", "");

                       }

                       else

                       {

                           writer.WriteElementString("TradingName", String.IsNullOrEmpty(regEmp.cs_TradingName) ? String.Empty : regEmp.cs_TradingName);

                       }

                       //mandatory field, will contain data.

                       writer.WriteElementString("RegisteredName", String.IsNullOrEmpty(regEmp.cs_CompanyName) ? String.Empty : regEmp.cs_CompanyName);

                   }

                   else if ((companyTypeLabel.ToString().Equals("Partnership")) || (companyTypeLabel.ToString().Equals("LLP")))

                   {

                       //mandatory field, will contain data.

                       writer.WriteElementString("TradingName", String.IsNullOrEmpty(regEmp.cs_TradingName) ? String.Empty : regEmp.cs_TradingName);

                       //not mandatory field, may contain data.

                       if (regEmp.cs_CompanyName == null)

                       {

                           writer.WriteElementString("Partners", "");

                       }

                       else

                       {

                           writer.WriteElementString("Partners", String.IsNullOrEmpty(regEmp.cs_CompanyName) ? String.Empty : regEmp.cs_CompanyName);

                       }

                   }

                   else if (companyTypeLabel.ToString().Equals("Sole Trader"))

                   {

                       //not mandatory field, may contain data.

                       if (regEmp.cs_TradingName == null)

                       {

                           writer.WriteElementString("TradingName", "");

                       }

                       else

                       {

                           writer.WriteElementString("TradingName", String.IsNullOrEmpty(regEmp.cs_TradingName) ? String.Empty : regEmp.cs_TradingName);

                       }

                       //mandatory field, will contain data.

                       writer.WriteElementString("Owner", String.IsNullOrEmpty(regEmp.cs_CompanyName) ? String.Empty : regEmp.cs_CompanyName);

                   }

                   writer.WriteElementString("CompanyType", companyTypeLabel.ToString());

                   WriteAddressElements(regEmp, contact, hasInsolvencyContact, writer);

                   writer.WriteStartElement("Assessment");

                   // BUG #972 30/07/2012 AJG update source of PAYE and LOSC fields

                   // BUG #991 07/08/2012 AJG update source of LOPR field and round fields

                   writer.WriteElementString("PAYE", levyReturn.cs_AssessablePAYEAmount == null ? String.Empty : Decimal.Round(levyReturn.cs_AssessablePAYEAmount.Value).ToString());

                   writer.WriteElementString("Percent_PAYE", levyReturn.cs_LevyRatePAYE.HasValue ? Decimal.Round(levyReturn.cs_LevyRatePAYE.Value, 1).ToString() : String.Empty);

                   writer.WriteElementString("Assessed_PAYE", levyReturn.cs_LevyDuePAYE == null ? String.Empty : Decimal.Round(levyReturn.cs_LevyDuePAYE.Value).ToString());

                   //   writer.WriteElementString("LOSC", levyReturn.cs_AssessableLOSCAmount == null ? String.Empty : Decimal.Round(levyReturn.cs_AssessableLOSCAmount.Value).ToString()); // not rq for BA CR GG 12/12/2016

                   //   writer.WriteElementString("Percent_LOSC", levyReturn.cs_LevyRateLOSC.HasValue ? Decimal.Round(levyReturn.cs_LevyRateLOSC.Value, 1).ToString() : String.Empty); // not rq for BA CR GG 12/12/2016

                   //   writer.WriteElementString("Asssessed_LOSC", levyReturn.cs_LevyDueLOSC == null ? String.Empty : Decimal.Round(levyReturn.cs_LevyDueLOSC.Value).ToString());// not rq for BA CR GG 12/12/2016

                   //   writer.WriteElementString("SubTotal_PAYE_LOSC", levyReturn.cs_LevyDueSubTotal == null ? String.Empty : Decimal.Round(levyReturn.cs_LevyDueSubTotal.Value).ToString());// not rq for BA CR GG 12/12/2016

                   //   writer.WriteElementString("LOPR", levyReturn.cs_AssessableLOPRAmount == null ? String.Empty : Decimal.Round(levyReturn.cs_AssessableLOPRAmount.Value).ToString());// not rq for BA CR GG 12/12/2016

                   //   writer.WriteElementString("Percent_LOPR", levyReturn.cs_LevyRateLOSC.HasValue ? Decimal.Round(levyReturn.cs_LevyRateLOSC.Value, 1).ToString() : String.Empty);// not rq for BA CR GG 12/12/2016

                   //CR96 amended to includ correct field and produce correct figures.

                   //decimal amt = levyReturn.cs_ReceiptsLOSCAmount == null ? 0 : 0 - levyReturn.cs_ReceiptsLOSCAmount.Value;

                   writer.WriteElementString("CIS", levyReturn.cs_AssessableCISAmount == null? String.Empty : Decimal.Round(levyReturn.cs_AssessableCISAmount.Value).ToString());

                   writer.WriteElementString("Levy_Rate_CIS", levyReturn.cs_CISNetLevyPercentage.HasValue ? Decimal.Round(levyReturn.cs_CISNetLevyPercentage.Value, 2).ToString() : String.Empty);

                   writer.WriteElementString("Assessed_CIS", levyReturn.cs_CISCalculatedNetCISLevy == null ? String.Empty : Decimal.Round(levyReturn.cs_CISCalculatedNetCISLevy.Value).ToString());

                  // writer.WriteElementString("Sub_Total", levyReturn.cs_CISLevySimplificationLevyAmount == null ? String.Empty : Decimal.Round(levyReturn.cs_CISLevySimplificationLevyAmount.Value).ToString());

                   writer.WriteElementString("Sub_Total", levyReturn.cs_CISLevySimplificationLevyAmount == null ? String.Empty : Decimal.Round(levyReturn.cs_CISLevySimplificationLevyAmount.Value, 2).ToString());

                   decimal amt = levyReturn.cs_LevyLOPRAmount == null ? 0 : 0 - levyReturn.cs_LevyLOPRAmount.Value;

                   if (amt > 0)

                   {

                       amt = amt * -1;

                   }

                  // writer.WriteElementString("Assessed_LOPR", Decimal.Round(amt).ToString());

                  // writer.WriteElementString("SubTotal_PAYE_LOSC_LOPR", levyReturn.cs_LevyDueTotal == null ? String.Empty : Decimal.Round(levyReturn.cs_LevyDueTotal.Value).ToString()); //not rw for Bulk Assessment in new CR 12/12/2016

                    amt = levyReturn.cs_TaperBandAmount == null ? 0 : 0 - levyReturn.cs_TaperBandAmount.Value;

                   if (amt > 0)

                   {

                       amt = amt * -1;

                   }

                   writer.WriteElementString("PAYE_TAPER", Decimal.Round(amt, 2).ToString());

                   writer.WriteElementString("Percent_TAPER", levyReturn.cs_TaperPercentage.HasValue ? Decimal.Round(levyReturn.cs_TaperPercentage.Value, 1).ToString() : String.Empty);

                   writer.WriteElementString("Total", levyReturn.cs_LevyPayable == null ? String.Empty : Decimal.Round(levyReturn.cs_LevyPayable.Value, 2).ToString());

                   //CR96 allowed&disallowed LOPRS & CIS - removed as not required

                   //writer.WriteElementString("Allowed LOPRs", String.IsNullOrEmpty(levyReturn.cs_LoprsMaterial) ? String.Empty : levyReturn.cs_LoprsMaterial);

                   //writer.WriteElementString("Disallowed LOPRs", String.IsNullOrEmpty(levyReturn.cs_LoprsImmaterial) ? String.Empty : levyReturn.cs_LoprsImmaterial);    

                   //writer.WriteElementString("Calculated_Net_CIS_Levy", levyReturn.cs_CISCalculatedNetCISLevy == null ? String.Empty : Decimal.Round(levyReturn.cs_CISCalculatedNetCISLevy.Value, 2).ToString());

                  // writer.WriteElementString("CIS_Tax_Deducted", levyReturn.cs_cistaxdeducted == null ? String.Empty : Decimal.Round(levyReturn.cs_cistaxdeducted.Value).ToString());

                  // writer.WriteElementString("Net_CIS_Grossed_Up_Figure", levyReturn.cs_CISNetCISGrossedUpFigure == null ? String.Empty : Decimal.Round(levyReturn.cs_CISNetCISGrossedUpFigure.Value).ToString());

                   writer.WriteEndElement();

                   writer.WriteElementString("DueDate", levyReturn.cs_DueDate.HasValue ? levyReturn.cs_DueDate.Value.ToLocalTime().ToString("dd MMM yyyy") : String.Empty);

                   //CR96 - add OCR line to file

                   String OCR = "1";

                   OCR += regEmp.cs_RegistrationNumber.PadLeft(8, '0');

                   OCR += levyReturn.cs_AssessmentDate.Value.ToString("ddMMyy");

                   OCR += levyReturn.cs_LevyPayable.Value.ToString("0000000.00").Replace(".", "");

                   OCR += "0000000000";                  

                   writer.WriteElementString("OCR", OCR);

                   writer.WriteElementString("ProRata", levyReturn.cs_ProRataPercentage.HasValue && levyReturn.cs_ProRataPercentage.Value == 100 ? String.Empty : "1");

                   writer.WriteElementString("BankSortCode", String.IsNullOrEmpty(regEmp.cs_SortCodeLevy) ? String.Empty : regEmp.cs_SortCodeLevy);

                   writer.WriteElementString("BankAccountNo", String.IsNullOrEmpty(regEmp.cs_AccountNumberLevy) ? String.Empty : regEmp.cs_AccountNumberLevy);

                   writer.WriteElementString("InRespect", regEmp.cs_TradingStatus != null && regEmp.cs_TradingStatus.Value == ProcessBulkJobs.TradingStatus.CEASEDTOTRADE ? "In Respect of: " + regEmp.Name : String.Empty );

                   writer.WriteStartElement("Installments");

                   writer.WriteElementString("InstallmentCount", levyReturn.cs_DDQty.HasValue ? levyReturn.cs_DDQty.Value.ToString() : String.Empty);

                   writer.WriteElementString("Total", levyReturn.cs_LevyPayable == null ? String.Empty : Decimal.Round(levyReturn.cs_LevyPayable.Value,2).ToString());

                   // BUG 838 AJG - allow for BST - date returned is the UTC datetime

                   writer.WriteElementString("FirstDate", levyReturn.cs_DDDueDate1.HasValue ? levyReturn.cs_DDDueDate1.Value.ToLocalTime().ToString("dd MMM yyyy") : String.Empty);

                   writer.WriteElementString("FirstAmount", levyReturn.cs_DDFirstAmount == null ? String.Empty : Decimal.Round(levyReturn.cs_DDFirstAmount.Value, 2).ToString());

                   writer.WriteElementString("RestAmount", levyReturn.cs_DDOtherAmounts == null ? String.Empty : Decimal.Round(levyReturn.cs_DDOtherAmounts.Value, 2).ToString());

                   writer.WriteElementString("NextDate", levyReturn.cs_DDDueDate2.HasValue ? levyReturn.cs_DDDueDate2.Value.ToLocalTime().ToString("dd MMM yyyy") : String.Empty);

                   writer.WriteElementString("DayOfPayment", levyReturn.cs_DDDayOfMonth.HasValue ? levyReturn.cs_DDDayOfMonth.Value.ToString() : String.Empty);

                   String ddbarcode = "*1007";

                   ddbarcode += regEmp.cs_RegistrationNumber;

                   ddbarcode += "*";

                   writer.WriteElementString("Direct_Debit_BarCode", ddbarcode);

                   writer.WriteEndElement();

                   WriteCSkillsContactDetails(sharedServicesPhoneNumber, sharedServicesEmailAddress, hasAppointedAccountManager, user, writer);

                   //WriteLevyContactElement(contact, hasInsolvencyContact, writer);

                   WriteLevyContactElementForAssessment(contact, hasInsolvencyContact, writer);

                   // only need this if assessment type is Estimated

                   // BUG 837 AJG Add missing fields and update order of elements

                   if (levyReturn.cs_AssessmentType !=  null && levyReturn.cs_AssessmentType.Value != ProcessBulkJobs.AssessmentType.BONAFIDE && levyReturn.cs_AssessmentType.Value != ProcessBulkJobs.AssessmentType.NOTASSESSED)

                   {

                       writer.WriteStartElement("LevyReturn");

                       writer.WriteElementString("EmployerID", String.IsNullOrEmpty(regEmp.cs_RegistrationNumber) ? String.Empty : regEmp.cs_RegistrationNumber);

                       String barcode = "*1005";

                       barcode += levyYear.Substring(2,2);

                       barcode += "0";

                       barcode += regEmp.cs_RegistrationNumber;

                       barcode += "*";

                       writer.WriteElementString("LevyReturn_BarCode", barcode);

                     //  WriteLevyContactElement(contact, hasInsolvencyContact, writer);

                       WriteLevyContactElementForAssessment(contact, hasInsolvencyContact, writer);

                       writer.WriteElementString("TradingName", String.IsNullOrEmpty(regEmp.cs_TradingName) ? String.Empty : regEmp.cs_TradingName);

                       writer.WriteElementString("OtherNames", String.IsNullOrEmpty(regEmp.cs_CompanyName) ? String.Empty : regEmp.cs_CompanyName);

                       writer.WriteElementString("UTR", String.IsNullOrEmpty(regEmp.cs_UniqueTaxRef) ? String.Empty : regEmp.cs_UniqueTaxRef);

                       writer.WriteElementString("VATNumber", String.IsNullOrEmpty(regEmp.cs_VATNumber) ? String.Empty : regEmp.cs_VATNumber);

                       WriteAddressElements(regEmp, contact, hasInsolvencyContact, writer);                    

                       WritePhoneFaxEmailElements(contact, hasInsolvencyContact, writer);

                       writer.WriteElementString("MainActivity", regEmp.cs_MainActivityId == null ? String.Empty : regEmp.cs_MainActivityId.Name);

                       // BUG #886 19/06/2012 AJG - return date needs to be local time to allow for BST

                       writer.WriteElementString("ReturnDate", returnDate.ToLocalTime().ToString("dd MMM yyyy"));

                       writer.WriteElementString("IssueDate", DateTime.Today.ToString("ddMMyy"));

                       WriteCSkillsContactDetails(sharedServicesPhoneNumber, sharedServicesEmailAddress, hasAppointedAccountManager, user, writer);

                       EntityCollection memberships = GetMemberships(accountId, xrm, ref workflowResultMessage,executionContext);

                       writer.WriteStartElement("EmployerOrganisations");

                       foreach (Entity membership in memberships.Entities)

                       {

                           if (membership.ToEntity<Xrm.cs_employerorganisationdetail>().cs_employerorganisationid != null)

                           {

                               writer.WriteElementString("EmployerOrganisation", membership.ToEntity<Xrm.cs_employerorganisationdetail>().cs_employerorganisationid.Name);

                           }

                       }

                       writer.WriteEndElement();

                       writer.WriteEndElement();

                   }

                   writer.WriteEndElement();

               }

               tracingService.Trace("Finished LevyReturnUtils - WriteAssessmentFile...");

    }

    UploadAzureBlob is a class added to the project to upload the xml to blob storage. Code here:

    using System;

    using System.Collections.Generic;

    using System.Linq;

    using System.Text;

    using System.Threading.Tasks;

    using System.Xml;

    using Microsoft.WindowsAzure;

    using Microsoft.WindowsAzure.Storage;

    using Microsoft.WindowsAzure.Storage.Blob;

    using System.IO;

    namespace CSkills.CRM.LevyGrant.ProcessBulkJobs

    {

       public static class UploadAzureBlob

       {

           public static void UploadStream(string storageConnectionString, string blobContainerName, Stream streamUpload, string fileName)

           {

               // Retrieve storage account from connection string.            

               CloudStorageAccount storageAccount = CloudStorageAccount.Parse(storageConnectionString);

               // Create the blob client.

               CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();

               // Retrieve reference to a previously created container.

               CloudBlobContainer container = blobClient.GetContainerReference(blobContainerName);

               string sFileName = String.Format("{0}_{1}",  fileName, DateTime.Today.ToString("yyyyMMdd"));

               // Retrieve reference to a blob named "myblob".

               CloudBlockBlob blockBlob = container.GetBlockBlobReference(sFileName + ".xml");

               // Upload the string to the blob            

               blockBlob.UploadFromStream(streamUpload);

           }

           public static void UploadString(string storageConnectionString, string blobContainerName, string stringUpload, string fileName)

           {

               // Retrieve storage account from connection string.            

               CloudStorageAccount storageAccount = CloudStorageAccount.Parse(storageConnectionString);

               // Create the blob client.

               CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();

               // Retrieve reference to a previously created container.

               CloudBlobContainer container = blobClient.GetContainerReference(blobContainerName);

               string sFileName = String.Format("{0}_{1}", fileName, DateTime.Today.ToString("yyyyMMdd"));

               // Retrieve reference to a blob named "myblob".

               CloudBlockBlob blockBlob = container.GetBlockBlobReference(sFileName + ".xml");

               // Upload the string to the blob            

               blockBlob.UploadText(stringUpload);

           }

       }

    }

    Thanks

    Phil

  • a33ik Profile Picture
    a33ik 84,325 Most Valuable Professional on at
    RE: System.IO.FileNotFoundException running custom workflow activity CRM365 online

    Forget my reply regarding XrmWritter :)

    I looked at your code second time and I have question:

    1. What does lrUtils.WriteAssessmentFile code do?

    2. Where UploadAzureBlob comes from?

  • fillcrocker Profile Picture
    fillcrocker 190 on at
    RE: System.IO.FileNotFoundException running custom workflow activity CRM365 online

    Thanks Andrew. Any suggestions on what to use instead of XmlWritter? Our plan was to build the XML in memory and write to blob storage then use a logic app to send file to customer. We were hoping to change as little as possible in the workflow activity code.

    Thanks

    Phil

  • a33ik Profile Picture
    a33ik 84,325 Most Valuable Professional on at
    RE: System.IO.FileNotFoundException running custom workflow activity CRM365 online

    Hello,

    CRM Online works in sandbox and it can't log anything in the way you're doing through XmlWritter. You will have to rebuild your code.

  • fillcrocker Profile Picture
    fillcrocker 190 on at
    RE: System.IO.FileNotFoundException running custom workflow activity CRM365 online

    Hi Andrew, code for one of the workflow activities below:

    //

    {

       using System;

       using System.Activities;

       using System.ServiceModel;

       using Microsoft.Xrm.Sdk;

       using Microsoft.Xrm.Sdk.Workflow;

       using Microsoft.Xrm.Sdk.Query;

       using Microsoft.Xrm.Sdk.Messages;

       using System.Linq;

       using System.Xml;

       using System.IO;

       using CSkills.CRM.LevyGrant.ProcessBulkJobs;

       using System.Net.Http;

       //using log4net;

       public sealed class ProcessAssessmentBulkMailing : CodeActivity

       {

           //  Workflow inputs/outputs

           [Input("Levy Year")]

           [RequiredArgument]

           [ReferenceTarget("cs_levyyear")]

           public InArgument<EntityReference> LevyYearId { get; set; }

           [Input("Bulk Mail Type")]

           [RequiredArgument]

           public InArgument<String> BulkMailType { get; set; }

           [Input("Retrieve Query")]

           [RequiredArgument]

           public InArgument<String> RetrieveQuery { get; set; }

           [Input("Return Date")]

           [RequiredArgument]

           public InArgument<DateTime> ReturnDate { get; set; }

           [Input("Job Mode")]

           [RequiredArgument]

           public InArgument<Boolean> JobMode { get; set; }

           [Output("Step Executed Successfully")]

           public OutArgument<Boolean> IsWorkflowResultOk { get; set; }

           [Output("Workflow Result Message")]

           public OutArgument<string> WorkflowResultMessage { get; set; }

           private ProcessBulkJobs.LevyReturnsUtils lrUtils = new CSkills.CRM.LevyGrant.ProcessBulkJobs.LevyReturnsUtils();

           private ProcessBulkJobs.LevyReturnCommonObjects lrCommonObjects = new CSkills.CRM.LevyGrant.ProcessBulkJobs.LevyReturnCommonObjects();

           //private static ILog log = ProcessBulkJobs.Log4NetWrapper.GetLog4Net(System.Reflection.MethodBase.GetCurrentMethod().GetType());

           /// <summary>

           /// Executes the workflow activity.

           /// </summary>

           /// <param name="executionContext">The execution context.</param>

           protected override void Execute(CodeActivityContext executionContext)

           {

               ITracingService tracingService = executionContext.GetExtension<ITracingService>();

               String workflowResultMessage = String.Empty;

               XmlWriter writer = null;

               XmlWriterSettings writersettings = new XmlWriterSettings();

               writersettings.OmitXmlDeclaration = true;

               writersettings.Indent = true;

               //Creating memory stream for XML writer to store data

               string fileName = "LevyAssessmentNotices";            

               MemoryStream stream = new MemoryStream();

               stream.Position = 0;

               tracingService.Trace("Just Entered...");

               // Create the tracing service

               if (tracingService == null)

               {

                   throw new InvalidPluginExecutionException("Failed to retrieve tracing service.");

               }

               tracingService.Trace("Entered ProcessAssessmentBulkMailing.Execute(), Activity Instance Id: {0}, Workflow Instance Id: {1}",

                   executionContext.ActivityInstanceId,

                   executionContext.WorkflowInstanceId);

               // Create the context

               IWorkflowContext context = executionContext.GetExtension<IWorkflowContext>();

               if (context == null)

               {

                   throw new InvalidPluginExecutionException("Failed to retrieve workflow context.");

               }

               tracingService.Trace("ProcessAssessmentBulkMailing.Execute(), Correlation Id: {0}, Initiating User: {1}",

                   context.CorrelationId,

                   context.InitiatingUserId);

               IOrganizationServiceFactory serviceFactory = executionContext.GetExtension<IOrganizationServiceFactory>();

               IOrganizationService service = serviceFactory.CreateOrganizationService(context.UserId);

               Xrm.XrmServiceContext xrm = new Xrm.XrmServiceContext(service);

               try

               {

                   // TODO: Implement your custom Workflow business logic.

                   //string workflowResultMessage = string.Empty;

                   Boolean allInputsResolved = true;

                   // check we have the correct mailing type

                   if (BulkMailType.Get<String>(executionContext).ToString().Trim().ToLower() != "levy assessment notice bulk mailing")

                   {

                       throw new InvalidPluginExecutionException("Invalid bulk mailing type.");

                   }

                   // determine the output file path

                   //String outputFile = lrUtils.GetOutputFilePath("LevyAssessmentNotices");

                   //if (String.IsNullOrEmpty(outputFile))

                   //{

                   //    throw new InvalidPluginExecutionException("Unable to determine the output file LevyAssessmentNotices.");

                   //}                

                   lrCommonObjects.InitialiseValues();

                   // Retrieve the FetchXML from the User Query

                  // Xrm.XrmServiceContext xrm = new Xrm.XrmServiceContext(service);

                   // get the Levy year name

                   String levyYear = lrUtils.RetrieveLevyYear(xrm, LevyYearId.Get<EntityReference>(executionContext).Id);

                   // determine job mode

                   bool jobModeLive = JobMode.Get<Boolean>(executionContext);

                  //CR96 Fields

                   Xrm.cs_config configEmp = null;

                   var emailaddress = string.Empty;

                   var phonenumber = string.Empty;

                   // only create files if live mode

                   if (jobModeLive)

                   {

                       // create the output file

                       writer = XmlWriter.Create(stream, writersettings);

                       writer.WriteStartDocument();

                       writer.WriteStartElement("LevyAssessments");

                   }

                   // Check if User Cancelled the Job

                   if (!lrUtils.RetrieveCancelJob(context.PrimaryEntityId, xrm, ref workflowResultMessage, executionContext))

                   {

                       tracingService.Trace("Start Time : " + lrCommonObjects.DateStartTime);

                       tracingService.Trace("Retrieve Query : " + RetrieveQuery.Get<String>(executionContext));

                       tracingService.Trace("Levy Year Id : " + LevyYearId.Get<EntityReference>(executionContext).Id.ToString());

                       tracingService.Trace("Bulk Mail Type : " + BulkMailType.Get<String>(executionContext));

                       tracingService.Trace("Return Date : " + ReturnDate.Get<DateTime>(executionContext).ToLocalTime());

                       tracingService.Trace("Job Mode : " + JobMode.Get<Boolean>(executionContext));

                       var queryFetchXml = lrUtils.RetrieveSavedQueryFetchXml(xrm, RetrieveQuery.Get<String>(executionContext));

                       var configQueryFetchXml = lrUtils.RetrieveSavedQueryFetchXml(xrm,"Current Active Config Settings");

                       if (queryFetchXml != null)

                       {

                           tracingService.Trace("Retrieve Query exists");

                           tracingService.Trace("RetrieveQuery.FetchXml : " + queryFetchXml);

                           while (true)

                           {

                               var returnRegisteredEmployersCollection = lrUtils.GetRegisteredEmployersFromSavedQuery(queryFetchXml, service,

                                                                                        ref workflowResultMessage, lrCommonObjects.FetchCount, lrCommonObjects.PageNumber, xrm, executionContext);

                               var configurationCollection = lrUtils.GetConfigSettingsFromSavedQuery(configQueryFetchXml, service,

                                                                                         ref workflowResultMessage, lrCommonObjects.FetchCount, lrCommonObjects.PageNumber, xrm, executionContext);

                               if (configurationCollection != null)

                               {

                                  foreach (var configEntity in configurationCollection.Entities)

                                  {

                                       configEmp = lrUtils.GetConfigSettings(configEntity.Attributes["cs_configid"].ToString(), xrm, ref workflowResultMessage, executionContext);

                                       emailaddress = configEntity.Attributes["cs_emailaddress"].ToString();

                                       phonenumber = configEntity.Attributes["cs_phonenumber"].ToString();

                                  }

                               }

                               if (returnRegisteredEmployersCollection != null)

                               {

                                   if (returnRegisteredEmployersCollection.Entities.Count > 0)

                                   {

                                       lrCommonObjects.TotalCount = returnRegisteredEmployersCollection.Entities.Count;

                                       tracingService.Trace("Total Registered Employers : " + lrCommonObjects.TotalCount);

                                       foreach (var entity in returnRegisteredEmployersCollection.Entities)

                                       {

                                           // Get the registered employer data that is required

                                           Xrm.Account regEmp = lrUtils.GetRegisteredEmployerData(entity.Attributes["accountid"].ToString(), xrm, ref workflowResultMessage, executionContext);

                                           // Get the levy return

                                           var levyReturn = lrUtils.GetLevyReturnForAssessments(entity.Attributes["accountid"].ToString(),

                                                                            LevyYearId.Get<EntityReference>(executionContext).Id.ToString(), xrm, ref workflowResultMessage, executionContext);

                                           EntityCollection assessments = null;

                                           // Get the assessments

                                           if (levyReturn != null && levyReturn.Attributes.Contains("cs_levyreturnid"))

                                           {

                                               assessments = lrUtils.GetAssessments(entity.Attributes["accountid"].ToString(), levyReturn.Attributes["cs_levyreturnid"].ToString(), xrm, ref workflowResultMessage, executionContext);

                                           }

                                           bool recordOK = true;

                                           // BUG #836 19/06/12 AJG

                                           // Check if the Bulk Assessment Block flag is set

                                           if (lrUtils.CheckIfBulkAssessmentBlock(regEmp, ref workflowResultMessage))

                                           {

                                               // block is set so record error and do not process

                                               ErrorWithRecord(entity.Attributes["cs_registrationnumber"].ToString(), "The Bulk Assessment Block flag is Set", executionContext);

                                               recordOK = false;

                                           }

                                           else

                                           {

                                               // check the levy return is present

                                               if (levyReturn == null || !levyReturn.Attributes.Contains("cs_name"))

                                               {

                                                   // No Levy Return Exists

                                                   ErrorWithRecord(entity.Attributes["cs_registrationnumber"].ToString(), "No Levy Return Exists for the given Levy Year", executionContext);

                                                   recordOK = false;

                                               }

                                               else

                                               {

                                                   // Check the levy return status

                                                   if (!levyReturn.Attributes.Contains("statuscode") || ((Microsoft.Xrm.Sdk.OptionSetValue)(levyReturn.Attributes["statuscode"])).Value != ProcessBulkJobs.LevyReturn.StatusCode.ASSESSED)

                                                   {

                                                       // wrong status code - ignore record, but do not report it

                                                       recordOK = false;

                                                   }

                                               }

                                           }

                                           if (recordOK)

                                           {

                                               // Check the assessment name is present - this is now the only field used from the assessment (for the letter subject)

                                               if (assessments == null || assessments.Entities.Count == 0 || !assessments.Entities[0].Contains("cs_name"))

                                               {

                                                   // should not get to here as the levy return status is assessed, but put in just in case

                                                   // assessment name not present

                                                   ErrorWithRecord(entity.Attributes["cs_registrationnumber"].ToString(), "There is no Assessment or the assessment name is not set", executionContext);

                                                   recordOK = false;

                                               }

                                           }

                                           //// Check the Bulk Assessment Block flag is set

                                           //if (recordOK && lrUtils.CheckIfBulkAssessmentBlock(regEmp, ref workflowResultMessage))

                                           //{

                                           //    if (((Microsoft.Xrm.Sdk.OptionSetValue)assessments.Entities[0].Attributes["cs_assessmenttype"]).Value != ProcessBulkJobs.AssessmentType.BONAFIDE)

                                           //    {

                                           //        // assessment set and not BonaFide

                                           //        ErrorWithRecord(entity.Attributes["name"].ToString(), "Bulk Assessment Block is Set and the assessment type is not Bona Fide");

                                           //        recordOK = false;

                                           //    }

                                           //}

                                           if (recordOK)

                                           {    

                                               // record Ok, so can create the letter activity                                                    

                                               if (lrUtils.CreateLetterActivity(new Guid(entity.Attributes["accountid"].ToString()),

                                                   "Levy Assessment " + assessments.Entities[0].Attributes["cs_name"].ToString(), jobModeLive, service, ref workflowResultMessage, executionContext))

                                               {

                                                   tracingService.Trace(entity.Attributes["cs_registrationnumber"].ToString() + " : " + "Letter Activity created successfully");

                                                   // Write the record to the output file                                                        

                                                   //lrUtils.WriteAssessmentFile(entity.Attributes["accountid"].ToString(), levyYear, lrCommonObjects.SharedServicesPhoneNumber,

                                                                          // lrCommonObjects.SharedServicesEmailAddress, writer, regEmp, (Xrm.cs_levyreturn)levyReturn,

                                                                          // jobModeLive, ReturnDate.Get<DateTime>(executionContext), xrm, ref workflowResultMessage);

                                                   //CR96

                                                   lrUtils.WriteAssessmentFile(entity.Attributes["accountid"].ToString(), levyYear, phonenumber, emailaddress,

                                                                         writer, regEmp, (Xrm.cs_levyreturn)levyReturn,jobModeLive, ReturnDate.Get<DateTime>(executionContext),

                                                                         xrm, ref workflowResultMessage, service, executionContext);

                                                   tracingService.Trace(entity.Attributes["cs_registrationnumber"].ToString() + " : " + "Added to output file");

                                                   lrCommonObjects.SuccessCount = lrCommonObjects.SuccessCount + 1;

                                               }

                                               else

                                               {

                                                   allInputsResolved = false;

                                                   lrCommonObjects.ErrorCount = lrCommonObjects.ErrorCount + 1;

                                                   tracingService.Trace(entity.Attributes["cs_registrationnumber"].ToString() + " : " + "Error while creating activity/updating file, Check the stacktrace on server logs");

                                                   lrCommonObjects.strErrors += lrUtils.AppendLine(entity.Attributes["cs_registrationnumber"].ToString() + " : " + "Check the stacktrace on server logs");

                                               }

                                           }

                                       }

                                       lrCommonObjects.DateFinishTime = DateTime.Now;

                                       lrCommonObjects.strMessages += lrUtils.AppendLine(lrCommonObjects.DateStartTime + " " + "Job Started");

                                       lrCommonObjects.strMessages += lrUtils.AppendLine(lrCommonObjects.DateFinishTime + " " + "Job Finished for " + lrCommonObjects.SuccessCount + " " + "records");

                                       lrCommonObjects.strMessages += lrUtils.AppendLine("--");

                                       lrCommonObjects.strMessages += lrUtils.AppendLine("Total records per page : " + lrCommonObjects.TotalCount);

                                       lrCommonObjects.strMessages += lrUtils.AppendLine(lrCommonObjects.SuccessCount + " Records processed");

                                       lrCommonObjects.strMessages += lrUtils.AppendLine(lrCommonObjects.ErrorCount + " Errors");

                                       lrCommonObjects.strMessages += lrUtils.AppendLine("--");

                                       //lrCommonObjects.strMessages += lrUtils.AppendLine("Output File : " + outputFile);

                                       // Check for morerecords, if it returns 1.

                                       if (returnRegisteredEmployersCollection.MoreRecords)

                                       {

                                           // Retrieve Cancel Job value from Recurring Job

                                           if (!lrUtils.RetrieveCancelJob(context.PrimaryEntityId, xrm, ref workflowResultMessage, executionContext))

                                           {

                                               tracingService.Trace("Update Recurring Job");

                                               // Update Recurring Job

                                               lrUtils.UpdateRecurringJob(lrCommonObjects.SuccessCount, lrCommonObjects.ErrorCount, lrCommonObjects.strMessages,

                                                                   lrCommonObjects.strErrors, context.PrimaryEntityId, service, ref workflowResultMessage, executionContext);

                                               // Increment the page number to retrieve the next page.

                                               lrCommonObjects.PageNumber++;

                                           }

                                           else

                                           {

                                               tracingService.Trace("User Cancelled the Job");

                                               lrCommonObjects.strMessages += lrUtils.AppendLine("User Cancelled the Job");

                                               // Update Recurring Job

                                               lrUtils.UpdateRecurringJob(lrCommonObjects.SuccessCount, lrCommonObjects.ErrorCount, lrCommonObjects.strMessages,

                                                                   lrCommonObjects.strErrors, context.PrimaryEntityId, service, ref workflowResultMessage, executionContext);

                                               break;

                                           }

                                       }

                                       else

                                       {

                                           lrUtils.UpdateRecurringJob(lrCommonObjects.SuccessCount, lrCommonObjects.ErrorCount, lrCommonObjects.strMessages,

                                                                   lrCommonObjects.strErrors, context.PrimaryEntityId, service, ref workflowResultMessage, executionContext);

                                           // If no more records in the result nodes, exit the loop.

                                           break;

                                       }

                                   }

                                   else

                                   {

                                       tracingService.Trace("No records found for the System Query");

                                       // Update Message with no records found

                                       lrCommonObjects.strMessages += lrUtils.AppendLine("No records found for the System Query");

                                       lrUtils.UpdateRecurringJob(lrCommonObjects.SuccessCount, lrCommonObjects.ErrorCount, lrCommonObjects.strMessages,

                                                                   lrCommonObjects.strErrors, context.PrimaryEntityId, service, ref workflowResultMessage, executionContext);

                                   }

                               }

                               else

                               {

                                   tracingService.Trace("Error while converting FetchXML to QueryExpression");

                                   // Update Message with no records found

                                   lrCommonObjects.strMessages += lrUtils.AppendLine("Error while converting FetchXML to QueryExpression");

                                   lrUtils.UpdateRecurringJob(lrCommonObjects.SuccessCount, lrCommonObjects.ErrorCount, lrCommonObjects.strMessages,

                                                                   lrCommonObjects.strErrors, context.PrimaryEntityId, service, ref workflowResultMessage, executionContext);

                               }

                           }

                       }

                       if (lrCommonObjects.MaxErrorCount == ProcessBulkJobs.LevyReturnCommonObjects.MAX_ERROR_COUNT)

                       {

                           lrCommonObjects.strErrors += lrUtils.AppendLine("There are more than " + ProcessBulkJobs.LevyReturnCommonObjects.MAX_ERROR_COUNT.ToString() + " errors, please check stacktrace on server logs");

                           lrUtils.UpdateRecurringJob(lrCommonObjects.SuccessCount, lrCommonObjects.ErrorCount, lrCommonObjects.strMessages,

                                                                   lrCommonObjects.strErrors, context.PrimaryEntityId, service, ref workflowResultMessage, executionContext);

                       }

                   }

                   else

                   {

                       tracingService.Trace("User Cancelled the Job");

                       lrCommonObjects.strMessages += lrUtils.AppendLine("User Cancelled the Job");

                       // Update Recurring Job

                       lrUtils.UpdateRecurringJob(lrCommonObjects.SuccessCount, lrCommonObjects.ErrorCount, lrCommonObjects.strMessages,

                                           lrCommonObjects.strErrors, context.PrimaryEntityId, service, ref workflowResultMessage, executionContext);

                   }

                   //  Set workflow output messages

                   WorkflowResultMessage.Set(executionContext, workflowResultMessage);

                   IsWorkflowResultOk.Set(executionContext, allInputsResolved);

               }

               catch (FaultException<OrganizationServiceFault> e)

               {

                   //log.Error("ProcessAssessmentBulkMailing --> " + e);

                   workflowResultMessage = lrUtils.AppendLine("ProcessAssessmentBulkMailing --> " + e.StackTrace);

                   //  Set workflow output messages

                   WorkflowResultMessage.Set(executionContext, workflowResultMessage);

                   // Set Workflow result

                   IsWorkflowResultOk.Set(executionContext, false);

                   tracingService.Trace("Exception: {0}", e.ToString());

                   // Handle the exception.

                   throw;

               }

               finally

               {

                   if (writer != null)

                   {

                       writer.WriteEndElement();

                       writer.WriteEndDocument();

                       writer.Close();

                       string sConnectionString = "";

                       string sContainer = "";

                       string WebHookUrl = "";

                       var configQueryFetchXml = lrUtils.RetrieveSavedQueryFetchXml(xrm, "Current Active Config Settings");

                       var configurationCollection = lrUtils.GetConfigSettingsFromSavedQuery(configQueryFetchXml, service,

                                                                                      ref workflowResultMessage, lrCommonObjects.FetchCount, lrCommonObjects.PageNumber, xrm, executionContext);

                       if (configurationCollection != null)

                       {

                           foreach (var configEntity in configurationCollection.Entities)

                           {

                               sConnectionString = configEntity.Attributes["fuj_azurestorageconnectionstring"].ToString();

                               sContainer = configEntity.Attributes["fuj_containername"].ToString();

                               WebHookUrl = configEntity.Attributes["fuj_logicapphttpwebhook"].ToString();

                           }

                       }

                       stream.Seek(0, SeekOrigin.Begin);

                       UploadAzureBlob.UploadStream(sConnectionString, sContainer, stream, fileName);

                       stream.Dispose();

                       stream.Close();

                       //using (HttpClient httpClient = new HttpClient())

                       //{

                       //   // var retryPolicy = Policy.Handle<HttpRequestException>().WaitAndRetry(5, attempt => TimeSpan.FromSeconds(Math.Pow(2, attempt)));

                       //    var httpResponseMessage = retryPolicy.Execute(() => httpClient.GetAsync(WebHookUrl).Result);

                       //}

                   }

               }

               tracingService.Trace("Exiting ProcessAssessmentBulkMailing.Execute(), Correlation Id: {0}", context.CorrelationId);

           }

           /// <summary>

           /// Sets up the error detail for the record

           /// </summary>

           /// <param name="name"></param>

           /// <param name="errorMsg"></param>

           private void ErrorWithRecord(String name, String errorMsg, CodeActivityContext executionContext)

           {

               ITracingService tracingService = (ITracingService)executionContext.GetExtension<ITracingService>();

               tracingService.Trace(name + " : " + errorMsg);

               lrCommonObjects.ErrorCount = lrCommonObjects.ErrorCount + 1;

               if (lrCommonObjects.ErrorCount > ProcessBulkJobs.LevyReturnCommonObjects.MAX_ERROR_COUNT)

               {

                   lrCommonObjects.MaxErrorCount = ProcessBulkJobs.LevyReturnCommonObjects.MAX_ERROR_COUNT;

               }

               else

               {

                   lrCommonObjects.strErrors += lrUtils.AppendLine(name + " : " + errorMsg);

               }

           }

       }

    }

  • Suggested answer
    a33ik Profile Picture
    a33ik 84,325 Most Valuable Professional on at
    RE: System.IO.FileNotFoundException running custom workflow activity CRM365 online

    Hello Phil,

    Can you please post code of workflow activity here?

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Tip: Become a User Group leader!

Join the ranks of valued community UG leaders

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,494 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,309 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans