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
User fills out form, clicks submit
Custom workflow is executed, user gets redirected
User does things on external page
External page calls URL on my page with parameters
Parameters are read in, determined which Contour record is needed
"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..
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?
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))
{
service.Approve();
}
}
}
Triggering workflow execution on URL call
Ahoy!
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
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..
Comment author was deleted
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
So just like this and I'm done?
That would be splendid :D
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?
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:
is working on a reply...