How to differentiate a record created by a pick applet and by New button in Siebel - siebel

Currently I have an applet on which user can either create record by New button or it can add records from a pick applet. I want to differentiate between these two type of records like this:
If (Record is by New button)
Field: f = 0
If (Record is by pick applet)
Field: f = 1
Can I achieve it?

You could try an extra Pickmap.
On the PickList BusComp, add a calc field with a hardcode value of "1" in the calculation.
On the base BusComp, on the field with the picklist, add one more pickmap , which stamps the value of the new calc field into the field 'f' (in your example above) of the base bc. Then on the field 'f', add a predefault value of '0'.
If the record in the base bc is created via new record, the value '0' will be predefaulted to 'f'. But when the value is picked, the value '1' should be picked onto 'f'.
Turn on audit trail to debug this.

Related

Oracle Apex Autocomplete Item to return ID value, not the lookup value

I have the table "SYMPTOMS" with two fields:
"ID" number and "SYMPTOM" varchar2(1000).
I want on my page the item "P2117_SYMPTOM_ID" to be autocomplete and search from the second field ("SYMPTOM") but to return the ID value of this record.
Check the docs. The page item type "Text field with autocomplete" only takes a single column as source (a return value), not 2 columns like a list of values. Reason is that this is an enhanced text field: you can freely enter data but it will suggest you possibilities from a list. A text field only has its actual value as return type too. You could have return ids from a table but then how would you handle values entered by the user that are not in the list ? If you want to map the data the user enters to an id then you can write your own function to do that. Ideally that function would:
Return the id of the value if it exists
Create a new value and return that newly created id if it doesn't exist.

How to create a field with a list of choices but store the index?

I'm making a Microsoft Access table where one of the fields is a list of pre-made options. When I make a SQL query on that table it returns the values of the list as strings containing the spelled out choice. I would like to assign numerical values to each element of the list so a SQL query returns a number instead. How do I do this? I know it's possible because I have an access file with such a list but I'm unable to recreate it.
An easy way to do this is to have your combo box use a query of the table as a Rowsource. This query would have the table unique ID in the first field and the field you wish to return as the second field. Then change the setting on the combo box for "Column Count" to 2. If you want to show both fields change the "Column Widths" value to 1"; 1". If you want to show only one field, change the value of one you do not want to see to 0. Now we you refer to this list in an SQL queries, it will use the ID field but show the user the string field.

Reselect item on Select2 multi-value select list

I use plugin Select2 on Apex.
I have scenario like this:
I have three tables: ROOM, MASTER_STUDENT and MAP_STUDENT_ROOM
One ROOM can have many STUDENT
User can select more than one student(with Select2 from MASTER_STUDENT) when create ROOM
When user edit ROOM, previously selected student show in Select2 item(selected item by MAP_STUDENT_ROOM), so user can remove or add more Student
How to achieve point number 4, item Select2 list of values is MASTER_STUDENT but with default selected by MAP_STUDENT_ROOM?
I found this documentation, but i dont know how to apply it.
I'm not familiar with the Select2 plug-in.
Have you considered using the built-in Popup LOV, which since APEX 19.1 now allows multiple selection.
Whether you're using the Select2 plug-in or the built-in Popup LOV, the issue will be the same. You have a form on ROOM, that's trying to take into account an item that isn't part of the ROOM table (its values are stored in MAP_STUDENT_ROOM). The trick is to populate the item correctly during page load so that the item can correctly display the currently assigned students.
How is the item's Source configured? If it's not, set Type to SQL Query (return colon separated value). Assuming you have a primary key item on the page for the room (e.g. P1_ID), enter a query like the following:
select student_id
from MAP_STUDENT_ROOM
where room_id = :P1_ID
Then set Used to Always, replacing any existing value in session state.
This should get the item to display correctly when the page loads. However, you'll still have to figure out how to map the values back to the MAP_STUDENT_ROOM table correctly when the page is submitted. You'll need to add some logic that first deletes rows from the room (P1_ID) that are not in the selection (e.g. P1_ASSIGNED_STUDENTS). You can use APEX_STRING.SPLIT_NUMBERS to help:
delete from map_student_room
where room_id = :P1_ID
and student_id not in (
select column_value
from apex_string.split_number(:P1_ASSIGNED_STUDENTS, ':')
)
Then you can insert rows that are in the selection but not already in the room.
insert into map_student_room (
room_id,
student_id
)
select :P1_ID,
column_value
from apex_string.split_number(:P1_ASSIGNED_STUDENTS, ':')
where column_value not in (
select student_id
from map_student_room
where room_id = :P1_ID
)
I've not tested any of this code, but it should get the points across.
Another option would be to use an Interactive Grid instead of a list of values item. This is a classic master/detail scenario where students could be added and removed below the form region (typically only done after create).

apex_item_text Add Row/Remove Row Apex

I am working with Apex_Item_Text .. i am using the below query to display the text area in apex as null initially.
select distinct a.GUID, a.CREATED_BY, a.created_date, apex_item.text(null)
Delete from
NON_DYNAMIC_USER_GROUP_MEMBERS a,
NON_DYNAMIC_USER_GROUPS b
where a.DYNAMIC_GROUP_ID in
(select DYNAMIC_GROUP_ID from NON_DYNAMIC_USER_GROUPS
where instr(','||DYNAMIC_GROUP_ID||',' , ','||:P153_ID_HIDDEN||',') > 0) ;`
In Apex application once the text area filled by user as Delete/Add, it has to update in table when submit button pressed, i don't know how to proceed further on this.
Thanks
You need to pass in a number into the apex_item.text function. By passing a number APEX will automatically create an array that will store the values of those columns.
This can be referenced in your delete statement with: APEX_APPLICATION.G_FXX(i) where XX is the number you pass into the apex_item.text function and i is the index of the item.
Without passing a number into the apex_item.text function I would have no idea how to reference that field
See oracle documentation for more information about apex_item.text: https://docs.oracle.com/cd/E14373_01/apirefs.32/e13369/apex_item.htm#AEAPI211

How to pass data between fields in Oracle APEX 5.1?

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.