Copied to clipboard

Flag this post as spam?

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


  • Thomas Kahn 602 posts 506 karma points
    Feb 14, 2013 @ 13:16
    Thomas Kahn
    0

    Specifying the workflow setting "Where to save" when using RestContour?

    Hi!

    I'm using Cultiv RestContour on an Umbraco 4.11.4 site and I have the basic functionality up and running. The data from my form is saved in Contour using AJAX. I also supply the parameter "nodeId" from the page where the form is currently displayed using a hidden form field, like this:

    <input type="hidden" name="nodeId" id="nodeId" value="<umbraco:Item field="pageID" runat="server" />" />
    

    This also works since I can see the ID of the page from which when I look at the entries in Contour. But here's the problem: I'm using the XSLT-path option for the "Where to save" setting in Contour to make it save the data from the form as an Umbraco node/page. The XSLT I'm using looks like this:

    $currentPage/descendant-or-self:: *[@isDoc][name()='QuestionFolder']/@id

    This XSLT works when I run the Contour form as a regular form (not using RestContour) but something breaks when you submit the data using RestContour. I'm not surprised since it's a whole different way of submitting form data and you lose the context in which the form normally exists. So I'm thinking the $currentPage doesn't make much sense when the form data is submitted using RestContour.

    A long shot was adding the nodeId parameter to see if it would affect the workflow but unfortunatelly it didn't.

    Can you think of a way that I can make the CultivRest form submission context aware so the workflow will know where it should create the new node? The other option would be to create an individual form for each page where it's used but we're talking 15-20 pages here so that would be very tedious to set up and difficult to manage (settings for each form etc).

    Thanks in advance!

    /Thomas Kahn

  • Thomas Kahn 602 posts 506 karma points
    Feb 14, 2013 @ 16:31
    Thomas Kahn
    100

    I have found a solution.

    You can set a dynamic parameter in the form of a node ID as the parameter for the workflow setting "Where to save", which makes sense. So, using the Umbraco Contour syntax and following the example code above, you add [@nodeId] as the "Where to save" parameter and the page will be saved as a subpage to the node where the form is located.

    In my case I need the page to be saved to a subpage to the page where the form is so I wrote a simple XSLT that I use to generate the hidden field and set its value.

    <xsl:template match="/">
     <xsl:variable name="nodeId" select="$currentPage/descendant-or-self::*[@isDoc][name()='QuestionFolder']/@id"></xsl:variable>
     <input type="hidden" name="nodeId" id="nodeId" value="{$nodeId}"/>
    </xsl:template>
    

    This is inserted as a macro in the form, a hidden field is inserted with the node ID to subpage where I want to save the page generated by the workflow.

    /Thomas

Please Sign in or register to post replies

Write your reply to:

Draft