3 Replies Latest reply: Jul 12, 2013 6:07 AM by dare RSS

    Want to varify every field on form with database value?

    yash_08031983

      hello Experts,

       

      I have to implement a functionality which will confirm the amendment for every text field on form.

      Scenario:

       

      I have a form with multiple tables with database fields.

      we have defined access flag for every column for every table to yes or no in a master table .

      when user navigate to any text field in any database block, procedure or function will varify that access is given for amendment for that column.

      If access flag is set to yes, user can change it. otherewise prompt with message, you are nor authorize to amend this field.

       

      i do not want to call that procedure and function at every field level.

      Also if in future if some new field will add at that form, we do not need to change in code or we should not require to remember for verifying the access flag for that column.

       

       

      Please help me out.

       

      Thanks

      yash

        • 1. Re: Want to varify every field on form with database value?
          InoL

          With

          get_block_property('block',first_item)

          you can get the first item in a block.

           

          Then with

          get_item_property('item',nextitem)

          you can loop through all the items in the block.

           

          Then with

          set_item_property('item', updateable ,property_true/false)

          you can set the updateable property.

           

          That should give you an idea how to do it dynamically.

          • 2. Re: Want to varify every field on form with database value?
            yash_08031983

            Hi experts,

             

            Please review my code which is use to navigate through all the item in a database base block:

            {code}

            DECLARE

              L_FIRST_BLOCK VARCHAR2(50);

              L_LAST_BLOCK VARCHAR2(50);

              L_CUR_BLOCK VARCHAR2(50);

              L_NEXT_BLOCK VARCHAR2(50);

              CUR_FORM VARCHAR(50) := :SYSTEM.CURRENT_FORM;

              L_BLOCK_TABLE VARCHAR2(100);

              L_FIRST_ITEM VARCHAR2(50);

              L_LAST_ITEM VARCHAR2(50);

              L_CUR_ITEM VARCHAR2(50);

            BEGIN

              L_FIRST_BLOCK := GET_FORM_PROPERTY(CUR_FORM,FIRST_BLOCK);

              L_LAST_BLOCK := GET_FORM_PROPERTY(CUR_FORM,LAST_BLOCK);

              L_CUR_BLOCK := L_FIRST_BLOCK;

              GO_BLOCK(L_CUR_BLOCK);

              LOOP

              GO_BLOCK(L_CUR_BLOCK);

              L_BLOCK_TABLE := GET_BLOCK_PROPERTY(L_CUR_BLOCK,QUERY_DATA_SOURCE_NAME);

             

              IF NVL(L_BLOCK_TABLE,' ')<>' ' THEN

               MESSAGE(L_CUR_BLOCK||'-'||L_BLOCK_TABLE);MESSAGE(L_CUR_BLOCK||'-'||L_BLOCK_TABLE);

               DECLARE

               L_FIRST_ITEM VARCHAR2(50);

              L_LAST_ITEM VARCHAR2(50);

              L_CUR_ITEM VARCHAR2(50);

              L_ITEM_ID VARCHAR2(50);

               BEGIN

                L_FIRST_ITEM := GET_BLOCK_PROPERTY(L_CUR_BLOCK,FIRST_ITEM);

                L_LAST_ITEM := GET_BLOCK_PROPERTY(L_CUR_BLOCK,LAST_ITEM);

                L_CUR_ITEM := L_FIRST_ITEM;

                LOOP

                      MESSAGE(L_CUR_BLOCK||'.'||L_CUR_ITEM);

                      IF L_CUR_ITEM=L_LAST_ITEM THEN

                      EXIT;

                      END IF;

                      L_CUR_ITEM := GET_ITEM_PROPERTY(L_CUR_BLOCK||'.'||L_FIRST_ITEM,NEXTITEM);

                END LOOP;

               END;

              

             

              END IF;

              IF L_CUR_BLOCK = L_LAST_BLOCK THEN

              EXIT;

              END IF;

              L_CUR_BLOCK := GET_BLOCK_PROPERTY(L_CUR_BLOCK,NEXTBLOCK);

              END LOOP;

            END;

             

            {code}

             

            This code navigates through the DB Block item's, i have a item with

            key-next-trigger's code:

            if item is null then

            Message('can not blank');

            raise form_trigger_failure;

             

             

            Navigation stock at this item.

            i am write the navigation code at when-new-form-instance trigger.

            if key-next-item trigger will fire then it will not be position to navigate through all the items in form.

             

            Please help me out.

             

            Thanks

            Yash

             

             

             

            Thanks

            yash

            • 3. Re: Want to varify every field on form with database value?
              dare

              KEY-NEXT-ITEM is always triggered, so you can try to put that code in WHEN-VALIDATE-ITEM trigger. That way you can navigate over that field if it's fetched blank from db, but can not force user to enter data in a new record. Alternatively, you can ask again for priviledge to change data in your KNI trigger.