1

I have a conditional hyperlink column in my IG:

SELECT CASE WHEN t1.active = 'No' 
            THEN t1.active
       ELSE
            '<a href="#" onClick="javascript:$s(''P1_SELECTED_ID'','''||t1.ID||''');doSubmit(''REQUEST1'');"><button>Run</button></a>' END IsActive,
       ID as ID
FROM Table1 t1

I cannot use regular Link column as not every row will have it so I have to generate it using HTML in my select statement.

I have a process on my page to be executed when that button in the grid is clicked that has a server-side condition Request=Value and a value is set to REQUEST1. Now the process never executes and when debugging I saw that the process is skipped because condition or authorization evaluates to FALSE. Does it have something to do with how I pass request value as an argument to doSubmit?

Coding Duchess
  • 6,445
  • 20
  • 113
  • 209
  • 1
    Instead of having javascript on every row of your report, you could take a different approach and use "data-id" and a class. That way the html in your report is a lot cleaner and the code is nicely declared in dynamic actions. I answered a similar question [here](https://stackoverflow.com/questions/73858502/oracle-apex-pl-sql-dynamic-content-inserting-id-of-clicked-item-to-table/73864592#73864592). Let me know if that answer is unclear I can put together another one if needed – Koen Lostrie Jan 25 '23 at 15:18
  • @koenLostrie - I really liked the example code you linked to, though not sure I'll ever need it. Either way, thanks very much. – StewS2 Jan 25 '23 at 16:47
  • @StewS2 thanks ! I'm not the original author of that technique, it was shown by Dan McGhan in a video - he's the smart one ;) – Koen Lostrie Jan 26 '23 at 07:37

2 Answers2

1

Here is a possible solution (on emp table) using css to for rendering and dynamic actions to set the value and submit the page. Functionality is that for all employees except manager a button is rendered (change it to a link if you want, but since it doesn't really link but submit maybe a button is more appropriate). For the manager some text is rendered in a span.

  • Create IG on emp table
  • Use following source query:
select EMPNO,
       ENAME,
       JOB,
       MGR,
       HIREDATE,
       SAL,
       COMM,
       DEPTNO,
       CASE WHEN MGR IS NULL THEN 'none' ELSE 'block' END AS DISPLAY_BUTTON,
       CASE WHEN MGR IS NULL THEN 'block' ELSE 'none' END AS DISPLAY_TEXT
  from EMP

Set columns DISPLAY_TEXT and DISPLAY_BUTTON as hidden

  • Add an additional column "Button" of type "HTML Expression" with Settings > HTML Expression:
<button style="display:&DISPLAY_BUTTON!ATTR." type="button" data-ename="&ENAME!ATTR." class="my-button-js t-Button t-Button--tiny t-Button--success">My Button</button>
<span style="display:&DISPLAY_TEXT!ATTR.">&ENAME!HTML.</span>

Info: this is the markup for a button and a span. Based on the value of the DISPLAY_BUTTON and DISPLAY_COLUMN columns only button or span will be shown. There is a class my-button-js to serve as jQuery selector and the data-ename is the dataset property containing the data for the row.

  • Create a page item P132_ENAME to hold the value being set on click of button.

  • Create a dynamic action on click

    • Event scope: Dynamic (needed to handle pagination or refresh of report)
    • Selection Type: jQuery Selector
    • jQuery Selector: .my-button-js
  • Action 1: Set Value

    • Set Type: Javascript Expression
    • Javascript Expression: this.triggeringElement.dataset['ename']
    • Selection Type "Item(s)"
    • Item(s): P132_ENAME
  • Action 2: Submit Page

    • Request/Button Name: REQUEST1
Koen Lostrie
  • 14,938
  • 2
  • 13
  • 19
  • this.triggeringElement.dataset['column-name'] comes up as undefined – Coding Duchess Jan 30 '23 at 19:46
  • I used – Coding Duchess Jan 30 '23 at 19:46
  • Hard to debug with this little info. I suggest you create this solution on the emp table (exactly) as I showed in order to familiarize yourself with it and then apply to your app. Feel free to have a look on apex.oracle.com, workspace SO_HELP, username/pwd SO_75235469/SO_75235469, app 22384, page 13 – Koen Lostrie Jan 31 '23 at 07:12
0

I cannot use regular Link column as not every row will have it so I have to generate it using HTML in my select statement.

Couldn't you leave the link value empty in that case?

I added this new column to my query:

CASE IS_ACTIVE
    WHEN 'Y' THEN PROPERTY_NAME
    ELSE NULL
    END AS active_link,

Then I defined the link for my new active_link column with:

  • Type URL
  • URL: mailto:&ACTIVE_LINK.

Apex figured out that when my active_link column is NULL, don't show a link.

That seems a lot simpler than the alternatives above.

StewS2
  • 401
  • 4
  • 10