Page 1 of 1

Redirect on Save

Posted: 13 Feb 2018
by TonyDuke
Good Morning,

I am trying to add a function to a New and Edit Form so that on submit, based on certain conditions it will redirect on save to a specific New Form (from the same List)

My unconditional redirect code is as below: -

Code: Select all

fd.onsubmit(function() {
	fd.sourceFormParam('fd_Task_bb60fbb4-0754-4de2-bb50-1eb6565a2b1a_NewForm.aspx?');
	return true;
});
This works fine as long as I navigate directly to the initial New form, however we are encoding some data into the initial URL of the form to pass through data from a previous form and in doing so this seems to break the save function.

The initial clean URL looks like this: -

Code: Select all

https://xxxxxxxxxx.sharepoint.com/ERP/Lists/Sales%20Activities/fd_Task_bb60fbb4-0754-4de2-bb50-1eb6565a2b1a_NewForm.aspx?
The initial encoded URL like this: -

Code: Select all

https://xxxxxxxxxx.sharepoint.com/ERP/Lists/Sales%20Activities/fd_Task_bb60fbb4-0754-4de2-bb50-1eb6565a2b1a_NewForm.aspx?CompanyNameId=474&CompanyName=xxxxxxxx&ContactNameId=&AddressNameId=
When trying to save the form the item is saved to the list but with a number of fields blank and the New Form fails to open with the following error displayed: -
"Invalid data has been used to update the list item. The field you are trying to update may be read only. "

I'm sure its a fairly simple fix, but I just can't get my head around it...

Thanks

Re: Redirect on Save

Posted: 14 Feb 2018
by Nikita Kurguzov
Dear Tony,
If passing parameters in the URL breaks functionality of the new form, I would suggest to store the same data in localStorage instead, you can also use it to retrieve data when the form opens.

Re: Redirect on Save

Posted: 14 Feb 2018
by TonyDuke
Thanks Nikita,

I have now started using sessionStorage and that is working 100%.

Thanks again for your assistance