I am very new to oracle forms and I have to make a button conditional on my form.
The visibility of the button depends on user role.
The button should be visible only to a user whose role is 'admin'. If the role is 'super admin' the button should not be visible.
Thanks!
Use the set_item_property built-in and its displayed property.
You didn't explain how to know who is who, so I'll guess that it is contained in a global variable, so you'd then
if :global.user_role = 'super_admin' then
set_item_property ('employees.btn_create_department', displayed, property_false);
elsif :global.user_role = 'admin' then
set_item_property ('employees.btn_create_department', displayed, property_true);
end if;
For more info, open Forms Online Help system and read about that procedure.
Related
I am creating an application on Oracle Apex version 18 that takes survey from users.
I have used form on table for that purpose. However, users are able to submit the form multiple times. Is there a way to freeze the submit button once the form is submitted?
Yes; you have to be able to find out whether it was already submitted (for example, record in a table gets its ID; or, survey_date gets is set to sysdate).
Then create a condition for that button. A simple option is to use a function body that returns Boolean, e.g.
return :P1_ID is null;
which will render the button only if :P1_ID item is empty. If it is not, you won't see the button any more.
In the first instance I would try setting the page attribute Enable duplicate page submissions to No.
It seems like you don't want users to be able to answer the same survey multiple times.
In order to achieve this you can use a server side condition as Littlefoot suggested, but you seem to have problems with setting up the server side condition properly.
If you use a hidden item on your page, which holds the value of the current survey the user has to answer like "P1_SURVEY_ID", you can add a server side condition that doesn't allow the user to answer it again, if he already has:
Type: No rows returned
SQL Query: select * from YOUR_SURVEYS where SURVEY_ID = :P1_SURVEY_ID;
This way the user can only click the button if he has not answered this specific survey yet.
This is a easy solution:
https://community.oracle.com/thread/4167853?start=15&tstart=0
Simply add the "Page Submit" TRUE Action to your Dynamic Action and
set the Show Processing "o Yes. Then you don't even need any Enable or
Disable Actions on your button.
I have a text item ('TXT_EG_PER') and a list item('LI_P') as tabular in a datablock('DB') as shown in the picture.
I want to make list items enable/disable singly based on the row data.
I used 'TXT_EG_PER's WHEN-VALIDATE-ITEM trigger. My code in it:
IF smt.. THEN
SET_ITEM_PROPERTY ('DB.LI_P',
ENABLED,
property_true);
ELSE
SET_ITEM_PROPERTY ('DB.LI_P',
ENABLED,
property_false);
END IF;
But it makes all list items enable or disable. I want to do it row based.
Use SET_ITEM_INSTANCE_PROPERTY instead. Its usage is described in Forms Online Help System. Have a look, as it doesn't have the same parameters as SET_ITEM_PROPERTY built-in, e.g.
set_item_instance_property(item, record, property value);
In your case, that might be
SET_ITEM_INSTANCE_PROPERTY ('DB.LI_P',
:system.trigger_record,
ENABLED,
property_true);
I created a textbox and a button. What I wanted to happen is that after pressing the button and the textbox is null, the focus must go back on textbox.
BEGIN
IF :blk.textbox IS NULL THEN
msg_alert('Error message', 'E', FALSE);
end if;
END;
I'd already tried to put the code above in WHEN-BUTTON-PRESSED trigger but nothing happens.
Put your code in WHEN-VALIDATE-ITEM trigger of :BLK.TEXTBOX item.
BEGIN
IF :blk.textbox IS NULL THEN
msg_alert('Error message', 'E', FALSE);
--if msg_alert procedure has no RAISE FORM_TRIGGER_FAILURE, then uncomment next line
-- RAISE FORM_TRIGGER_FAILURE;
end if;
END;
You can also set the MOUSE NAVIGATE property to FALSE (or NO) of the button so that the focus won't go to that button after it was clicked.
use GO_ITEM also to set the focus to the textitem. sample,
GO_ITEM('blk.textbox');
Why reinventing the wheel? Set text item's REQUIRED property to YES.
After reading comments you left for #eifla001's answer, I'm not sure what is the code you have. Something like this works properly on my Forms 10g (but should work on any version):
-- WHEN-BUTTON-PRESSED trigger
if :blk.textbox is null then
go_item('blk.textbox');
end if;
If it doesn't work, check TEXTBOX's properties. Is it really a text (or a display) item? Is it enabled? Are there any SET_ITEM_PROPERTY calls that make it unavailable?
Because, task you're about to perform is really trivial, that should work just like that.
'+' sign to create a case on customer/account is missing in CRM 2016. Though the role has all the privileges to create , read, write and append , append to. See the screen shot below, missing + sign:
Tried removing and adding the security roles again, it didn't help. Also it does not appear in admin role as well. Any Suggestions ?
This is most likely because the relationship is not a navigable relationship. When you click the drop-down arrow you should see Cases (I'm assuming the system does not have more than one relationship between Account and Cases.) If you do not have the relationship showing here you will not get a + sign to add a new record
To add the relationship to the form edit the form and add the relationship to the left-hand navigation configuration.
Provided, the security role having Create privilege for Incident entity, this button should appear.
The problem could be because of 2 reasons.
Either someone customized the ribbon to hide the 'Add New' button from subgrid menu
or
Subgrid should be inside a Quick view form. In this case - Lock symbol will appear before text "Recent Cases" which is not true in your case
Moreover I personally tested by removing the left navigation in form, 'Add New' button is still visible, only 'Associated View' is removed.
I have 2 data block 'Employee' as master and 'Employee_Details' as details and 1 control block for navigation. I have used my menu and usually the default developer toolbar was not appeared. So I place a Enter-Query button to serve the purpose. I used when-button-pressed trigger.
GO_BLOCK('EMPLOYEE');
IF :System.Mode = 'NORMAL' THEN
Enter_Query;
ELSE
EXECUTE_QUERY;
END IF;
In first trigger the Form goes to Enter-Query Mode. But when I pressed for Execute_Query it does not work. Rather it shows in status bar to press F8 to do query and Ctrl+q for cancel. I tried it to place the code in different button but not working. I do not want to press F8 for execute query. Why my button code not working for Executing Query? Have you any solution?
The problem probably is that there are a few options with your trigger.
One of them is if it will fire when in enter query mode.
Because you are in enter-query mode right now this switch should be true.
Then it will work.
The default for the switch is false, so no trigger will fire in enter-query mode.