Copied to clipboard

Flag this post as spam?

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


  • AbsolutelyN 89 posts 437 karma points
    Sep 30, 2021 @ 15:13
    AbsolutelyN
    0

    Umbraco 9 upgrade - Forms issue

    I've just upgraded a site I'm working on from 8 to 9. The whole thing has been really easy despite coming to asp.net core / .net 5 completely new. Brilliant work and it's so much faster!

    However the site already had some umbraco forms. I've installed Umbraco.Forms 9.0.0 and forms section appears in the backend. However the existing forms built before upgrade are not there.

    The old form submitted data is still in the database tables - UFRecords table etc.

    Do I need to re-create the forms?

    The site also uses a custom WorkflowType which also is not displaying as an option if I create a new form. The only change seemed to be

    public override WorkflowExecutionStatus Execute(Record record, RecordEventArgs e)
    

    to

    public override WorkflowExecutionStatus Execute(WorkflowExecutionContext context)
    

    Am I missing something obvious regarding upgrading forms? Struggling to find any documentation on changes.

    Thanks for any input.

  • Søren Gregersen 441 posts 1884 karma points MVP 2x c-trib
    Sep 30, 2021 @ 15:28
    Søren Gregersen
    0

    Hi,

    Umbraco Forms for Umbraco 9 does not support forms as files.

    I would suggest looking into settig up your v8 site so store the files in the database. The new version should be able to se the files in the database.

    Just a heads up, i haven't tried the method myself, but for everything else in v9 it's code upgrade only.

    HTH :)

  • AbsolutelyN 89 posts 437 karma points
    Sep 30, 2021 @ 15:34
    AbsolutelyN
    0

    Brill thanks - new to forms and had not even seen that option. I can only find documentation on v8 but I guess if I change it on the v8 site and then migrate the database that might work.

    https://our.umbraco.com/Documentation/Add-ons/UmbracoForms/Developer/Forms-in-the-Database/index-v8

  • Andy Butland 422 posts 2334 karma points MVP 4x hq c-trib
    Sep 30, 2021 @ 15:42
    Andy Butland
    100

    Hi - yes, as Søren says for V9 we're only supporting storage of Forms in the database. The docs for this are here, which links off to a page detailing how to enable this in V8.

    For discussion on the reasons why we made this change, please also see here.

    You've found the only method signature change - we did this just as the previous one was a little odd (in that RecordEventArgs also held details of the Record, and felt we could improve the naming). There's an example with the new syntax here.

    With Umbraco V9 doing less type scanning, you'll also need to register your new workflow. The core ones are done in an extension method on IUmbracoBuilder:

    public static IUmbracoBuilder AddUmbracoForms(this IUmbracoBuilder builder)
    {
        // omitting all but the workflow registrations...
    
        builder.WithCollectionBuilder<WorkflowCollectionBuilder>()
            .Add<ChangeRecordState>()
            .Add<PostAsXml>()
            .Add<PostToUrl>()
            .Add<SaveAsFile>()
            .Add<SaveAsUmbracoNode>()
            .Add<SendEmail>()
            .Add<SendRazorEmail>()
            .Add<SendXsltEmail>()
            .Add<Slack>()
            .Add<SlackV2>();
    
        return builder;
    }
    

    Which we call from a composer (but if you prefer you could call the extension method from StartUp:

    public class UmbracoFormsComposer : IComposer
    {
        public void Compose(IUmbracoBuilder builder) => builder.AddUmbracoForms();
    }
    

    So you will need to do something similar for your workflow type.

    This last part I've realised isn't documented - other than now here I guess - so I'll make sure we add that.

    Hope that helps.

    Andy

  • AbsolutelyN 89 posts 437 karma points
    Sep 30, 2021 @ 17:14
    AbsolutelyN
    0

    Thanks Andy, all sorted.

    To import the missing forms I simply enabled database storage as mentioned above in the original v8 site, saved each one and then backed up the database and restored it over the v9 database. It then ran the upgrade on the updated DB and all done.

    Adding the custom workflow was really simple with a quick custom composer.

    public class UmbracoFormsComposer : IComposer
       {
           public void Compose(IUmbracoBuilder builder)
           {
               builder.WithCollectionBuilder<WorkflowCollectionBuilder>().Add<MyCustomWorkflow>();
           }
       }
    

    The only other minor change was updating the UI code to render the form

    @await Umbraco.RenderMacroAsync("renderUmbracoForm", new { FormGuid = form, FormTheme = "", ExcludeScripts = "1" })
    

    Fantastic work on v9 - upgrading has been made so much easier than v7 to v8.

Please Sign in or register to post replies

Write your reply to:

Draft