Add new to multichoice Lookup column

Forums Classic DFFS Add new to multichoice Lookup column

Viewing 2 reply threads
  • Author
    Posts
    • #35055
      Michael V. Green
      Participant

      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>
    • #35060
      Alexander Bautz
      Keymaster

      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

    • #35062
      Michael V. Green
      Participant

      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:
      • #35066
        Alexander Bautz
        Keymaster

        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

Viewing 2 reply threads
  • You must be logged in to reply to this topic.