The SharePoint form redefines CSR (client-side rendering).
I tried adding a new button, which is pretty much like the Save button, except that it redirects another form with the given parameters.
The fact is that the redirect does not work. I tried redirecting by changing the "action" property of the form, but it doesn't seem to count as a count.
Here is the new button: <input id="custom_addLine" type="button" name="custom_addLine" value="+" class="ms-ButtonHeightWidth">
Here is the function called by the button and the addLine method, as follows:
$('#custom_addLine').click(function(event){ event.preventDefault(); addLine(getQueryStringParameter('ID')); }); function addLine(id) { if(!PreSaveItem()) { return false; } var actionUrl = "/Lists/PurchaseRequestLine/NewForm.aspx?PurchaseRequestID="+ id; var encodedActionUrl = encodeURIComponent(actionUrl); var newFormAction = location.pathname + '?Source=' + encodedActionUrl; $('#aspnetForm').attr('action',newFormAction); if(SPClientForms.ClientFormManager.SubmitClientForm('WPQ1')){ return false; } WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions('custom_addLine', "", true, "", "", false, true)); }
getQueryStringParameter is a custom function to retrieve parameters from a URI (which works).
The tricky part is that I want to keep the default action URI if the "Save" button is clicked, so the action parameter has been changed on the fly.
source share