Form drafts

It’s possible to instruct the form to keep certain dynamic api parameters for api requests but not trigger the corresponding api request with the post until instructed to do so.

This can be used to make ‘drafts’ from inputs that will not trigger the api calls.

Hold all api request

The following form entry will prevent all dynamic api calls from triggering, but keeps all the parameters intact.

Note that this also affects api calls that are done by presets.

Server will not run any dynamic api calls when the value of the Form.HoldDraft is true. Inputs against these calls can be changed and posted without the actual calls being initiated.

<form method="post">
        <input type="hidden" id="req" name="ErplyApi.Api.Post.myRequest1"
            value="getProducts">

        <label for="id">Records on page</label>
        <input type="text" id="id" name="ErplyApi.Api.PostParam.myRequest1.recordsOnPage"
            value="{{ index .Data.Parameters "ErplyApi.Api.PostParam.myRequest1.recordsOnPage" }}">

        <label for="hold-state">Hold draft</label>
        <input type="checkbox" id="hold-state" name="Form.HoldDraft" value="true">

        <button type="submit">send</button>
    </form>

Hold specific api calls

In order the enrich data with additional possible api calls but hold others as drafts we can use a different input.

All dynamic requests that have the names will not be executed.

<input type="text" id="hold-state" name="Form.HoldDraftFor" value="myRequest2,myRequest3">

Can possibly make stepper type templates using this method. In this sample the same ‘Send’ will run request1 and request2 in sequence.

<form method="post">

        <input type="hidden" id="req" name="ErplyApi.Api.Post.myRequest1"
            value="getProducts">
        <input type="hidden" id="req" name="ErplyApi.Api.Post.myRequest2"
            value="getProducts">
        

        <label for="id">Records on page</label>
        <input type="text" id="id" name="ErplyApi.Api.PostParam.myRequest1.recordsOnPage"
            value="{{ index .Data.Parameters "ErplyApi.Api.PostParam.myRequest1.recordsOnPage" }}">

        <label for="id">Records 2 on page</label>
        <input type="text" id="id" name="ErplyApi.Api.PostParam.myRequest2.recordsOnPage"
                    value="{{ index .Data.Parameters "ErplyApi.Api.PostParam.myRequest2.recordsOnPage" }}">

        {{ if ne .Data.ErplyApi.Api.Requests.myRequest1.Response.Exists true }}
            <input type="text" id="hold-state" name="Form.HoldDraftFor" value="myRequest2">
        {{ end }}

        <button type="submit">send</button>
    </form>