Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Refresh list from UI page that is invok from UI action list banner

Nico12
Mega Sage

Hi,

 

We got a List banner UI Action on alm_hardware table that open a UI page in Glidemodal.

The GlideModal contain a form with some fields of the assets form.

 

When user select a record in the list and click on the button, he can update these fields afet clicking on Modal ok button.

 

I have tried the following in the UI Action script but none worked.

if(typeof window == 'undefined'){
	serverValidation();
}

function serverValidation(){
	//location.reload();
	// action.setRedirectURL(returnurl);
	g_list.refresh(1);
}

Is it possible to refresh the list after the button ok is clicked, and all the update done ?

 

Regards,

1 ACCEPTED SOLUTION

Ratnakar7
Mega Sage

Hi @Nico12 ,

 

Yes, it is possible to refresh the list after the button is clicked and the updates are done. One way to achieve this is by using the g_form.submit function in the GlideModal's "OK" button script to submit the form and reload the list.

Here is an example script:

 

function onSubmit() {
  // Submit the form
  g_form.submit();
  
  // Reload the list after a short delay (to allow time for the form to save)
  setTimeout(function() {
    g_list.refresh();
  }, 1000);
  
  // Close the GlideModal
  GlideModal.destroy('myModal');
}

 

You can customize the delay time according to your needs. In this example, the delay is set to 1 second (1000 milliseconds).

 

You can also refer Reload a Form or Related list from a Client Script 

 

If my response was helpful in resolving the issue, please consider accepting it as a solution by clicking on the Accept solution button and giving it a thumbs up 👍. This will benefit others who may have a similar question in the future.

 

Thank you!

Ratnakar

 

View solution in original post

1 REPLY 1

Ratnakar7
Mega Sage

Hi @Nico12 ,

 

Yes, it is possible to refresh the list after the button is clicked and the updates are done. One way to achieve this is by using the g_form.submit function in the GlideModal's "OK" button script to submit the form and reload the list.

Here is an example script:

 

function onSubmit() {
  // Submit the form
  g_form.submit();
  
  // Reload the list after a short delay (to allow time for the form to save)
  setTimeout(function() {
    g_list.refresh();
  }, 1000);
  
  // Close the GlideModal
  GlideModal.destroy('myModal');
}

 

You can customize the delay time according to your needs. In this example, the delay is set to 1 second (1000 milliseconds).

 

You can also refer Reload a Form or Related list from a Client Script 

 

If my response was helpful in resolving the issue, please consider accepting it as a solution by clicking on the Accept solution button and giving it a thumbs up 👍. This will benefit others who may have a similar question in the future.

 

Thank you!

Ratnakar