Application Perf Mgmt (BAC / BSM) Practitioners Forum
Showing results for 
Search instead for 
Do you mean 

Vugen 11.52 + Truclient: Force transaction to fail

SOLVED
Go to Solution
Highlighted
Valued Contributor

Vugen 11.52 + Truclient: Force transaction to fail

I need to programatically force a transaction to fail in TruClient BUT allow the script to keep running, as there are other transactions in the script that are not dependent on this transaction being successful. Is there any way to do this?

 

Thanks.

2 REPLIES
Trusted Contributor

Re: Vugen 11.52 + Truclient: Force transaction to fail

We don’t have continue on error as in other protocols in LR. However on Step Object we do have optional steps that may not fail the execution:

 

 

 

 

I have ask if we could have it in the future, and currently it is technical limitation, and they don't see way to add it.

Regards,
Noam

Valued Contributor

Re: Vugen 11.52 + Truclient: Force transaction to fail

[ Edited ]

Thanks. In my situation, I actually need to FAIL the transaction, but continue with the execution of the script.

 

Here's actually the workaround that I came up with to accomplish what I wanted to do. Keep in mind that this is a simple workaround - I wouldn't usually check to see whether the 'Lucky' button exists before clicking on the 'Lucky' button, but it demonstrates the principle:

 

 

The first code block (step 1) contains the following code:

var isTransactionError = false;

 

The second code block (step 2, in the "Else" block) contains the following code; this is only found if the error condition is true:

isTransactionError = true;

 

The third code block (step 4, in the first "If" block) contains the following code, which is called if the transaction is in error:

LR.log("Sorry, you're not lucky today.","Error");
LR.endTransaction("I'm feeling lucky","Fail");

 

The final code block (step 4, in the "Else" block) is empty; it is there because if you attach the 'End Transaction' to the entire 'If' block, it will ALWAYS report successful, and if you place it on a transaction AFTER the 'If' block, it will complain that you're ending a transaction that isn't open.

 

Where I am primarily using this type of logic is if my application gives me a specific error screen if a specific condition occurs, i.e., "Customer not found." This allows me to create a custom error message for that condition using the LR.log() function, rather than expecting to see customer data and get an "object not found" error when I continue on to the next transaction.

 

I also use it with a CATCH block after the TruClient block I'm watching for the error on. Within that CATCH block is a code block that sets isTransactionError = true in order to emulate CONTINUE ON ERROR functionality.

 

I use these when the failure of a single transaction does NOT necessarily fail the entire script - i.e., if looking up different customer types pulls data from different databases; one DB may be down, impacting functionality, while others remain up and usable.