Saturday, February 7, 2015

Add custom script to Nintex forms

Share/Save/Bookmark

At the end of this blog post you will learn how to

- Submit data to mulitple lists from a single form(here Nintex)
- Create a new item using client side script(Jquery)
- Have your own code/javascript run when submitting the OOTB submit/save button
- Add custom script or jquery in Nintex forms accessing controls



NWF$(document).ready(function () {

var formclick = $("input[commandtype*='Save']").attr("onclick");
formclick = "if(!UpdateContacts()){return false;};" + formclick.replace("javascript:","");
$("input[commandtype*='Save']").attr("onclick",formclick);

});

Above function will bind custom script/function to the OOB save/submit button on the Nintex form but for some reason i could not get the client validation happen before the submit works.

function UpdateContacts()
{

 mode = "New";
 var aname = $('#'+accountnameCtrl).val();
 var fn = $('#'+firstnameCtrl).val();
 var ln = $('#'+lastnameCtrl).val();
 var email = $('#'+emailCtrl).val();
 var phone = $('#'+phoneCtrl).val();

  $().SPServices({
        operation: "UpdateListItems",
        async: false,
        batchCmd: "New",
        listName: "Contacts",
        valuepairs: [["FirstName", fn],["LastName", ln],["Phone",phone],["Email",email]],
        completefunc: function(xData, Status) {
        console.log(status);

    $(xData.responseXML).find("ErrorText").each(function() {
     alert("Error :"+$(this).text());
    });
    }

});

}


Subscribe

No comments:

Post a Comment