Thursday, October 9, 2014

Input Parameter Validation in BIP

BI publisher is really simple-easy-to-use tool but with its own limitations. One of which is validation of the input parameter befor report execution. Yeah you might fire back stating we do have LOV concept there but what about Email and Phone formatting.

Keep all your worries at bay as there is always an alternate solution. We can't validate the parameters while keying but we can validate the same in the template. That's how much powerful BIP is. BI Publisher has extended a set of SQL and XSL functions for use in RTF templates. The syntax for these extended functions is

<?xdofx:expression?> for extended SQL functions

<?xdoxslt:expression?> for extended XSL functions

The key here is syntax. You might struggle in the begining if you are new to this part of world. However there are certain functions (read Instr as one) which are supported by xdof while some are supported by xdoxslt. Keep in mind you cannot mix xdofx statements with XSL expressions in the same context. Consider a simple scenario of validating email address parameter in template, whether it have '@' symbol or not. The syntax can be real tricky if you are using the same with conditional region in rtf. Below steps can be used to perform the same.

1 - Define input parameter in rtf template

<?param@begin:Email;u_rock@gmail.com?>

2- Define xdofx condition which checks for @ in the parameter. This will use extension function for the same.

<?xdofx:if Instr($Email,'@',1) <= 1?>

Invalid Email Address

<end if>

<?xdofx:if Instr($Email,'@',1) > 1?>

Your Report Data

<end if>


With the help of extension functions you can define your own conditional region and conditional formatting.  Do share your experience with the extension functions as the syntax can be quite tricky at times for these functions. In my next post i will try to take a dig on xdoxslt function for validation.

Happy Reporting!!

No comments: