7 Replies Latest reply: Jul 15, 2013 10:45 AM by Andreas Weiden RSS

    Facing issues with Post-Query Trigger

    Bhushan53

      Hi,

      i am using Forms [32 Bit] Version 10.1.2.0.2 (Production).

       

      Here, I have a data block based on a table. I am displaying 10 records on the form. Please see the stpes I am taking -

       

      1. Execute Query. (Returns me 17 Records)

      2. Setting value of one field in POst-Query Trigger.

      3. Save it.

       

      When I requery, the previously set value was saved only for 10 records which were visible. Remaining 7 records don't get updated. Now, I reset the value from backend and again repeated my steps as -

       

      1. Execute Query. (Returns me 17 Records)

      2. Setting value of one field in POst-Query Trigger.

      3. Scrolling through records till Last_record manually.

      4. Save it

       

      This time, I on re-querying I am able to see the updated value for all 17 records. Please help me in attaing this result without scrolling through the records.

       

      Regards

      Bhushan

        • 1. Re: Facing issues with Post-Query Trigger
          Pramod SR

          Set QUERY ALL RECORDS property to YES at block level and try. This might help you.

          • 2. Re: Facing issues with Post-Query Trigger
            Andreas Weiden

            hm,

             

            so your user has to execute a query, and when doing so, the queried records are updated? Sounds like a strange logic to me. If you have to update the record, then why don't you just write an UPDATE-statement to do so?

            • 3. Re: Facing issues with Post-Query Trigger
              Bhushan53

              Thanks Pramod and Andreas and Apologies, as I forgot to mention that the field that is getting updated is a hidden field and I just need to update the value in form_field and not commit to the database. Hence, I can not use ON-UPDATE trigger.

              Because, If there are 10 records on display, on-update will fire only for the records whose record status is changed. So, it will not serve my purpose even if I hard code the value in on-update.

               

              @Pramod : I am surely going to try this. I suppose this will work. Thanks again!

              • 4. Re: Facing issues with Post-Query Trigger
                Pramod SR

                Please share your code/comments once you resolve your issue and don't forget to mark the answers

                • 5. Re: Facing issues with Post-Query Trigger
                  dare

                  I agree that it is strange to do anything in POST-QUERY trigger except of fetching additional data or compute derived fields. The reason you're having trouble is exactly because you're using PQ trigger - it's triggered only for records that are visible. What was the intention? User queried block -> update all records in block? It could be done by single update statement as Andreas suggested. You don't need no ON-UPDATE trigger, just find the appropriate event for update, following the intented logic.

                  • 6. Re: Facing issues with Post-Query Trigger
                    Bhushan53

                    Thanks Dare, I understood what Andreas suggested properly now. This won't require an ON-UPDATE trigger.

                     

                    So, If I am getting it correctly.. both of you are suggesting that, I should write an Update statement for user event(button pressed in my case).

                     

                    Current Approach -

                    1. Block is queried.

                    2. Post Query Trigger - I set the value of one hidden field in form (not updated in DB).

                    3. user hits save. The values he has changed + hidden column values for only visible lines are updated in DB.

                     

                    Suggested Approach -

                    1. Block is queried.

                    2. user hits save. The values he has changed will be updated + I should write an update statement inside loop (first_record to Last_record) for hidden field.

                     

                    Please correct me If I am wrong. In this, I have few doubts -

                    1. Will my update statement affect the usual flow of the way forms work? If yes, how can that be avoided?

                     

                    Regards

                    Bhushan

                    • 7. Re: Facing issues with Post-Query Trigger
                      Andreas Weiden

                       

                      Suggested Approach -

                      1. Block is queried.

                      2. user hits save. The values he has changed will be updated + I should write an update statement inside loop (first_record to Last_record) for hidden field.

                       

                       

                      No, there is some misunderstanding here. The question is, is there any other interaction between your form and the user between step 1 and 2? Does the user edit some additional fields? If so, the suggested way would be:

                      1. Block is queries

                      2. User does some manual things on the block.

                      3. User hits save. Now you loop over the block and set the value of your hidden field. Then you issue a COMMIT_FORM, forms does the "real" update.

                       

                      If the user just queries the block to then aftterwards press save without any interaction, then the processing would be different.