ALERT! The community will be read-only starting on April 19, 8am Pacific as the migration begins. Read more for important details.
ALERT! The community will be read-only starting on April 19, 8am Pacific as the migration begins.Read more for important details.
Absent Member.. Absent Member..
Absent Member..
4622 views

Vugen 11.52 + Truclient: Force transaction to fail

Jump to solution

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.

Labels (1)
0 Likes
1 Solution

Accepted Solutions
Absent Member.. Absent Member..
Absent Member..

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.

View solution in original post

0 Likes
3 Replies
Absent Member.. Absent Member..
Absent Member..

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

0 Likes
Absent Member.. Absent Member..
Absent Member..

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.

View solution in original post

0 Likes
Ensign Ensign
Ensign

Thank You for solution, it helped me a lot!

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.