Maximo Open Forum

 How to script redirect header response from OSLC script

  • Integrations
David Shaw's profile image
David Shaw posted 05-04-2022 05:11
Hi,

I am working on an integration currently and am struggling to remove the middleware I currently use.
My current setup involves:
  • The user in Maximo being sent to an external website via script service.openURL()
  • The user performs actions on the external website
  • This results in the external site POSTing an XML document to a URL
  • This URL is being listened to by Node-Red
  • Node-Red processes the XML and posts required data in via the MIF
  • Node-Red then send a 303 redirect URL to the browser and forwards the user to a specific record in Maximo.
I am looking to remove the Node-Red section from this and handle it entirely within script.
I have changed the URL the HTTP POST is sent to to https://MAXIMOHOST/maximo/oslc/script/scriptname

My script is processing the XML properly, but the user is being left on a blank screen.  How do I direct the browser to a URL?
I have tried the service.openURL() but it does not do anything. I presume as it is not  running interactively.
I want to try sending a status code of 303 back to the browser with a location header but I cannot find how to send this.

Does anyone know how I can achieve this?

Regards
Dave S
Steven Shull's profile image
Steven Shull
With the REST API, unless you're doing it in local side JavaScript, the script is being fired on the server of the external website and not in context of this user. Understanding if the POST occurs server side is important as it would eliminate the script handling the redirect. 

Since you had the ability to configure the URL to POST the XML document to, do you have the ability to redirect in that external site? That's where it would make the most sense. I'd expect a flow like this:

1) User is redirected to external site
2) User creates record in external site
3) External site sends a synchronous REST API call to automation script
4) External site redirects to Maximo URL after success

In step 3 you can provide a body or header of where to redirect to the external site. As long as you can have the external site redirect that seems like the cleanest approach.
David Shaw's profile image
David Shaw
Hi Steve,
I don't have an option to reply to you, this is all I can do. The external website isn't mine so I can't get any configuration on it.  This is actually using the standard cXML so should be the same when I connect to other companies using it as well. So asking them to change something wouldn't work.
I believe they are POSTing through the users browser. I know that if I put something in the response body in the script it appears in the uesrs webpage.  I was hoping to alter the response header but can't see how.

Dave S