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.

GlideTransaction.get().response.sendRedirect broken in Jakarta / sendRedirect

jean-lucchatton
Kilo Guru

Hello,

Our instance uses a couple of GlideTransaction.get().response.sendRedirect() calls. It was ok on Helskinki version but is broken on Jakarta.

We receive the following error message "Attempted script access to inaccessible member denied - com.glide.sys.Transaction:getResponse:()Ljavax/servlet/http/HttpServletResponse;

Evaluator: java.lang.SecurityException: Illegal access to method getResponse in class com.glide.sys.Transaction".

I've looked in the community forum and find that this API was not documented. Therefore ServiceNow has certainly decided to change something or decided to restrict his usage.

Any idea how to get the same functionality ?

Thanks and regards

Jean-Luc

15 REPLIES 15

Hey Hichem,



Please, can you post the whole function here so that even we get the perspective of the functionality .. Please if you can


Hi surendraraika,



Hereunder is the whole code snippet with at line 69 the GlideTransaction.get().response.sendRedirect   which is not working anymore :



if (GlideTransaction.get()) {


      var transaction = GlideTransaction.get();



      if (transaction.URLString) {


              // Checks if the end-user is not on the login page (welcome page)


              // or on a login or logout page


              if (transaction.URL != "/welcome.do" &&


                      transaction.URL.indexOf("login") == -1 &&


                      transaction.URL.indexOf("logout") == -1) {


                             


                      var redirectionURL = "";



                      // Checks if the end-user is not already in the CMS


                      if (GlideTransaction.get().isVirtual() == false) {


                              // Suffix of the CMS to redirect to


                              redirectionURL = cmsSuffix;


                              var targetURL = transaction.URLString;



                              // If the end-users tries to navigate directly to an Incident


                              if (targetURL.indexOf("incident.do?") != -1) {


                                      redirectionURL = this._generateRedirectionURL("sys_id", "incident", redirectionURL);


                                      // If the end-users tries to navigate directly to a Report


                              } else if (targetURL.indexOf("sys_report_display.do?") != -1) {


                                      redirectionURL = redirectionURL + targetURL;


                                      // If the end-users tries to navigate directly to a Requested Item


                              } else if (targetURL.indexOf("sc_req_item.do?") != -1) {


                                      redirectionURL = this._generateRedirectionURL("sys_id", "sc_req_item", redirectionURL);


                                      // If the end-users tries to navigate directly to a Catalog Item


                              } else if (targetURL.indexOf("sc_cat_item.do?") != -1) {


                                      redirectionURL = this._generateRedirectionURL("sys_id", "sc_cat_item", redirectionURL);


                              } else if (targetURL.indexOf("com.glideapp.servicecatalog_cat_item_view.do?") != -1) {


                                      redirectionURL = this._generateRedirectionURL("sysparm_id", "sc_cat_item", redirectionURL);


                                      // If the end-users tries to navigate directly to a Knowledge article


                              } else if (targetURL.indexOf("kb_view.do?") != -1) {


                                      var kbNumber = GlideTransaction.get().getRequestParameter("sysparm_article");


                                      if (kbNumber) {


                                              var kbArticle = new GlideRecord("kb_knowledge");


                                              if (kbArticle.get("number", kbNumber)) {


                                                      redirectionURL = redirectionURL + "/knowledge.do?sysparm_document_key=kb_knowledge," + kbArticle.sys_id;


                                              }


                                      } else {


                                              var kbSysID = GlideTransaction.get().getRequestParameter("sys_kb_id");



                                              if (kbSysID) {


                                                      redirectionURL = redirectionURL + "/knowledge.do?sysparm_document_key=kb_knowledge," + kbSysID;


                                              }


                                      }


                                      // If the end-users tries to navigate directly to an Approval


                              } else if (targetURL.indexOf("sysapproval_approver.do?") != -1) {


                                      redirectionURL = this._generateRedirectionURL("sys_id", "sysapproval_approver", redirectionURL);


                              }


                              // If the end-user is already in the CMS, checks if he accesses the homepage.


                              // This is a workaround for a ServiceNow bug when the user types a CMS suffix


                              // that does not exist. The default behaviour of ServiceNow is to redirect


                              // the end-users to their Homepage (i.e.: not in the CMS)


                      } else if (GlideTransaction.get().isVirtual() == true && transaction.URL == "/home.do") {


                              // Suffix of the CMS to redirect to


                              redirectionURL = "/" + cmsSuffix;


                      }


                      /*else if( (transaction.URL.indexOf('_list.do') != -1) && (this._URLStringISAutorizedOrNot(transaction.URLString) == true ) ) {


                      // Suffix of the CMS to redirect to


                      redirectionURL = "/" + cmsSuffix;


                      }*/




                      if (redirectionURL != "") {


                              // Redirects the end-user. If not one of the cases above, it will


                              // always be the CMS homepage


                              transaction.response.sendRedirect(redirectionURL);



                      }


             


      }


Morning,



Did anyone get anywhere with this? I've found the same issue upgrading to Jakarta this morning. The sendRedirect's I've got inside a Processor doesnt seem to be working anymore.


Hi,



I've logged a ticket on HI and I'm waiting feedback from them.



For the moment the only info that I have is that it seems to be linked to a know PB :



Core Platform PRB1096460 Illegal access warnings similar to illegal access to method getURLString in class com.glide.sys.Transaction - post Jakarta upgrade



Kingston release


Ok..so I've done some further troubleshooting..it seems the Redirect method does work. My code not working in Jakarta is:


g_response.sendRedirect(


gs.getProperty("glide.servlet.uri") + "nav_to.do?uri=/" + encodeURIComponent(ritm.getLink())


);


Manually entering in the URL and running that is fine and so I may change the way I make up the URL for now.