Documenting Business Rules on a Webform

I got this question from a colleague of mine.

“Is there an easy way to analyze the Business rules attached to a form?”

I’ve written about a few queries on documenting the usage of menus, calculation scripts and was hoping that it’ll be useful. However, this is a cloud instance, and the blog post is not helpful anymore. One way to do that will be to open the forms in the Form editor and look at the business rules properties.

BR properties

I immediately knew that is not the answer he was expecting ;).

I cannot run any SQL queries on Planning tables as this is a cloud instance, and was limited to use the LCM files for the information.

Here is a utility that I came up with, which can scan the LCM folder for data forms and create a file for you.

You need to extract and unzip the LCM file and browse to the application directory.

LCM application

Once the location is selected, use the “Create Document” button to create a file (FormBRDetails.txt under LCM app folder) similar to the one below.

It is a tab-delimited file and can be easily added to an EXCEL file for documentation purposes.

If you don’t want to use the utility and want to roll up your sleeves and do it yourself, here is a groovy script that can be utilized to do the same thing.

def lcmFolder = <HP App Folder>
def infoXML = new XmlSlurper().parse(lcmFolder + "\\info\\listing.xml")
def formBRDoc = new File(filename.txt)
formBRDoc.write("Form Name\tBR Name\tRun On Load\tRun Before Save\tRun After Load\tRun On Save\tHide Prompt\tUse Members on Form" + System.getProperty("line.separator"))
    if (it.@type=='Data Form'){
        def formPath = it.@name as String
        def fullFormContents = new File("$lcmFolder\\resource\\${it.@path}\\${formPath.replace("(", "%28").replace(")", "%29")}.xml").text
        def formXML = new XmlSlurper().parseText(fullFormContents)
        formXML.businessRules.businessRule.each{ formDetails ->
            formBRDoc.append("${it.@name}\t${formDetails.@name}\t${formDetails.@runOnLoad}\t${formDetails.@runPreSave}\t${formDetails.@runAfterLoad}\t${formDetails.@runOnSave}\t${formDetails.@hidePrompt}\t${formDetails.@useMRU}" + System.getProperty("line.separator"))

I’m using the listing XML file to find out all the objects that are Data forms. If it is a data form, then use the path given in listing.xml to get the details.

You cannot use the encoding here as some characters are encoded not all, so this is going to be a trial and error. (I did take care of parenthesis.)

Don’t forget to add the folder location and file location in the script

Leave a comment

Your email address will not be published. Required fields are marked *