Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Romeo Cadaoas 31 posts 92 karma points
    Aug 01, 2017 @ 06:33
    Romeo Cadaoas
    0

    RecordService.Instance.Approve(record, form) Value cannot be null. Parameter name: umbracoContext Error

    I'm executing RecordService.Instance.Approve(record, form) asynchronously to update the status to approved but I'm getting the following error:

    System.ArgumentNullException (umbraco)
                 ...      Value cannot be null.
                 ...      Parameter name: umbracoContext
                 ...         at Umbraco.Web.Security.MembershipHelper..ctor(UmbracoContext umbracoContext, MembershipProvider membershipProvider, RoleProvider roleProvider)
                 ...         at Umbraco.Forms.Data.StringHelper.ParsePlaceHolders(HttpContext context, Record record, String value)
                 ...         at Umbraco.Forms.Data.StringHelper.ParsePlaceHolders(Record record, String value)
                 ...         at Umbraco.Forms.Core.Services.WorkflowService.ExecuteWorkflows(List`1 workflows, RecordEventArgs e)
                 ...         at Umbraco.Forms.Core.Services.WorkflowService.ExecuteWorkflows(Record record, Form form, FormState state, Boolean editMode)
                 ...         at Umbraco.Forms.Web.Services.RecordService.Approve(Record record, Form form)
    

    Did anyone here encountered the same error?

    Here are my code:

    var task = new System.Threading.Tasks.Task(() =>
                                {
                                        if (formRecord != null)
                                        {
                                            Umbraco.Forms.Core.Record record = GetRecordByUniqueID(formRecord.UniqueId);
                                            if (record != null)
                                            {
    
    
                                                #region Update Record Status
                                                try
                                                {
                                                    //Update form record status to approved 
                                                    using (var formStorage = new Umbraco.Forms.Data.Storage.FormStorage())
                                                    {
                                                        Umbraco.Forms.Core.Form form = formStorage.GetForm(record.Form);
    
                                                        if (record.RecordFields.Any(x => x.Value.Field.Caption == "Payment Reference"))
                                                        {
                                                            record.GetRecordField("Payment Reference").Values.Clear();
                                                            record.GetRecordField("Payment Reference").Values = new List<object> { tranid };
                                                        }
                                                        RecordService.Instance.Approve(record, form); 
    
                                                    }
                                                }
                                                catch (Exception ex)
                                                {
    
                                                }
                                                #endregion
                                            }
                                        }
    
    
                                });
                                task.Start();
    
  • Eric Wilkinson 12 posts 82 karma points
    Mar 22, 2018 @ 15:16
    Eric Wilkinson
    0

    Also encountering this unless you say task.Wait(); after the task.Start(), but that defeats the purpose of needing to Approve the workflow after the submit workflow is called.

Please Sign in or register to post replies

Write your reply to:

Draft