Get node (id) of prevalue source item in workflowtype
Hi,
I've created a custom workflow type with Countour v 3.0.23.
This purpose is to send the form data to another data store. (in this case, a queue).
I hook my workflowtype in on the "submitted" event".
One field is a checkboxlist with a prevalue source of Umbraco documents as prevalue type.
In the workflow I have a fieldmapper control to map this property; but I don't think this is really relevant.
No my question is how that I can easily access the node(s) that were chosen or it's Id's. Because now all I get is the labels from the saved record.
I need this because there is data stored on the node that I want to pass to the other data store. The best scenario would be the node, otherwise the nodeId to get the node myself from the cache.
You could fetch it by node id but this is the least performant way, looking into a way to just have the id available in the workflow
var umbracoHelper = new UmbracoHelper(UmbracoContext.Current);
var contentNode = umbracoHelper.TypedContentSingleAtXPath(String.Format("//* [@isDoc and @nodeName = '{0}']", name);
You should also be able to fetch the prevalue source from within the workflow, something like
var field = e.Form.AllFields.Where(x => x.PreValues.Any() && x.Id = new Guid("")).Single();
var prevalueId = field.PreValues.Where(x => x.Value == "value");
If you add the following snippet to your workflow it should populate the prevalues. I'll look into adding this at the correct place in the core but for know you can use this as a workaround
foreach(var field in e.Form.AllFields)
{
if(field.PreValueSource != null)
field.PreValueSource.Type.LoadSettings(field.PreValueSource);
field.PreValues = field.PreValueSource.Type.GetPreValues(field);
}
Get node (id) of prevalue source item in workflowtype
Hi,
I've created a custom workflow type with Countour v 3.0.23.
This purpose is to send the form data to another data store. (in this case, a queue). I hook my workflowtype in on the "submitted" event".
One field is a checkboxlist with a prevalue source of Umbraco documents as prevalue type.
In the workflow I have a fieldmapper control to map this property; but I don't think this is really relevant.
No my question is how that I can easily access the node(s) that were chosen or it's Id's. Because now all I get is the labels from the saved record.
I need this because there is data stored on the node that I want to pass to the other data store. The best scenario would be the node, otherwise the nodeId to get the node myself from the cache.
Any help is much appreciated.
Tnx!
Comment author was deleted
How are you getting the values from the record ? Mind sharing a code snippet
Yes, srry that might help :))
Fields property on workflowtype:
Code to get a list of the mapped values:
That mapping code comes from the overridden " WorkflowExecutionStatus Execute(Record record, RecordEventArgs e)" method ofcourse
Comment author was deleted
You could fetch it by node id but this is the least performant way, looking into a way to just have the id available in the workflow
var umbracoHelper = new UmbracoHelper(UmbracoContext.Current); var contentNode = umbracoHelper.TypedContentSingleAtXPath(String.Format("//* [@isDoc and @nodeName = '{0}']", name);
You should also be able to fetch the prevalue source from within the workflow, something like
var field = e.Form.AllFields.Where(x => x.PreValues.Any() && x.Id = new Guid("")).Single(); var prevalueId = field.PreValues.Where(x => x.Value == "value");
Hi Tim,
Thanks for your reply!
The problem is that in the workflow only the fields' prevaluesource is known.
The prevalues list is null when I hook my custom workflow into the "Ater submit" event in the Form's workflow.
In the View of that field the Prevalues are present.
Comment author was deleted
Ok will setup a test site to see what is needed to get the ids, will report back later today
Comment author was deleted
Hey,
If you add the following snippet to your workflow it should populate the prevalues. I'll look into adding this at the correct place in the core but for know you can use this as a workaround
Comment author was deleted
of course once the prevalues are populated you can filter them by value to get the correct id...
is working on a reply...