Lock Cells on Form

Lock Cells on Form

Use any criterion or multiple criteria, or even the username!


In certain cases, it becomes necessary to restrict user access to particular cells beyond the conventional security measures. This could be due to the absence of dimensional security options for specific accounts or complex logic needed to identify editable cells. However, locking cells is a simple solution using Groovy.

All you have to do is use the Data Grid Iterator and lock cells based on the criteria.


Let’s take the expenses form

No alt text provided for this image
Standard Form with Travel Expenses

Let’s say that as a corporate policy, no one is allowed to rent a car in the first quarter.

All you need is a simple groovy script that you attach to the form and run on load.

/*RTPS:*/

operation.grid.dataCellIterator().each {
     if(it.getAccountName() == "OFS_Car Rental" && ["Jan", "Feb", "Mar"].contains(it.getPeriodName())) {
          it.setForceReadOnly(true)
     }
}        

Once the form is updated with the script attached to run on load, just open / reload the form.

No alt text provided for this image
Car Rental account locked for the first Quarter

Let’s look at one more example. We’ll use our Revenue Direct Entry form

No alt text provided for this image
Revenue for Smart Phone 4 in US Market

Let’s say that we don’t want the Smart Phone 4 to be sold in the Italian Market in the second Quarter.

/*RTPS:*/

operation.grid.dataCellIterator().each {
     if(it.getMemberName("Product") == "Smart Phone 4 in" && it.getMemberName("Market") == "Italian Market" && ["Apr", "May", "Jun"].contains(it.getPeriodName())) {
          it.setForceReadOnly(true)
     }
}        

Once you attach the script to the form to run on load and refresh…

No alt text provided for this image
Smart Phone 4 locked for Quarter 2 in the Italian Market

This can be extended to lock cells based on any criteria, be it Years or you can lock based on the Entity, a combination of criteria or even the username!

要查看或添加评论,请登录

Shehzad Kazmi的更多文章

社区洞察

其他会员也浏览了