Rocket Modern Experience (formerly LegaSuite)

 View Only
  • 1.  Looking for microflow best practice for a REST API call that does not retrieve data it expected.

    Posted 11-16-2023 06:01

    We have an iSeries application that will show an error message on the bottom of the screen if the item being selected has no additional information (instructions).  

    The success output currently looks fine:

    Date: Wed, 15 Nov 2023 22:58:31 GMT
    Content-Type: application/json;charset=utf-8
    Rocket-Status-Success: true
    Rocket-Status-ReturnCode: 0
    Content-Length: 48
    {"Result":{"instruction":"","RESULT":"SUCCESS"}}

    However, if it is not found, we would like to return a non-successful result and, ideally, the reason.

    I have tried using the Set Status Code action, but it seems to have no effect in the Execute Stage (or I am using it incorrectly).

    I would be happy to execute a Javascript function, but I don't see anything in hostSession or microflowContext that seems to have what I would need.  Is there documentation you could point me toward on hostSession and microflowContext, as well as other JavaScript capabilities?  I don't find references to them in the scripting documentation that I've found.  Also, if there were a set of example javascript files that did a few other fancy things, that would be an excellent resource you could point me to as well.



    ------------------------------
    Norman Kabir
    Developer
    Gebbers Farms
    Brewster WA US
    ------------------------------


  • 2.  RE: Looking for microflow best practice for a REST API call that does not retrieve data it expected.

    ROCKETEER
    Posted 11-17-2023 10:17

    Hi Norman,

    If you use the Set Status Code in the main action overview, the last value of Set Status Code will be shown.
    To have a different result, this should go through an Exception handler.
    And to have an Exception Handler triggered, this should have on a Check condition.

    Within the Check condition, you can build condition which will result in true or false.
    And then you can call this Exception handler, containing the Set Status to e.g. 403.

    If you want to have specific data returned, then you can enter information in the Exception Handler.
    This will change from handler to reporter. At that point the Session Control become enabled, and you can choose what should happen to your existing session.

    Example in one overview:

    In case of an expected request, my answer is now 299 (in stead of 200):

    In case of riddle at input0, the http code is 499:

    If you want to check upon more javascript functions from the hostSession and or microflowContect, press after the . (dot) Ctrl+Spacebar:

    With the microflowContext, you can request information about e.g. the microflow input

    And afterwards, when using the . only after e.g. hostSession, this should already show the options:

    To find more information about the hostSession, you can navigate to : https://rocketsoftware.github.io/rocket-api-javadoc/
    And see the details in Javadoc for Emulator API.

    If you have more questions, please let me know.

    Joyful regards,

    Rene



    ------------------------------
    Rene Terhorst
    Rocket Software
    Dordrecht NL
    ------------------------------



  • 3.  RE: Looking for microflow best practice for a REST API call that does not retrieve data it expected.

    Posted 11-20-2023 10:26

    Thank you, Rene,

    I'm having difficulty getting the condition in the check statement calling my exception handler.  Neither of these call it...is there something else I'm missing?  It doesn't matter if I specify the result should be true or false, it advances to the next instruction and does not call the exception handler:

    I've tried other conditionals that evaluate to true or false...and I get the same effect.  

    Thank you



    ------------------------------
    Norman Kabir
    Developer
    Gebbers Farms
    Brewster WA US
    ------------------------------



  • 4.  RE: Looking for microflow best practice for a REST API call that does not retrieve data it expected.

    Posted 11-21-2023 13:07

    Okay, ignore the above; I was able to get an exception to fire with the conditional.  

    So far I have not been successful in causing the status code to show in a multi-stage microflow...does it need to happen in a particular stage (execute/return)?  Does it need to be the last instruction in a stage?

    Date: Tue, 21 Nov 2023 18:04:27 GMT
    Content-Type: application/json;charset=utf-8
    Rocket-Status-Success: false
    Rocket-Status-ReturnCode: -7
    Rocket-Status-Description: No Instructions found for line item [ 13 ]
    Rocket-Status-LongDescription: Exception occurred while dispatching the request com.gebbersfarms.instruction_get. Exception info: 2023-11-21T10:04:28-08:00 com.seagullsw.appinterface.server.backend.hostconnector3.HCReporterException: ; No Instructions found for line item [ 13 ], keepSessionAlive: true - com.seagullsw.appinterface.server.backend.hostconnector3.BasicHCTransaction.flushReporter(BasicHCTransaction.java:990). (Request Name: com.gebbersfarms.instruction_get, User: null, Request ID: {c0a80b5e-adcea0db0000018bf2cf152e8041}, Session ID: {c0a80b5e-adcea0db0000018bf2cf152e8040}, Error Code: -7, Function Definition: com.gebbersfarms.instruction_get com.seagullsw.appinterface.model.schema.mapping.BasicFunctionMappingDefinition@ced8c43a, Back-end: ServerControlled5250BackEnd.erprestapi_ServerControlled5250). - Root cause: 2023-11-21T10:04:28-08:00 com.seagullsw.appinterface.server.backend.hostconnector3.HCReporterException: ; No Instructions found for line item [ 13 ], keepSessionAlive: true - com.seagullsw.appinterface.server.backend.hostconnector3.BasicHCTransaction.flushReporter(BasicHCTransaction.java:990)
    Content-Length: 2
    {}



    ------------------------------
    Norman Kabir
    Developer
    Gebbers Farms
    Brewster WA US
    ------------------------------