Saturday, July 25, 2020

Display Validations using Dynamic Actions in Oracle APEX

Button --> Dynamic Actions --> Event: Click --> True --> Execute Javascript Code

NOT NULL Check
*****************************************

if ($v('P7_CITYNAME')=== undefined || $v('P7_CITYNAME')== null || $v('P7_CITYNAME').length <= 0)
 {
    apex.message.alert('Please Enter City Name.');
}
if ($v('P7_COUNTRYNAME')=== undefined || $v('P7_COUNTRYNAME')== null || $v('P7_COUNTRYNAME').length <= 0)
 {
    apex.message.alert('Please Enter Country Name.');
}

or


if ($v('P7_CITYNAME') == "")
{
alert("Please Enter City Name.");
}
if ($v('P7_COUNTRYNAME') == "")
{
alert("Please Enter Country Name.");
}

Duplicate check
*************************************************
Execute PL/SQL Code

DECLARE
   v_dup   NUMBER (1) := 0;
BEGIN
   SELECT COUNT (*)
     INTO v_dup
     FROM CITIES
    WHERE CITYNAME = :P7_CITYNAME;

   IF v_dup > 0
   THEN
      :P7_CITYDUP := 'Y';
   ELSE
      :P7_CITYDUP := 'N';
   END IF;
END;


Items to Submit: P7_CITYNAME
Items to Return: P7_CITYNAME

Execute Javascript Code

var nameExists = $v('P7_CITYDUP') === 'Y';
var cityNull = $v('P7_CITYNAME') === '';

if (nameExists) {
  if (!cityNull) {
  alert('This City Name already exists. Please enter a different City Name');
}
}

No comments:

Post a Comment

Delete Row Button to all records of Interactive Report in Oracle Apex

 1. add 'Delete' Del column to Report Query 2. Set the Following Properties for the DEL Column Type: Link Heading: Delete Targ...