I am trying to approve a record from code (when I get a callback from epay)
But an error occur when I try to create the Record object. Below is a sample of the process (would be nice if I could get a record by ust applying the recordId)
Hi Ole, how you get the guid (record id ) first palce? Did you have custom work flow after submit the form, and save the record id to session or ? Try to understand how to pass the record id to the payment gateway? I try to do the same thing but not sure how. thanks in advance
namespace Ulriksen.Silhouette { public class ContextUpdateWorkflow : WorkflowType { public override Umbraco.Forms.Core.Enums.WorkflowExecutionStatus Execute(Record record, RecordEventArgs e) { e.Context.Items[ItemKey] = record.Id; return Umbraco.Forms.Core.Enums.WorkflowExecutionStatus.Completed;
}
public override List<Exception> ValidateSettings() { return new List<Exception>(); }
[Umbraco.Forms.Core.Attributes.Setting("Item key", description = "Key used when adding the record Id to the Context.Items ", control = "Umbraco.Forms.Core.FieldSetting.TextField")] public string ItemKey { get; set; }
public ContextUpdateWorkflow() { this.Name = "Store record id in context"; this.Id = new Guid("15d2f92f-2134-43fb-bd13-35120f36997a"); this.Description = "This will add the record id of the newly created record to the context with key recordId"; } } }
Problem retrieving a Record object
I am trying to approve a record from code (when I get a callback from epay)
But an error occur when I try to create the Record object. Below is a sample of the process (would be nice if I could get a record by ust applying the recordId)
XPathNodeIterator iterator = Umbraco.Forms.Library.GetRecord(recordId);
XmlNode node = ((IHasXmlNode)iterator.Current).GetNode();
// Below throws a Guid should contain 32 digits with 4 dashes (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx).
Record record = Record.CreateFromXmlNode(node);
RecordService service = new RecordService(record);
service.Approve();
service.Dispose();
Comment author was deleted
Hi could you try fetching it by using the RecordStorage object
SHould be something in the line of
RecordStorage rs = new RecordStorage();
Record r = rs.GetRecord(guid);
rs.dispose();
Could you post the error that you're getting please?
Ignore that, should have read the post properly! What @Tim said!
That was exactly what I needed, thanks alot for the fast advice :)
Hi Ole, how you get the guid (record id ) first palce? Did you have custom work flow after submit the form, and save the record id to session or ? Try to understand how to pass the record id to the payment gateway? I try to do the same thing but not sure how. thanks in advance
Hi Yan
Yes I have a custom workflow on submit which among other things saves the recordid in a separate order table.
Hi Ole, Is it possible share your workflow source or advice how to save the recordId in the workflow. Thanks,
Yan,
I have a sample workflow which saves the id to the Context.Items. See http://harald.ulriksen.net/2010/6/2/getting-id-of-newly-created-contour-record.aspx
I've added the code sample here
namespace Ulriksen.Silhouette
{
public class ContextUpdateWorkflow : WorkflowType
{
public override Umbraco.Forms.Core.Enums.WorkflowExecutionStatus Execute(Record record, RecordEventArgs e)
{
e.Context.Items[ItemKey] = record.Id;
return Umbraco.Forms.Core.Enums.WorkflowExecutionStatus.Completed;
}
public override List<Exception> ValidateSettings()
{
return new List<Exception>();
}
[Umbraco.Forms.Core.Attributes.Setting("Item key",
description = "Key used when adding the record Id to the Context.Items ",
control = "Umbraco.Forms.Core.FieldSetting.TextField")]
public string ItemKey { get; set; }
public ContextUpdateWorkflow()
{
this.Name = "Store record id in context";
this.Id = new Guid("15d2f92f-2134-43fb-bd13-35120f36997a");
this.Description = "This will add the record id of the newly created record to the context with key recordId";
}
}
}
Cheers,
Harald
Thank you very much, Harald! Great help!
Yan
is working on a reply...