Skip to Main Content

APEX

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to validate column value for each row in tabular form?

C PatelMar 25 2014 — edited Mar 26 2014

I have a custom tabular form based on a collection and I'm interested in being able to validate the value entered by a user in any given row/column combination.  Conceptually, it is basically a grid-format time sheet, where each row represents a task, and each column represents a day of the week.

Task Name

03 / 24

Mon

03 / 25

Tues

03 / 26

Wed

03 / 27

Thurs

03 / 28

Fri

03 / 29

Sat

03 / 30

Sun

03 / 31

Mon

04 / 01

Tues

04 / 02

Wed

04 / 03

Thurs

04 / 04

Fri

04 / 05

Sat

04 / 06

Sun

Task ID
Task A13416312345
Task B436142123567890
Task C22172245789
Task D12345112389

The user can enter hours worked for any given task, for any given day of the week.  So whenever the user inputs some hours, the form needs to validate whether that task still has a valid GL code for the current time period.  I started to go down the path of Javascript / AJAX for validating prior to submitting the form, but got stuck on how to reference values in other cells on the same row.  For example, the user enters some hours in tabular form cell f03_0010, the javascript needs to look up the "task id" found in f18_0010 (Task ID is actually a hidden column but always in f18_xxxx cell).  It should then pass the value of f18_0010 to checkWBS function (see below) which calls an application process using PL/SQL to verify whether the task id is still valid.

function checkWBS(pITEM) {

  var get = new htmldb_Get(null, html_GetElement('pFlowId').value, 'APPLICATION_PROCESS=VALIDATE_TASK_CODE',0);

  get.addParam('x01',pITEM);

  var gReturn = get.get();

  return gReturn;

}

Having client-side validation would be nice, but alternatively, a page process which executes On Submit will also work.   I understand that I could achieve this by looping through each row using the syntax below, but since the columns can span a 2-week period (14 cells) what's the best way to go through each column without having to code for each day?  Are there any built-in APEX functions to make this easier?

BEGIN

  FOR i IN 1..apex_application.g_f02.count  LOOP

   IF apex_application.g_f03.count > 0 THEN

        v_tot_hours := v_tot_hours + TO_NUMBER(NVL(RTRIM(apex_application.g_f03(i)),'0'));

   END IF;

  /* keep adding all 14 days to v_tot_hours */

  IF apex_application.g_f016.count > 0 THEN

       v_tot_hours := v_tot_hours + TO_NUMBER(NVL(RTRIM(apex_application.g_f016(i)),'0'));

   END IF;

/* now validate if there are hours entered for the task during any day */

  IF v_tot_hours > 0 THEN

-- do something here

END IF;

  END LOOP;

END;

Hope this makes sense.  Thanks for any input!

Oracle APEX 4.2

This post has been answered by DannyD on Mar 26 2014
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 23 2014
Added on Mar 25 2014
2 comments
1,069 views