Search code examples
pentahopdispoon

Pentaho - Condition to go to next block


I have a transformation where i call a REST client to post to an API. The API is expected to return a Reference number, which i use to log and use it for other functionalities.

An exception occurred and i received a status code 200 but the response was "Object reference not set to an instance of an object." which is not a number. The next step after Rest client expects a number but since the response is a text fails. (Rest client 2 to Modified Javascript 2 in the image)

enter image description here

In this scenario is it possible to have an intermediate step which checks if the response is a number else should not allow to go to next step?

Also, a related question. this transformation is run for each record from previous transformation. If the if condition fails, then it should continue with the next record.


Solution

  • There are multiple options.

    One of the simplest ones is to insert a Select Values step to convert the field to a number and then add a Error handling hop connected to a Dummy step.

    Rows that fail the data type conversion cause errors and are then sent through the error handling hop to the dummy step and will not be sent to the javascript step.