umbraco / Umbraco.Forms.Issues

Public issue tracker for Umbraco Forms
29 stars 0 forks source link

Magic string page field in workflow with Form Delivery API #1215

Closed bjarnef closed 1 month ago

bjarnef commented 1 month ago

Working with workflow we can use magic string, e.g. {email} or page field [#myProperty]. However with Forms Delivery API, I wonder how to handle this?

I have a custom workflow inheriting SendRazorEmail and [#employee] in recipient email.

image

I tried with the following inside workflow:

string? value = _placeholderParsingService.ParsePlaceHolders(Email, false);

Employee property is in this case a single MTNP picker, so I would expect a Guid, which I could resolve looking up the content node from cache or define a custom format function.

Forms API only contains a few endpoints:

image

bjarnef commented 1 month ago

@AndyButland do you know how I can get the reference to the page specific field from within workflow?

However I often find we need to pass in additional data to Umbraco forms / workflow, not just from page level, but sometimes from block although it is probably ideal only to have a single form per page: https://github.com/umbraco/Umbraco.Forms.Issues/issues/578

AndyButland commented 1 month ago

I haven't checked in detail here yet, but first can I check you are passing in the page ID when you submit the form (via the contentId parameter)?

https://docs.umbraco.com/umbraco-forms/developer/ajaxforms#submitting-a-form-entry

The intention here was that you could provide this such that when the form is submitted via the headless API it's processed as if it was hosted on the page provided - such that this information is available to workflows, entry records etc.

bjarnef commented 1 month ago

@AndyButland no, it didn't originally pass in contentId, but after I included that, I can access the page data: https://github.com/umbraco/Umbraco.Forms.Issues/issues/578#issuecomment-2100087920

However in my use-case when using magic string for a Content Picker / MNTP property on page it resolved to Umbraco.Cms.Web.Common.PublishedModels.Employee as string, which wasn't useful :)

and a custom format function wasn't any help here and the property value (or type or property) was returned as string value: https://github.com/umbraco/Umbraco.Forms.Issues/issues/1216

It would be nice it magic strings could resolve the picker as Guid (or array or Guid for multi picker), but I guess it only works for simple property editors like textstring, textarea, number (int and decimal), date...

AndyButland commented 1 month ago

Yes, that's right. In which case I'll close this one since remaining point you raise you mention already has a separate issue. Thanks.