How can I get current form view in Service Portal?

trikuxabi
Tera Contributor

I'm currently trying to get a form's view in Service Portal.

In the back-end using getView() works without a hitch, but it isn't accessible from the portal. g_form.getViewName() doesn't give JavaScript errors, but it always returns an empty string. I have also tried to get the "view" parameter from the URL directly, with no success.

Any help will be appreciated!

Thank you!

Xabi

8 REPLIES 8

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

Can you share the script which is giving it as empty?

Regards

Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Hi! Of course 🙂

var view = g_form.getViewName();
alert(view);

The JS alert displayed with these lines (in an onLoad Client Script) appears blank.

Thanks for your support!

Xabi

Hi,

Is there any view on that table?

Is this code showing up some view name on native UI

Mark Correct if this solves your issue and also mark Helpful if you find my response worthy based on the impact.
Thanks
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Hi,

Yes, there are views in that form, as that same code does return the active view's name when using the back-end.

I just need this same functionality on the Service Portal.

Thanks in advance!