Home › Forums › Classic DFFS › Add new to multichoice Lookup column
- This topic has 3 replies, 2 voices, and was last updated 3 years ago by Alexander Bautz.
-
AuthorPosts
-
-
November 4, 2021 at 14:43 #35055
Im trying to create a list that is used throughout my site collection that grows organically called CaseType and I cant figure out how to do it with SPJS-Lookup and Autocomplete. CaseType is a multichoice Lookup column on the Newform. If the type of case isn’t listed, I would like the user to be able to add a new one to the list and use that new CaseType in the current item and in the future. Therefore, I added a button to the form that opens the CaseType List newform Dialog box(see attached).
However, when you add the new CaseType, I cannot select that new one to the current form because it isn’t reflected in the multi Lookup yet. If my button refreshes the form after save, I lose all the data I added in the subsequent fields. And since this is a newform, that is an issue. Also, this CaseType list is being used on all other sub sites, Refiners within Search and I cant use managed metadata.
My script for the dialog new form:
<script type="text/javascript"> function displayLayover(url) { var options = SP.UI.$create_DialogOptions(); options.url = url; options.dialogReturnValueCallback = Function.createDelegate( null, null); SP.UI.ModalDialog.showModalDialog(options); } </script> <html><table><tr><td> <input type=button value="Add CaseType" onClick='javascript:displayLayover("https://DOMAIN/sites/##/Remand_Docket/Lists/Case Type/NewForm.aspx?IsDlg=1")'></button> </td></tr></table></html>
- This topic was modified 3 years ago by Michael V. Green.
Attachments:
-
November 4, 2021 at 21:11 #35060
It is unfortunately not possible to add new options to a lookup after you have opened the form that the lookup field is located in without doing a refresh.
I have looked at this earlier, but SharePoint has built in code to ensure only options that existed when the form loaded will be accepted.
Alexander
-
November 4, 2021 at 22:15 #35062
OK; thank you for getting back to me. I believe I found a work around to this issue. Can you tell me how I can move or replicate the Redirect button(See attached) to under the CaseType field in a Header/Html section within the tab?
I am going to tell my users to add a new CaseType via the dialog newform button I created. Then, if they want to use that CaseType on the current form, they will have to click the “Redirect to Editform” button. This will save what they have already entered and the new CaseType will show in the multi select Lookup. It would just be great to have that button under the Lookup field in an HTML Section instead of at the bottom of the form.
Thanks for your help. It is greatly appreciated.
~Mike
Attachments:
-
November 5, 2021 at 12:02 #35066
Add this to your Custom JS to move the button below the lookup column (not a HTML section):
function dffs_ready() { jQuery("#saveAndStayInFormBtn").css({"margin": "5px 0"}).appendTo(jQuery("#dffs_CaseType .ms-formbody")); }
Please note that if your CaseType internal name is not correct you must replace CaseType in the snippet with the correct name.
Alexander
-
-
AuthorPosts
- You must be logged in to reply to this topic.