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();
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.
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:
Did anyone here encountered the same error?
Here are my code:
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.
is working on a reply...