Is %value% syntax works in If-else?

Hi Experts,

For the DSP I created, Im trying to display the error message in case failure in processing occurs.
I test in Designer, the Output variable is working and catching the error message. However, when Im including it in the DSP, it is not displaying.

Below is the Designer result:


As you can see, returnStatus got the error message I want to display in the DSP.

Below is my DSP code:

%ifvar returnStatus equals(‘success’)%
< p >Success transaction </ p>
%else%
< p>Failed transaction</ p>
< p>Return Status: %value returnStatus% </ p>
%endif%

Note: In success scenario, all is working - success message displayed. However, for the failure scenario, the returnStatus variable is not displaying the error message I want to display when I included it in %value% syntax. Is there any syntax I am missing? When I checked the documentation, all samples are added under %loop% syntax. Is that the case for all? Thanks

PS: I added space in < p> tag to display for better example.

Product/components used and version/fix level:

Detailed explanation of the problem:

Error messages / full error message screenshot / log file:

Question related to a free trial, or to a production (customer) instance?

It’s hard to answer without seeing your full DSP, but here are some things to try.

Make sure your reference to returnStatus comes between the %invoke% and %endinvoke% for the service that returns it.

If returnStatus is nested within a document in the pipeline, you will need to account for that.

A handy way to debug these types of issues is to dump the pipeline in your DSP. The following will display the contents of the pipeline. It calls the toString method on each pipeline variable.

%loop -struct%
  %value $key% = %value% <br>
%endloop%

This does not traverse nested objects. To display the contents of a Document (an IData) within the pipeline, use this:

%loop –struct "nestedDoc"%
  %value $key% = %value% <br>
%endloop%

As @michael6 already mentioned, it is a bit of guess work without the entire picture. :slight_smile:

As an additional debugging measure I would recommend to also invoke pub.flow:tracePipeline right before your if statement. That is what I have been doing for more than a decade and it always helped me to understand what variables are available at runtime. In many cases, while not directly(!) making the root cause obvious, it gives a good overall picture and that is often more helpful.

Other than that I see no obvious error in your code. So it is probably a relatively minor deviation from what is needed. But that does not necessarily make it easier to debug …

@jahntech.cj @michael6 Thank you for your suggestions. For a quick background, I have two separate DSP, 1 as a landing page that calls my service and another is the output template DSP that will display on another page after calling a service. Thus, %invoke% syntax is not being used in my DSP.

This code is for the 2nd page after calling the service from 1st page(return page)
%ifvar returnStatus equals(‘success’)%
< p >Success transaction </ p>
%else%
< p>Failed transaction</ p>
< p>Return Status: %value returnStatus% </ p>
%endif%

– Any suggestion that will improve my implementation is accepted.

May I also know how do you debug the DSP using pub.flow:tracePipeline? Is it from the designer or browser? Im just trying to understand howwe can do it because I haven’t tried it before. Thank you

@mrcruz , you basically see all the data available at run-time in the server.log file of Integration Server. In that sense the debugging happens neither in Designer nor in the browser. Although, you can of course view the server.log contents in the browser. If possible, however, I strongly recommend to use a tool like BareTail free for this.

Since I had planned to create a short video on this topic anyway, let me bring this forward. Once it is available (should be day after tomorrow) I will post a link here.

Thank you Christoph! That video will be very helpful.
I will also try BareTail. Thanks!

The video is now online at https://www.youtube.com/watch?v=UynxYtqezh8 . Please let me know if I missed something or additional aspects are of interest.

Thank you Christoph! I will review it :slight_smile: