3 Replies Latest reply: May 5, 2014 9:43 AM by CraigB RSS

    How to create a dynamic LOV & RG on runtime

    949920

      Hi all,

       

      Can anyone please tell me how to create dynamic LOV & assign dynamic RG to it on run time according to previous data seletion.

       

       

       

      thanks & regards.

        • 1. Re: How to create a dynamic LOV & RG on runtime
          sfr.farhan

          Hi,

           

          See the following sample code.

           

          Let's say, based on county code you want to populate city list.

          Source: :block.country_code

          Target: block.city_name

           

          DECLARE

           

              group_id RecordGroup;

              query_ok NUMBER;

           

          BEGIN


                group_id:=find_group('rg_city')


                 If not id_null(group_id) then 

                    delete_group(group_id);

               end if; 


              /* create the group 'rg_city' and assign its id to the

              ** variable group_id */

           

              group_id := Create_Group_From_Query ('rg_city',  'SELECT city_name, city_code

                                                                                         FROM city

                                                                                      WHERE country_code = ' || :block.country_code);

           

              /* now execute the new group's query, using the variable

              ** group_id to identify the group */

              

              query_ok := Populate_Group(group_id);

           

              /* Populate the list item block.city_name based on block.county_code

           

              Populate_List ('block.city_name', group_id); 

              

          END;

           

          Please mark the question as Correct/Answer, if this answers your question. Thanks

          • 2. Re: How to create a dynamic LOV & RG on runtime
            Andreas Weiden

            What exactly has to be dynamic at runtime? Do you want to show different columns in the lov? or only different data? If it is different data, in waht way is it different? Do you have to apply a different WHERE-condition? Or is the whole query completely different?

            • 3. Re: How to create a dynamic LOV & RG on runtime
              CraigB

              949920 wrote:...

              Can anyone please tell me how to create dynamic LOV & assign dynamic RG to it on run time according to previous data seletion.

               

               

              An LOV can only be defined during design.  Once created, you can dynamically create and assign the Record Group (RG) that supplies the data to the LOV.  This can be a drawback, but it is the way Forms works.  If you need different layouts and column mapping from an LOV that is dependent upon choices a user makes during runtime, then you will need to create a seperate LOV for each situation in the Forms Builder.  Then you can programatically assign LOV's to an item based on the user's choices as well as create/assign different RG's as needed during runtime.

               

              Craig...