How to pass data between fields in Oracle APEX 5.1? - oracle-apex

This is a VERY basic question. Sorry for not providing any code I have NO IDEA how to even start tackling the problem
I have lets say two fields... One is a date selector field and the other a regular text field. What I want is when I select a date (or type a date), the value comes in the second field... Just that...
I'm on APEX 5.1.4

Since you have stated that the second item is a text field, you could do this with the help of a dynamic action that sets the value of the second item when there is a change in the value of the first item ( date field).
The following would be the steps, if you are using component view:
Create Dynamic Action
When
Event : Change
Selection : Item(s)
Item : First Page Item
Condition : is not null
True Action
Action : Set Value
Fire on Page Load: No
Set Type: You can choose how you want to set the value of the second item on the page.
If you have the flexibility to change the second item to be a select list and you have a list of values that goes with a date, you could do this much simpler, with a Cascading LOV
On Second Item's - Under List of Values section
Cascading LOV Parent Item(s) : First Item
Page Items to Submit: First Item
List of Values definition: Here you can define the query.
Hope this helps.

There are a few different ways to do this, probably the easiest way is as follows.
Assume your two items are P1_ITEM1 and P1_ITEM2.
Create a dynamic action which fires on change of item P1_ITEM1.
The true action of this should be action:set value, set type:PL/SQL Expression, item::P1_ITEM2, items to submit P1_ITEM1.

Related

How get display value of checkbox in a checkbox group?

I am using APEX 21.1. I have a checkbox group whose list of values is retrieved using a query...
select disease, id from history;
The query returns many checkboxes. I have another textarea item. I need to get the display value for any checkbox whenever it's checked and set item HISTORY to that value. How to do so?
Describing a how-to would be so much easier if you had provided some example page item names and example data. So, lets call your checkbox group P10_CHECKBOX and your textarea P10_TEXT.
Usually, your checkbox group will save the item ids as a colon seperated list, like this: 3:4:5
To display the corresponding display values, make a dynamic action on change on your item P10_CHECKBOX.
Then, use an action of type Execute PL/SQL Code to fetch the display values of your items.
The code could look like this:
select listagg(disease,chr(10)) within group (order by disease) into :P10_TEXT
from history h
join table(apex_string.split_numbers(:P10_CHECKBOX,':')) t on (h.id = t.column_value);
apex_string.split_numbers will convert your colon list into an actual "table" with the column column_value you can use in the join clause. listagg will do the actual concatenation and will work up to a couple thousand characters. chr(10) is an ordinary line break and will have your items be shown line by line, but any other seperator will do.
Last step is to set up P10_CHECKBOX in your Items to submit and P10_TEXT in your Items to return.
Now, whenever you click a checkbox, the textarea will be updated immediately.

Oracle Apex Dynamic action not working for form items

I have a form with items P1_APP and P1_USER.
P.S. P1_USER is select list.
Display John
Return 1
Display Andy
Return 2
I need to disable when user selects John.
When P1_USER = 'John', P1_APP should get disabled which is a multi select list.
I created dynamic action on P1_APP, True Action= Disable,Affected element P1_APP
Client condition : Item =Value
Item= P1_USER
Value= John
However this is not working.
I have used similar logic to disable interactive grid items and was able to do so. Why is this not working for form?
EDIT: In Value now i am putting 1 which is return value for John.
However when i select John. It disables P1_App upon clicking. But remains disabled even when i choose Andy.
This works for me using the following configuration.
Create form and report on EMP - everyone has access to that sample data, it is a good idea to post questions based on that.
In the form P3_DEPTNO is a select list with source
SELECT d.dname, d.deptno FROM dept d
Add a page item to my form P3_APP. This is a select list with "Allow multi selection" enabled. Select list has 2 static values.
Create a dynamic action on change of P3_DEPTNO.
Client side condition: Item = Value
Item: P3_DEPTNO
Value: 30 (note that this is the return value for SALES, not display value)
add true action of "Disable", affected item P3_APP
Click true action and select "Create Opposite Action". Save.
When I run this it work. Selecting SALES in the select list disables the item P3_APP and selecting something else enables it.

How to get the values in items without refreshing the page in apex

I have an item to enter email id, and two more items to get the values of first/last name and department of that user which we have given without refresh the page or without enter.
Item 1: ex : a...z#gmail.com (text field)
Item 2 : ex Mechanical (display only)
Item 3 : ex Abinnaya Moorthy (display only)
This should happen when we have given the email id and as soon as the cursor is out from email id the two item values should display.
I have used dynamic action but not getting exact output, please let me know.
On Item 1 make a following dynamic action:
Event: Change (I would recommend 'change', although based on your question, you might also be interested in 'Mouse Leave', although it would trigger DA even when no change in item value occurred, for example when someone just clicked on it and clicked away)
Selection Type: Item
Item: your Item 1
First true action: Execute PL/SQL Code
inserting values into your items Item 2 and Item 3, while using your Item 1 as a condition in WHERE clause
Page Items to Submit: your Item 1
Page Items to Return: your items Item 2 and Item 3
Second true action: Refresh
Selection Type: Item(s)
Item(s): your items Item1 and Item2
Let's say I have 1 field like an email field above. Then I have 50 display only fields that values are coming from (Source) SQL queries that depends on email field. How to refresh this fields without refreshing page, but also without Setting its value manually? I would only like to trigger them to perform their Source SQL query and refresh values on the page.
Setting their values by SetValue action will result in having same queries in Dynamic Action and in Source SQL Query for each field. Also for 50 fields DA would have hundreds of SQL lines and would become not maintainable.
assuming you are working on page 9, and the email field is :P9_EMAIL_ITEM, and the name fields are :P9_FNAME_ITEM and :P9_LNAME_ITEM
The email field is a text field (it doesn't matter what the source is)
The name fields should be display only, and in properties the setting "Based On" should be "Page Item Value", set the source property to type Null.
On the email text field, create a new dynamic action, set the When properties to: Event -> Change, Selection Type -> Item(s), Item(s) -> P9_EMAIL_ITEM
Under the dynamic actions you'll have a "New" event, with a "True" folder, and inside it a new action (probably "Show"). Change its action to "Set Value".
change the setting property so that "Set Type" will be "SQL statement", and write a statement with the following structure:
select FNAME_COLUMN, LNAME_COLUMN
from RELEVANT_TABLE
where EMAIL_COLUMN = :P9_EMAIL_ITEM
Under "Items to submit" select the P9_EMAIL_ITEM.
in the Affected Elements properties set Selection type -> Item(s) and Item(s) -> P9_FNAME_ITEM, P9_LNAME_ITEM
In "Execution Options" select NO for Fire on Initialization
what we did on step 5 is "refreshing" the relevant items, without refreshing the page
I just tested it out and here's what works very well:
On Item 1, create a DA on 'Loose Focus'
Create two true actions for 'Set Value', for both Item 2 and Item 3.
Select Settings > Set Type as SQL Statement.
Write query to fetch item 2 and item 3, base on item 1 (I suggest comparing lower cases of both to make it case in-sensitive.)
Items to Submit -> Item 1
And viola, it's done!

How to perform partial refresh of page in APEX5.0

I have an APEX page where it contains multiple regions. Each region has its own drop down list (Select list) item and a bar chart. My problem is from any particular region when I select a value from the drop down list, the whole page is refreshed as I have the option Submit page set for Page Action on Selection property.
How do I perform partial refresh so that during the selection from drop down list only the bar chart for that region should be refresh and not the entire page?
Go on your select list item and change the Page Action on Selection property from Submit Page to None. Then create a dynamic action on page with the following options:
Event=Change
Selected Type=Items
Item=Your select list item
Action=Refresh
Selection Type=Region
Region=Your bar chart
Same as answer above with one trick to make it work. The value in your select list has not been submitted so will be null and not work.
Add another Dynamic action that runs before the refresh one of type PLSQL. set the code to null; then add your select list to the "items to submit".
Should work now :)

xml for accessing the repeater control row values in infopath form

I have the web service, which has method State() that returning the List. where i want to design the infopath form that having the repeating table. in repeating table one of column should have the drop down list.
I want to populate this List in the drop down list (states). Each selected instance in the dropdown must be unique means when i would select state A for row 1 then in other row there must be validation that should not select the state A again.
in short avoid the duplicate selection.
Include a section with a validation message under each dropdown. Select the section Properties > Display > Conditional formatting.
Set the condition as dropdown2_field is equal to dropdown1_field.
(Need to add similar multiple conditions for 3rd,4th successive dropdown boxes.)
and select Hide this control check box.
If the user selects the same state in dropdown2 the validation message is shown.