Copied to clipboard

Flag this post as spam?

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


  • Ole Thorsager 5 posts 25 karma points
    Oct 11, 2010 @ 08:37
    Ole Thorsager
    0

    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

    Oct 11, 2010 @ 10:01

    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();

  • Tim 1193 posts 2675 karma points MVP 4x c-trib
    Oct 11, 2010 @ 10:02
    Tim
    0

    Could you post the error that you're getting please?

    Ignore that, should have read the post properly! What @Tim said!

  • Ole Thorsager 5 posts 25 karma points
    Oct 11, 2010 @ 10:25
    Ole Thorsager
    0

    That was exactly what I needed, thanks alot for the fast advice :)

  • Yan 36 posts 56 karma points
    Nov 12, 2010 @ 16:36
    Yan
    0

    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

  • Ole Thorsager 5 posts 25 karma points
    Nov 12, 2010 @ 17:03
    Ole Thorsager
    0

    Hi Yan

    Yes I have a custom workflow on submit which among other things saves the recordid in a separate order table.

  • Yan 36 posts 56 karma points
    Nov 12, 2010 @ 17:58
    Yan
    0

    Hi Ole, Is it possible share your workflow source or advice how to save the recordId in the workflow. Thanks,

  • Harald Ulriksen 207 posts 249 karma points
    Nov 13, 2010 @ 13:18
    Harald Ulriksen
    0

    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

  • Yan 36 posts 56 karma points
    Nov 15, 2010 @ 02:17
    Yan
    0

    Thank you very much, Harald! Great help!

    Yan

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies