Maximo Open Forum

 View Only
Expand all | Collapse all

Set the response code in custom script handler

  • 1.  Set the response code in custom script handler

    Posted 22 days ago

    Hi,
    I was going through this feature called custom script handler in Maximo.

    Invoking script through Automation Script Handler

    Ibm-maximo-dev remove preview
    Invoking script through Automation Script Handler
    Learn Anamitra's wisdom about Autoscripting
    View this on Ibm-maximo-dev >


    It allows us to call a script using a url either (POST or GET or UPDATE) and we can do our processing and return the responseBody.

    Apart from returning the responseBody can we return a response Code (e.g. 200, 400 or 500 etc) as well ?


    #MaximoApplicationSuite

    ------------------------------
    Rana Ahmed
    Maximomize
    ------------------------------


  • 2.  RE: Set the response code in custom script handler

    Posted 21 days ago

    Unfortunately, no but this would be a good enhancement request. You can request the enhancement here: https://ibm-ai-apps.ideas.ibm.com/ideas/ 



    ------------------------------
    Steven Shull
    IBM
    ------------------------------



  • 3.  RE: Set the response code in custom script handler

    Posted 21 days ago

    Added it here. It would be great if others can up vote it

    Let us return response | IBM Sustainability Software - Ideas Portal



    ------------------------------
    Rana Ahmed
    Maximomize
    ------------------------------



  • 4.  RE: Set the response code in custom script handler

    Posted 21 days ago

    I had a similar requirement but ended up doing it a different way. Voted for your idea.



    ------------------------------
    Manu Maganti
    EMA, Inc
    ------------------------------



  • 5.  RE: Set the response code in custom script handler

    Posted 21 days ago

    Hi Manu,

    Thanks for the vote.

    What was the path you took for it?



    ------------------------------
    Rana Ahmed
    Maximomize
    ------------------------------



  • 6.  RE: Set the response code in custom script handler

    Posted 21 days ago

    The external system was able to use status 500 with the specific status code appended at the end of each message. 



    ------------------------------
    MM
    ------------------------------



  • 7.  RE: Set the response code in custom script handler

    Posted 19 days ago

    Do you know any documentation for this



    ------------------------------
    Rana Ahmed
    Maximomize
    ------------------------------



  • 8.  RE: Set the response code in custom script handler

    Posted 19 days ago

    We did it the "easy" way. If you have specific errors that are being sent back, you'll have the BMXAA ID referenced. We had a limited set that were being returned and what specific status code they were expecting. We just appended that to the end of the error text. Find out if your external system can extract the text at the end of the error message you're sending to identify the status code. Note that this was only for errors being returned as 500. They were ok with the other standard codes - 200, 400+, etc.



    ------------------------------
    MM
    ------------------------------



  • 9.  RE: Set the response code in custom script handler
    Best Answer

    Posted 19 days ago

    You can do this like so:

    response = request.getHttpServletResponse();
    response.setStatus(302) # Set whatever status code you want.
    response.flushBuffer()

    The key to this is that by calling flushBuffer() on the HttpServletResponse you are flushing the header and response values to the client and preventing Maximo from overriding the values you have set.

    Let me know if you have any other questions about this.

    Regards,

    Jason



    ------------------------------
    Jason VenHuizen
    Sharptree
    ------------------------------



  • 10.  RE: Set the response code in custom script handler

    Posted 19 days ago

    Very cool. Is this 'new' functionality? I'd asked IBM about this about 5 years ago, and they said it would involve java customization which was not acceptable to the client at that time.

    Thanks for this, Jason.
    M



    ------------------------------
    MM
    ------------------------------



  • 11.  RE: Set the response code in custom script handler

    Posted 19 days ago

    No, this has always been part of the HttpServletResponse API.  It does have some potential risks in that it any additional headers or other information that IBM may add from being added to the response.  But in practice I have not seen this be an issue in the use cases I have encountered.

     

    Jason






  • 12.  RE: Set the response code in custom script handler

    Posted 13 days ago

    That's brilliant and it is working.



    ------------------------------
    Rana Ahmed
    Maximomize
    ------------------------------