Refresh List Lookup field using Javascript

  • 17 March 2022
  • 4 replies
  • 248 views

Hello,

 

I'd like to know how to refresh a List Lookup field on Nintex Forms On-Premise.

 

I have a form that contains a Lookup List field connected to a 'Client' list on SharePoint 2019 on-prem.  I have also created a JavaScript button (labelled 'Add Client') to add a new item to this list.  This 'Add Client' function successfully updates the 'Client' list with a new 'Client' item via a Window prompt.  However, I haven't found a way to refresh the List Lookup field to reflect the addition in the list.

 

If the form is closed and reopened, I can see the new value(s) in the List Lookup.  However, I'd like to refresh the form in real-time.  Is this possible?

 

Thanks for taking the time to read this.


4 replies

Badge +11

@Rayamondo 


I have something similar, to add new names using a JS button, then close dialog, refresh so new names appear on the dropdown list with new name.


 


This is what works for me:


 


function redirectToNewForm(){var options = {title: "Your Title",url: 'http://xxxxList/allitems.aspx',dialogReturnValueCallback:Function.createDelegate(null, portal_modalDialogClosedCallback)};SP.UI.ModalDialog.showModalDialog(options);}function openDialog(pageUrl) {var options = {url: pageUrl,title: 'Employee List',allowMaximize: false,showClose: true,width: 800,height: 880,dialogReturnValueCallback: RefreshOnDialogClose};SP.SOD.execute('sp.ui.dialog.js', 'SP.UI.ModalDialog.showModalDialog', options);}

Hey @Nunezma - thanks for your reply.


 


I have used your code, which is a nicer solution than what I had 🙂  However, I still have the same issue where the List Lookup field is not being updated with the latest addition.  The new item is successfully created in the list, but is not available in the List Lookup.

Badge +11

@Rayamondo 


the only other thing I have is call the JS funciton using a javascript button and under client click I have: OpenDialog('listURL')

Hey @Nunezma,


 


I have used your openDialog function as a client click already, and it works nicely to display the newItem page.. just for some reason doesn't update the List Lookup.  I haven't used the redirectToNewForm() function at all though; I assumed the openDialog function would do all I needed.


 


Thanks again for your responses.

Reply