Copied to clipboard

Flag this post as spam?

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

  • Jan Brinker 77 posts 103 karma points
    Aug 07, 2013 @ 16:59
    Jan Brinker

    Triggering workflow execution on URL call


    I'm currently working on a custom workflow, that kicks in as soon as the user submits a form and then redirects the user with extracted data to an external URL. Thus the "workflow execution chain" is aborted, when the redirect happens. Now I'd like to be totally crazy and pick the execution chain up again from where it left via a callback URL from the page the user was redirected to.

    So the flow would be like this

    1. User fills out form, clicks submit
    2. Custom workflow is executed, user gets redirected
    3. User does things on external page
    4. External page calls URL on my page with parameters
    5. Parameters are read in, determined which Contour record is needed
    6. "Approval" workflows get executed on that record

    Is there a way to achieve this?

    I guess I could also try creating a surface controller, which does the work another custom workflow would do and then set the record state manually. But for this task to work the user needs to specify configuration data, what is easily done with workflows. With surface controllers those variables would need to be set hard in code.. and I'm not a fan of that, especially if it's sensitive data..

  • Tim Geyssens 6524 posts 15306 karma points MVP 2x c-trib
    Aug 07, 2013 @ 18:03
    Tim Geyssens

    Yeah just use the API, if you have the record id that's all you'll need and then you'll need a code snippet that set's the record to approved

  • Jan Brinker 77 posts 103 karma points
    Aug 08, 2013 @ 11:25
    Jan Brinker

    So just like this and I'm done?

    //Get record and form by recordID in the url params
    ApproveRecord ar = new ApproveRecord();
    ar.Execute(record, form);

    That would be splendid :D

  • Jan Brinker 77 posts 103 karma points
    Aug 09, 2013 @ 16:09
    Jan Brinker

    Hm apparently yes and no. I'm struggling to find a way to actually be able to use that snippet. I apparently can't use it in Razor, so what are my options to approve a record? Is there a way in razor? Or how can I do it without Razor?

  • Douglas Ludlow 210 posts 366 karma points
    Aug 09, 2013 @ 21:04
    Douglas Ludlow

    You can run any code in razor, because it is effectively C#. Unfortunately, the code snippet you have there isn't correct. You may want to checkout the Umbraco Contour Documentation and read up on how it works. Tom Fulton has a good code sample on gist. Here's another one:

    @using Umbraco.Forms.Data.Storage
    @using Umbraco.Forms.Core.Services
    var recordId = Request["recordId"];
    if (!string.IsNullOrWhiteSpace(recordId))
        var guid = new Guid(recordId);
        using (var storage = new RecordStorage())
            var record = storage.GetRecord(guid);
            using (var service = new RecordService(record))
Please Sign in or register to post replies

Write your reply to: