Redirect after saving Form in Portal - nothing happens

Sue Frost
Giga Guru

I'm building my first portal. Of course it's on a tight timeline.

My plan is to display a table to the user. They'll pick their tracking record, open it, update it and submit/save it. That's working.

Then, I'd like to redirect them back to the homepage. That is NOT working.

I have a "Submit Me" ui action - currently it only contains "current.update()". It's not client callable.

It looks like "action.setRedirectURL(current);" doesn't work and is being ignored.

What should I be doing to redirect the user from this form? Does opening the form from a table record use a form widget?

 

Here's my UI Action:

find_real_file.png

 

Thank  you!

 

4 REPLIES 4

xiaix
Tera Guru

find_real_file.png

That would work, except Client Callable ui actions are ignored in the service portal. So I can use the 'Onclick' field to call the function.

I tried just making the call the first thing in my Script:

//current.update();
//gs.addInfoMessage("Got it!");
save_and_exit();

function save_and_exit()
{
	gsftSubmit(null, g_form.getFormElement(), 'sysparm_save_and_exit');
}

if (typeof window == 'undefined')
	serverResolve_sysparm_save_and_exit();

function serverResolve_sysparm_save_and_exit()
{
	current.update();
	var url = 'https://XXXXXXX.service-now.com/stride?sysparm_domain_restore=false&sysparm_stack=no';
	action.setRedirectURL(url, "_self");
}

 

And that's giving me a understandable runtime error:

Server Javascript error "g_form" is not defined.

 

 

 

 

Okay, so I'm confused.  Perhaps because I've never used a "UI Action" on the Service Portal.  I assumed UI Actions were for ServiceNow forms (internal) only.

 

When you say "Display a table to the user", how are you doing this on the Service Portal?  If you're using a custom widget, I can easily show you how to redirect.

Hi David,

I am doing this on a Service Portal. I tried something different yesterday because I don't think tables & UI Actions are the way to go on a Service Portal.

BUT - for "Display a table to the user", I'm using the "Data Table from Instance Definition" widget*. That displays a list of records. I can click a record and it opens (in a form widget? I can't tell.) I can make changes to the form and click on the ui action to save the record. When I've done that, I'm still sitting on the record. I need that UI Action to navigate back to the index page.

* Well, with your first reply, it's now a custom widget cloned from this one - "Data Table with New Button from Instance Definition".

- - - -

All that said, I've been trying to rejig this entirely to use two tables and two record producers - one to capture the user name / location / walking goal and a second table/producer to capture the date & total KM walked.

That's coming along except the Record Producers don't display on the portal page. They did yesterday. Today they don't. It's going to be one of those days.