Deleting a row in IR in Apex 4.2 - oracle-apex

Back with a new issue. I want to delete a row from an IR by having a delete icon as a column in the report itself and when I click on that icon a DA will fire which will call a code to delete that record and also will call API to delete the rows from fnd_attached_documents.
I did the following
Created an IR with the following query :
SELECT nvl(to_char(task_id), '-') "Title",
'-' "Type",
nvl(description, '-') "Description",
'-' "Category",
-- nvl(last_updated_by,'') "Last Updated By",
nvl((SELECT v('APP_USER') FROM sys.dual), '-') "Last Updated By",
nvl(last_update_date, SYSDATE) "Last Updated",
dbms_lob.getlength(file_content) download,
attachment_id,
document_id,
media_id,
'' "Delete"
FROM my_attachments
WHERE task_id = :p2_case_number;
Delete is not a column in the table and P2_CASE_NUMBER is an Item. Once the report was created I went to the report attributes --> Column Attributes and clicked on the Edit icon of delete and in the column link selected the icon and target as URL gave the following URL -
My DA is as follows
Name - DELETE_ATTACHMENT
Event- Custom
Selection type - DOM Object
DOM Object Title
True Action : PL/SQL code
DECLARE
lv_case_number NUMBER;
lv_attachment_id NUMBER;
BEGIN
lv_case_number := :P2_CASE_NUMBER;
APPS.DELETE_FILE_ATTACHMENT(lv_case_number,lv_attachment_id);
END;
Now I am facing the following issue and dont know what to do about them
I need to pass the attachment Id coming from the report as the second parameter to procedure I am calling, so how do I do that?
I need to refresh my report region only so that when delete happens I dont have to refresh the page myself?
I am using ebs r12 and apex 4.2
Thanks

You have to add the attachment id to link attributes and also a css class, that you can reference later in the DA:
data-id="#ATTACHMENT_ID#" class="delete-row"
You will need a hidden item to save the attachment id of the clicked row. In this example:PX_ATTACHMENT_ID
Then create a DA that is triggered when the link is clicked:
Event:click,Selection type:jquery selector,jquery Selector:.delete-row
Event scope of the DA should be dynamic, otherwise it won't work after the first refresh of the region.
Add a true action:
Action:set value,Set Type:Javascript Expression,Javascript Expression:this.triggeringElement.getAttribute('data-id'),Affected Items:PX_ATTACHMENT_ID
Add another true action:
PL/SQL Code to delete the attachment and make sure that you add PX_ATTACHMENT_ID to Page Items to Submit
Add another true action:
refresh report
https://apex.oracle.com/pls/apex/f?p=111339:2

Related

Oracle APEX - switching Region Display Selector regions from a link item

I have a couple of classic report columns that are links and a region display selector with a couple of regions under it. How can I switch between RDS regions dynamically when a corresponding column link is clicked?
I tried setting link type to URL and set it to
apex.region("RDS").widget().aTabs("getTabs")["#MY_TAB_STATIC_ID"].makeActive();
But that did not work - APEX tried to go to a different page.
Here is one option. I didn't use page items but you'll probably be able to reuse the logic:
Create 2 regions, give them static id rdsregion-1 and rdsregion-2
Create a display selector
Create a static report with the following sql:
select EMPNO,
ENAME,
JOB,
MGR,
HIREDATE,
SAL,
COMM,
DEPTNO ,
CASE WHEN SAL > 2500 THEN '<div class="setrds1">set rds 1</div>' ELSE '<div class="setrds2">set rds 2</div>' END as rds
from EMP
Create a dynamic action named "Set RDS1"
Event: Click
Selection Type: jQuery Selector
jQuery Selector: .setrds1
add a true action to DA "Set RDS1" o
Action "Execute Javascript Code"
Javascript code:
$('#rdsregion-1_tab a').trigger("click");
Create a similar dynamic action for RDS2.
Note that both snippets work:
$('a[href="#rdsregion-1"]').trigger("click");
and
$('#rdsregion-1_tab a').trigger("click");

Attachments moved away from Item after validation and before submit process in Apex

I have multiple File Browser Item fields on one page of Application in Oracle Apex.
What happens: When I miss any Item for which validation error fires, I want to hold that file to the browser but I usually loose it if I get that validation error. Is there a solution for the same like other Items fields hold previous value except File Browser Item field. Please see below ss:
Anshul,
APEX 4.2 is very old and no longer supported. A later (or preferably latest) version of APEX will behave differently as Dan explained above.
Can you import your application into apex.oracle.com (which is running APEX 20.1) and you will probably see better results. Based on this you can hopefully use it as justification to upgrade your environment.
Regards,
David
Go to your page-level attributes and a function like the following in the Function and Global Variable Declaration:
function validateItems(request) {
var $file1 = $('#P68_FILE_1');
var $file2 = $('#P68_FILE_2');
var errorsFound = false;
if ($file1.val() === '') {
errorsFound = true;
// Show item in error state
}
if ($file2.val() === '') {
errorsFound = true;
// Show item in error state
}
if (!errorsFound) {
// I think doSubmit was the name of the function back then. If not, try apex.submit
doSubmit(request);
} else {
// Show error message at top of page, I'll use a generic alert for now
alert('You must select a file for each file selector.');
}
}
Then, right-click the Create button and select Create a Dynamic Action. Set the name of the Dynamic Action to Create button clicked.
For the Action, set Type to Execute JavaScript Code. Enter the following JS in code:
validateItems('CREATE');
Finally, ensure that Fire on Initialization is disabled.
Repeat the process for the Save button, but change the request value passed to validateItems to SAVE.

Oracle APEX - how i can change translate action menu language (interactive grid and report)

I'm trying to change the language of default UI elements language in my APEX application to Arabic language :
i change the button (excepted interactive button) and column header language using XLIFF file , but i can't change action menu language , how i can do that if it possible.
You have to create new "messages":
Try to find message id:
select *
from APEX_APPLICATION_TRANSLATIONS
where WORKSPACE = 'INTERNAL'
and message_text = 'Subscription';
Copy TRANSLATABLE_MESSAGE field value (e.g. APEX.IG.SUBSCRIPTION or APEXIR_SUBSCRIPTION) and remember IS_JS_MESSAGE value
Go to Shared Components -> Globalization -> Text Messages -> Create Text message
Put id id name field (APEX.IG.SUBSCRIPTION)
Select your language
Fill "Text"
Select the same value as already exists in field IS_JS_MESSAGE
Your application language must me the same with this new message.

Disabling/Enabling a oracle apex Tabular Form Attribute based on the value selected in another attribute

I have a tabular form attribute which is a select list with static values Yes/no and another 2 attributes of Date and display.
My requirement is when i select "No" from the Select List, Date attribute should be enabled and Display attribute should be Disabled and If "Yes" From select list Display attribute should be enabled and Date attribute should be Disabled.
Dynamic Action:
Created a Dynamic action:
event = Change
Selection Type = Jquery selector
Jquery selector = `select[name='f06']`
Action = Execute javascript Code
var el = this.triggeringElement.id;
var row = el.split("_")[1];
if ($v(el) == "N") {
// disable the field
$x_disableItem("f04_" + row, true);
}
else {
// enable the field
$x_disableItem("f04_" + row, false);
}
Dynamic action Working perfectly for already created Rows, But not while i am trying to add new Row by selecting Add row.
https://apex.oracle.com/pls/apex/f?p=38210:LOGIN_DESKTOP:115699939041356
App 38210. Apex 4.2.6
Workspace/username/password : nani4850
Kindly help me out experts!!
Adding a blank row involves a partial page refresh, so the Event Scope of your dynamic action needs to be changed from Static to Dynamic in order for the change event handler to remain bound to the triggering elements.
You'll now find you have problems submitting new records, but if you're having difficulty, that's for another question!

Sitecore: multilist during deployment

How to enable the multilist to be control in content editor?
for example I have a list of item, item1 to item10. In the standard template value, I defined item1,2,3. After I have deploy the solution, how am I going to enable users in content editor mode or page editor mode to select item7,8,9 and 10?
And also, after I tested/rendered the multilist, only RAW VALUES are being rendered, is there any possible to render the item name such as item1? Do I need to customize the multilist?
The multilist control should be directly visible to the user in the Content Editor, you do not need to do anything else. Since you defined some items in standard values then those will be "pre-selected" when that item is first created. The user can then add the additional items as required.
To allow users to select values from the Page Editor you can Use Sitecore EditFrame in PageEdit
The reason the item is being rendered as the raw value is because you need to get the item and then iterate over the target id's. There is an example of this here here
//Get a multilist field from the current item
Sitecore.Data.Fields.MultilistField multilistField = Sitecore.Context.Item.Fields["myMultilistField"];
if (multilistField != null)
{
//Iterate over all the selected items by using the property TargetIDs
foreach (ID id in multilistField.TargetIDs)
{
Item targetItem = Sitecore.Context.Database.Items[id];
litItemTitle = targetItem.DisplayName;
// Do something with the target items
// ...
}
}
You can use the following instead for the datasource of a repeater
Sitecore.Data.Fields.MultilistField multilistField = Sitecore.Context.Item.Fields["myMultilistField"];
Sitecore.Data.Items.Item[] items = multilistField.GetItems();