IG column validation

1. Overview

This document will be helpful to validate the Interactive Grid column values without editing the IG region.

2. Technologies and Tools Used

The following technology has been used to validate the Interactive Grid column values is

  • Javascript

3. Use Case

When there is a requirement to validate the interactive grid column(TEST) to be not null, without editing the Grid region. Since IG validation fires only the affected rows.

4. Steps with Screenshot

We can achieve this by using JavaScript function in the apex page. The step by step process to achieve this is as follows

Step 1:

Create an Interactive Grid with a base query.

Step 2:

Set static ID as “IG” to Interactive Grid region.

Step 3:

Create a button as “SUBMIT”.

Step 4:

Add the following code into the Javascript Function and Global Variable Declaration section.

//To Validate a column value is null in IG

function run_jquery_process() {

var widget  =     apex.region(“IG”).widget();

var grid =widget.interactiveGrid(“getViews”, “grid”);

var model = grid.model;

var loop1 = 0;

var flg=’Y’;

apex.message.clearErrors();

model.forEach(function(r) {

var rows=r;

loop1 +=1;

if ( model.getValue(rows, “TEST”)==””)

// If the column is select list then the condition should be (if (model.getValue(rows, “TEST”).v==””) )

{

console.log(loop1);

flg=’N’;

console.log( ‘Actual Value must have a value in Row ‘ + loop1);

apex.message.showErrors([{

type: “error”,

location: “page”,

message: ‘Actual Value must have a value in Row ‘ + loop1,

unsafe: false

}]);

return;

}

})

if  (flg==’Y’){

apex.submit(‘SUBMIT’);

}

}

Step 5: 

Create a dynamic action

Event : Click

Selection Type : Button

Button : SUBMIT

True Action : Execute Javascript Code

Code: run_jquery_process()

Output:

Recent Posts