Link to home
Start Free TrialLog in
Avatar of Solve
Solve

asked on

How to lock dispayed record in form

Hello, could someone help me and tell if there is a possibility to set records (also can be blocks), but in fact all records displayed in oracle form doesn't matter how many related data blocks are there, not updateble?
Actually, I am able to set block property update_allowed, delete_allowed, insert_allowed
step by step, but how to do it at once? Mabe there is some form's property that allow it?
actually, record has an attribute created_user, so if user logged on database are not who created record, coul be able only read, but nothing else.

Solveiga
Avatar of Helena Marková
Helena Marková
Flag of Slovakia image

You can use SET_ITEM_INSTANCE_PROPERTY in a Post-Query trigger. Loop through all items in a block and set this property according to created_user to true or false.
Avatar of Solve
Solve

ASKER

And how to loop througth all items and througth all blocks?
ASKER CERTIFIED SOLUTION
Avatar of Helena Marková
Helena Marková
Flag of Slovakia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Solve

ASKER

ok, going to try ...

But it is seems to be the same like when I am typing:

set_block_property ('Block_name1', update_allowed, property_true);
set_block_property ('block_name2', ....

lots of sentences, the same run time...

I am still looking for a reason, cause my form works very very very slow! So I thought this set_block_property(update_allowed) also, set_view_property(visble) to many items and views slow down forms... That is why I am searching the way to do it at once

s.


It is not the same - if you put LOOP in Post-Query trigger then SET_ITEM_INSTANCE_PROPERTY will set every item in every record according created_user. Set_block_property sets properties for all records in a block. There is also difference between SET_ITEM_PROPERTY: sets properties for item in every record in the block and SET_ITEM_INSTANCE_PROPERTY sets item property for record => there will be different property values.
Avatar of Solve

ASKER

One more thing: I only have created_user in master table, not detailed :(

s.
So you have to disabled records in another block different way e.g. by using item which is in both blocks ...
Avatar of Solve

ASKER

ok, going to try! seems to be everything good
also (if it is not too many sub questions for one question), what about canvases
I have 10 of them, and according one parameter I want one of them to be visible.
So I do it by set_view_property(canvas, visible, property_true);

s.
I think that you can do it :)
Avatar of Solve

ASKER

I always get message Illegal procedure NEXT_FIELD in POST_QUERY trigger :(

s.
This is very nice script provided by jwahl (https://www.experts-exchange.com/questions/22091470/Disable-Records-In-Form-Based-on-Criteria.html) - there is no RESTRICTED PROCEDURE like NEXT_ITEM:

DECLARE
    v_block_name VARCHAR2(32) := 'YOUR_BLOCK'; -- modify!
    v_block_id  BLOCK;
    v_item_id   ITEM;
    v_item_name VARCHAR2(32);
    v_block_item_name VARCHAR2(65);
BEGIN
    --
    v_block_id := FIND_BLOCK(v_block_name);
    --
    v_item_name       := GET_BLOCK_PROPERTY(v_block_id, FIRST_ITEM);
    v_block_item_name := v_block_name||'.'||v_item_name;
    --
    LOOP
       v_item_id := FIND_ITEM(v_block_item_name);
       --
       IF ID_NULL(v_item_id) THEN
          EXIT;
       END IF;
       --
       IF GET_ITEM_PROPERTY(v_item_id, VISIBLE) = 'TRUE' AND
          GET_ITEM_PROPERTY(v_item_id, ITEM_TYPE) IN ('TEXT ITEM','CHECKBOX', 'LIST') THEN
          --
          IF :STATUS = 'C' THEN -- modify!
             SET_ITEM_INSTANCE_PROPERTY(v_item_id, CURRENT_RECORD, UPDATE_ALLOWED, PROPERTY_FALSE);
          END IF;
          --
       END IF;
       --
       v_item_name       := GET_ITEM_PROPERTY(v_item_id, NEXTITEM);
       v_block_item_name := p_block_name||'.'||v_item_name;
       --
    END LOOP;
END;
Avatar of Solve

ASKER

leaving for monday !!!
have a good weekend
s.
You too :)
Nothing to contribute here but just to say that liked seeing Henka back after a long gap in between.  Welcome back , Henka
Thank you, sapnam :)
Avatar of Solve

ASKER

Hello form very early monday again :)
it seems everything is working... but with some misteries.
I put "my_disabled" in post-query trigger, but it disables only that's block itmes, not in related blocks. But it is because they are not visible I guess. so I put this procedure in all blocks. But I noticed one thing:
I also want to disable buttons, and do it in the same block's post-query trigger. So, when I am calling only this form - everything is ok, but if I am opening form from another one, buttons are not disabled even if they have to be disabled...
What can it be wrong?

solveiga
"But it is because they are not visible I guess" - items ought to be enabled, there is no need of being visible.
Is there EXECUTE_QUERY (or Do_Key('EXECUTE_QUERY')) in a When-New-Form-Instance trigger ?
Avatar of Solve

ASKER

yes, it Is EXECUTE_QUERY (or Do_Key('EXECUTE_QUERY')) in a When-New-Form-Instance trigger...

I excluded this IF GET_ITEM_PROPERTY(v_item_id, VISIBLE) = 'TRUE' AND from your (jwahl) suggested code, so it doesn't workf with ID columns, because, they are not visible in any canvas

s.
What is problem - if ID columns are not visible then there is no need of setting SET_ITEM_INSTANCE_PROPERTY.
You can also use IF GET_ITEM_PROPERTY(v_item_id, ENABLED) = 'TRUE'  ...
Avatar of Solve

ASKER

Yes, I thought about it also....
Mabe somethin wrong with my head?! doesn't work anything!!!
What about this your question :If there ss EXECUTE_QUERY (or Do_Key('EXECUTE_QUERY')) in a When-New-Form-Instance trigger?
where to put this my_disabled (your suggested procedure name, in witch I am set disable item to other users..) to work when?
I would put it after execute_query in the When-New-Form-Instance trigger.
Avatar of Solve

ASKER

mabe in WHEN-NEW-RECORD-INSTANCE?
Oh, sorry - I would put it to the Post_Query trigger. You can also use WHEN-NEW-RECORD-INSTANCE.
Avatar of Solve

ASKER

ok, I am taking a break in writing messages and dirturbing you, going to test everything slowly and when I will inform you about situation.
Thank you for your patience
s.
Avatar of Solve

ASKER

Block's post-query doesn't affect other's block's items' properties if they are not visible or in not visible canvas or tab. Don't know why.
If I exclude this check get_item_property (item, visible), so my procedure throw erros "cannot set property to items with null canvas", it is because their are some items with null canvases.
Also doesn't work others blocks Post-query :(

but if I put this procedure into block's when-new-record-instance, it works to all blocks items, visible they or not.

s.

It is fine so use when-new-record-instance trigger.
"Block's post-query doesn't affect other's block's items' properties if they are not visible or in not visible canvas or tab. Don't know why." - item must be navigable if it ought to be include in a searching loop through the block. So item with null canvas are excluded. But why do you want change attributes (insert_allowed,update_allowed) for such items ? An user will never change them.
Avatar of Solve

ASKER

I don't whant.. But how to exclude then? I loop through all items...
but from your message I see, that I have also to check if it is navigable, hav I?

s.
No, if item is not enabled (sorry, it is enabled not navigable, I have made mistake), then it is not included to loop automatically.
Avatar of Solve

ASKER

Last question, what to do with combobox (list item)
I set_item_instance_property (update_allowed, property_false), but still able to select and insert value into combobox. What should I choice to perform such an action?
I am afraid, I confused myself in items, blocks, canvases, properties, ... at all!!


s.

List item can be selected but it will not be inserted. It is rather confused so I use a trick for list item: I create a When-Mouse-Click trigger with this code:

IF Get_Item_Property(:system.trigger_item,insert_allowed)='FALSE' THEN
  Go_Item(...); -- an item I wish a cursor to be moved to
END IF;