This discussion is archived
8 Replies Latest reply: Mar 3, 2013 2:20 PM by jrimblas RSS

confirm delete record in Report

Gor_Mahia Explorer
Currently Being Moderated
All,
I created IR to enable deleting a record via record-level button like shown here,
http://apps2fusion.com/at/64-kr/391-oracle-apex-person-details-tutorial-02-delete-functionality
how do i add a prompt to confirm like(do you really want to delete this record) before actually deleting the clicked record?

thanks & regards
  • 1. Re: confirm delete record in Report
    jrimblas Expert
    Currently Being Moderated
    You'll want to set your image/button to execute a javascript like this:
    javascript:apex.confirm("Are you sure?",{request:"DELETE_ROW", set:{"Pn_ITEM_ID": #ID#}});
    Then have a process that fires when the Request is DELETE_ROW and such process will use the value set on a hidden item Pn_ITEM_ID.
    So, it goes without saying, make sure you do have a hidden item to hold the ID of the row you're deleting.

    Hope this makes sense.
    Thanks
    -Jorge
  • 2. Re: confirm delete record in Report
    AnthonyRayner Pro
    Currently Being Moderated
    Hi,

    As another alternative, you could also take a look at the 'Refresh 2' example from the 'Sample Dynamic Actions' packaged applications, that is shipped with APEX 4.2.1. This page shows an example of what you are tying to achieve, using Dynamic Actions.

    Regards,
    Anthony
  • 3. Re: confirm delete record in Report
    Gor_Mahia Explorer
    Currently Being Moderated
    jrimblas

    in my case I've the img src conditionally displayed from the report query with SELECT...STATEMENT because not all rows can be deleted. so how do I implement DELETE_ROW request I already have hidden item to store the clicked ID and delete process.

    using Apex 4.1.1

    regards
  • 4. Re: confirm delete record in Report
    Gor_Mahia Explorer
    Currently Being Moderated
    Anthony

    iam not sure but will that be applicable in apex 4.1.1?
    thank you
  • 5. Re: confirm delete record in Report
    AnthonyRayner Pro
    Currently Being Moderated
    Hi,

    Yes, all the capability used in that example is available in APEX 4.1.1. (The only slight difference, is that in 4.1.1, the Dynamic Action's 'Event Scope' (in the 'Advanced' section of the DA), was named 'live', rather than 'Dynamic' as it is in 4.2 or greater.

    Regards,
    Anthony
  • 6. Re: confirm delete record in Report
    jrimblas Expert
    Currently Being Moderated
    Gor_Mahia wrote:
    in my case I've the img src conditionally displayed from the report query with SELECT...STATEMENT because not all rows can be deleted. so how do I implement DELETE_ROW request I already have hidden item to store the clicked ID and delete process.

    using Apex 4.1.1
    You can still apply the same technique. Check out this thread for an approach to what you're doing
    Help Creating A Link In An IR Report Passing The Value From A Different Col

    You can still build the link with the destination you want in the URL.

    As a bonus you can combine it with Anthony's suggestion and have a cleaner declarative solution.

    Thanks
    -Jorge
  • 7. Re: confirm delete record in Report
    Gor_Mahia Explorer
    Currently Being Moderated
    jrimblas
    actually my problem is not conditional display. I already have img src= displayed only for some records as i want, i have hidden item to get ID passed and the process to execute the DELETE statement. Where do i put the java-script confirm popup so it actually prompts before delete a record.
    i looked at the dink you mentioned but that's a bit different tasks.


    thanks.
  • 8. Re: confirm delete record in Report
    jrimblas Expert
    Currently Being Moderated
    Sorry for the delay, I'm on vacation this week and finally found time to connect.

    You don't give me enough information to know how you're accomplishing the image. You only say img src. Is that built on the SQL or on the column?
    If on the column, then you want to indicate you're linking to a URL and place the Javascript code as your URL.
    Something like this:
    javascript:apex.confirm("Are you sure?",{request:"DELETE_ROW", set:{"Pn_ITEM_ID": #ID#}});
    If it's on the SQL, then you need to wrap your img tag with an "a" or anchor tag. The end result needs to look similar to this:
    <a href="javascript_from_above"><img src=".jpg"></a>
    Because this is in the SQL you need to change #ID# for a concatenation of your values. Also, watch for the quotes, you'll need to escape your quotes.

    Thanks
    -Jorge

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points