AnsweredAssumed Answered

I'm looking for a better way to perform JavaScript actions prior to form save.  I'm using the method described in https://community.nintex.com/thread/2355 (and appreciate it's ingenuity).

Question asked by jboland@uoregon.edu on Oct 15, 2016

However, the solution described in thread 2355 uses an empty CSS class as a psuedo-identifier.  Much better would be the ability to use an actual identifier to reference the save action method.   Here's more of a description of what I do now:

 

A button labelled "Save" performs a JavaScript action.  Specifically, it calls the function below.  The function builds and assigns a Title value, then calls the form's save action.  It is able to do so because the (now hidden) save button for the form has the CSS class of "saveClass".  The HTML of the form page shows that the save button action is implemented with an HTML input element (below) that has saveClass as an attribute.

 

// The preSave function generates a unique value for the Title field before saving the form.
// For details on this approach, see https://community.nintex.com/thread/2355.
function preSave() {
 var reqDate = NWF$("#" + cboRequestorTrainingType).val();
 var arrReqDate = reqDate.split("(");
 var newTitle = arrReqDate[0] + "_" + NWF$("#" + txtSiteCity).val() + "_" + NWF$("#" + dteRequestedStartDate).val();
 NWF$("#" + txtTitle).val(newTitle);
 NWF$(".saveClass").click();
};

<div class="nf-filler-control-inner">
<input type="submit" name="ctl00$UxContentPlaceHolder$FormFiller$FormView$ctl74$ctl12$e1c6f63c_4a69_4809_a0dc_47dff3ee3bb3" value="Save" onclick="if (!NWF.FormFiller.Functions.ProcessFormsValidation(this, &#39;NfValidationGroupctl00UxContentPlaceHolderFormFiller&#39;, function () { })) { return false; } ;WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions(&quot;ctl00$UxContentPlaceHolder$FormFiller$FormView$ctl74$ctl12$e1c6f63c_4a69_4809_a0dc_47dff3ee3bb3&quot;, &quot;&quot;, true, &quot;NfValidationGroupctl00UxContentPlaceHolderFormFiller&quot;, &quot;&quot;, false, false))" id="ctl00_UxContentPlaceHolder_FormFiller_FormView_ctl74_ctl12_e1c6f63c_4a69_4809_a0dc_47dff3ee3bb3" class=" saveClass nf-disableonsubmit" commandType="Save" style="height:100%;width:100%;cursor:pointer;" />
</div>

Outcomes