This discussion is archived
9 Replies Latest reply: Oct 12, 2013 7:38 AM by NZK RSS

set_block_property on 6I

NZK Newbie
Currently Being Moderated

Dear All

 

In one of my forms there is a condition as follows

     IF :GRN_POSTED = 'P' THEN

          SET_BLOCK_PROPERTY('BLOCK1',INSERT_ALLOWED,PROPERTY_FALSE);

          SET_BLOCK_PROPERTY('BLOCK1',INSERT_ALLOWED,PROPERTY_FALSE);

          SET_BLOCK_PROPERTY('BLOCK1',INSERT_ALLOWED,PROPERTY_FALSE);

     ELSIF :GRN_POSTED = 'O' THEN

          SET_BLOCK_PROPERTY('BLOCK1',INSERT_ALLOWED,PROPERTY_TRUE);

          SET_BLOCK_PROPERTY('BLOCK1',INSERT_ALLOWED,PROPERTY_TRUE);

          SET_BLOCK_PROPERTY('BLOCK1',INSERT_ALLOWED,PROPERTY_TRUE);

     END IF;

 

This coding run in Pre-insert-trigger, pre-delete-trigger and pre-update-trigger. My issue is when I query a GRN which is already posted i can do modification and save. once I saved it i cant do any modifications. but when i requery it again i can do modification as before. strange;

Please help

Regards

NZK.

  • 1. Re: set_block_property on 6I
    Andreas Weiden Guru
    Currently Being Moderated

    First, why do you issue the same statement 3 times?

     

    Second, the code does not make sense in the mentioned triggers, as they fire for each record, but the code sets properties for the whole block.

     

    So the question is, what is your desired behavior? Should the user be able to insert new records? should the user be able to update existing records?

  • 2. Re: set_block_property on 6I
    NZK Newbie
    Currently Being Moderated

    Dear Andreas

     

    Sorry that was a mistake in the code it should be INSERT_ALLOWED,DELETE_ALLOWED & UPDATE_ALLOWED.

     

    What is my requirement is when the GRN is posted, user cannot update, delete or insert to the GRN.

     

    Hope you understood my question

     

    NZK

  • 3. Re: set_block_property on 6I
    Andreas Weiden Guru
    Currently Being Moderated

    How many records do you show in your block? Is the block you want ro disable a different block or it is the same block where your GRN_POSTED is in?

  • 4. Re: set_block_property on 6I
    NZK Newbie
    Currently Being Moderated

    Dear Andreas

     

    There are two separate blocks. 1 is Master Block where there is only one row. The other one is Lines block where, there can be one or many rows.  Once the GRN status is POSTED then I want to restrict INSERT/UPDATE OR DELETE on both blocks. User can navigate from MASTER to LINES block and vice-versa. I want to disable both blocks once the GRN is posted.

     

    NZK

  • 5. Re: set_block_property on 6I
    Sekhar1224 Newbie
    Currently Being Moderated

    Better try in post_insert trigger.

  • 6. Re: set_block_property on 6I
    Priyasagi Pro
    Currently Being Moderated

    Dear Mr.NZK,

     

    To restrict modifications based on an item value(pst_yn), you have to write item level trigger for all fields except posted indicator (ex.) pst_yn for example,

     

    when-new-item-instance

     

         if :pst_yn='Y' then

              if get_item_property('doc_date',update_allowed)='TRUE' then
                   set_item_property('doc_date',update_allowed,property_false);
              end if;

         else

              if get_item_property('doc_date',update_allowed)='FALSE' then
                    set_item_property('doc_date',update_allowed,property_true);
              end if;

         end if;


    To restrict deletions based on an item value(pst_yn), you have to write block level trigger like,

     

    key-delrec

     

         if :pst_yn='Y' then
              null;
         else
              delete_record;
         end if;


  • 7. Re: set_block_property on 6I
    Andreas Weiden Guru
    Currently Being Moderated

    If GRN_POSTED in placed in the Master-Block, i would do the following:

     

    Disable the INSERT_ALLOWED, UPDATE_ALLOWED and DELETE_ALLOWED in the Post-Insert and Post-Update trigger. Additionally, enable ro disable them in the WHEN-NEW-RECORD-INSTANCE-trigger on the master-block.

  • 8. Re: set_block_property on 6I
    Priyasagi Pro
    Currently Being Moderated

    Your post is not give us much information,

    Andreas Weiden raised a big doubt.  The indicator field where is located? Either Header or Detail?...

    If it is located at Header then AndreasWeiden solution is suitable for your requirement.

  • 9. Re: set_block_property on 6I
    NZK Newbie
    Currently Being Moderated

    Dear Priyasagi

     

    Yes the indicator is located in Header.

     

    NZK

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points