4 Replies Latest reply: May 15, 2013 6:09 AM by tony.g RSS

    Enable / Disable LOV Values in Multi record block based on one of the field

    951614
      Hi

      We have a master detail block - where the detail is a multi record block

      Requirement
      If line_type = 'A' , fields 1,2,3,4,5,6 should display the LOV values. Note that these LOVs are based on a record query which fetches the values using a select statement.
      If line_type = 'B',' field 1 should default to a value called 'DEFAULT'. The fields along with the LOVs should be disabled.

      We are using Oracle forms 10g version

      We have tried using the technique of show_lov in a KEY-LISTVAL trigger - both at item level and block level...and htis is not working
      set_LOV_PROPERTY is also not working

      Please provide any pointers.

      Sample code used in the KEY-LSITVAL is
      ------------------
      declare
           b1 Boolean;
      begin
      if(line_type = 'B')
      then
      null;
      elsif(line_type = 'a')
      THEN
      b1 := SHOW_LOV('LOV_ON_FIELD1');
      END IF;
      END;

      Note that - LOV_ON_FIELD1 is the name of the LOV on field 1 that uses a reqcord group with a select statement

      ----------------
      Thanks
      SR
        • 1. Re: Enable / Disable LOV Values in Multi record block based on one of the field
          Amatu Allah Neveen Ebrahim
          Hi SR

          Another idea cross to ...

          Creating more than a lov with different RGs
          Call each in When validate item trigger within if statement block
          e.g.
          IF :FIELD1 IN (1,2,3....) THEN
          SHOW_LOV ...
          ELSIF ....
          END IF;
          Or creating than lov for more than a RGS , in this case u have to change the record group before displaying LOV

          Amatu Allah
          • 2. Re: Enable / Disable LOV Values in Multi record block based on one of the field
            CraigB
            If line_type = 'B',' field 1 should default to a value called 'DEFAULT'. The fields along with the LOVs should be disabled.
            Well, you code sample for your Key-ListVal would not disable the fields, simply cause the LOV to not be shown. Also, looking at your code, if your "LINE_TYPE" field allows mixed-case, your code will not consistently supress the LOV. Try:
            declare
              b1 Boolean;
            begin
              if(UPPER(line_type) = 'B')
              then
                null;
              elsif(UPPER(line_type) = 'A')
              THEN
                b1 := SHOW_LOV('LOV_ON_FIELD1'); 
              END IF;
            END;
            Also, if your truly want the fields in rows where LINE_TYPE='B' to be disabled, you can't use the Key-ListVal trigger for this. I would recommend using the When-New-Record-Instance (WNRI) and the Post-Query (PQ) triggers. The WNRI would handle records being created while the PQ will handle existing records queried into your block. The code would look something like:
            /* Sample Disable code for Multi-Row block */
            /* This code would be used in both triggers */
            BEGIN
              -- Check if row should be disbled and FIELD_1 defaulted to "DEFAULT"
              IF ( UPPER(:YOUR_BLOCK.LINE_TYPE) = 'B' ) THEN 
                Set_Item_Instance_Property('YOUR_BLOCK.YOUR_ITEM1',INSERT_ALLOWED,PROPERTY_FALSE);
                Set_Item_Instance_Property('YOUR_BLOCK.YOUR_ITEM1',UPDATE_ALLOWED,PROPERTY_FALSE);
                Set_Item_Instance_Property('YOUR_BLOCK.YOUR_ITEM1',VISUAL_ATTRIBUTE,'DISABLED_ITEM');
                /* Do this for each item in the row you want disabled. */
                /* This sample assumes you have a set Visutal Attributes named */
                /* "DISABLED_ITEM" and "ENABLED_ITEM" */
              ELSE
                --Ensure the each item is enabled.
                Set_Item_Instance_Property('YOUR_BLOCK.YOUR_ITEM1',INSERT_ALLOWED,PROPERTY_TRUE);
                Set_Item_Instance_Property('YOUR_BLOCK.YOUR_ITEM1',UPDATE_ALLOWED,PROPERTY_TRUE);
                Set_Item_Instance_Property('YOUR_BLOCK.YOUR_ITEM1',VISUAL_ATTRIBUTE,'ENABLED_ITEM');
                /* Do this for each item in the row you want disabled. */
              END IF;
            END; 
            Hope this helps,
            Craig...
            • 3. Re: Enable / Disable LOV Values in Multi record block based on one of the field
              951614
              No longer relevant for our case.
              • 4. Re: Enable / Disable LOV Values in Multi record block based on one of the field
                tony.g
                But you are of course grateful and thankful for the people who have volunteered their help in the thread above.

                ;-)