We'd love to hear from you! Provide  feedback  to earn a badge today. Take our quick survey
You're almost there! Please answer a few more questions for access to the Applications content. Complete registration
Interested in joining? Complete your registration by providing Areas of Interest here. Register

How to use Groovy validate if a text type cell is not empty

Accepted answer
25
Views
6
Comments
edited Feb 18, 2021 4:32AM in Planning 6 comments

Content

I have simple requirement to check if there is value in any period for a particular Account, there should be some remarks in the Comment field as well.

The simple groovy script below works perfectly fine if every cell is numeric. Yet since the Comment cell is of Text type, I got the error below when the groovy script was executed through the Planning form.

"A method called by the script failed on line: 9, with error: An error occurred while processing this page."

Anyone knows how this can be fixed?

Thanks!

Sunny

 

Code Snippet

def BackErrLightRedColor = 16755370 // Light Red

DataGrid grid = operation.grid
GridIterator itr = grid.dataCellIterator('OFS_Direct Input')

itr.each{
DataCell hsComment = it.crossDimCell('HS_Comment')

if(it.data != 0) {
if(hsComment.data == '') {
      println(it.getMemberName('Entity') + " " + it.getMemberName('Account') + " has no Comment" )
          hsComment.addValidationError(BackErrLightRedColor, "There should be value in Comment")
     }
    }
}

Howdy, Stranger!

Log In

To view full details, sign in.

Register

Don't have an account? Click here to get started!