Monday, August 15, 2016

Apex report: Conditionally showing the link url

Apex report: Conditionally showing the link url

Sometime in the report/form combination, we will need to show/hide the linked url based on value of another col of the report, for example, in following report:

select empno,ename,job from emp;

There is a link on the empno col, (the link will point to the EMP detail form). What I would like to do is to only enable the link if the person's job title is 'Manager', otherwise hide the link.

Here is how to do it:

1. Modify the report sql to:
     select empno,ename,job,decode(job,'Manager','Y','N') flag from emp;
2.  in the report page(inline css section), put this in:
     .N { display: none; }
3. in the linked attribute of the report linked col, put this in
    class="#flag#"

That't IT!

In case you are not happen with the default edit icon, you can replace with a dynamic action on the report page:

create a dynamic action(after refresh), run javascripts:

$(".Y").removeClass("Y").addClass("fa fa-user-plus fa-2x")

In this case, I am replacing the default edit link icon with an font awesome icon

Tuesday, August 9, 2016

Apex Tabular Form -- disable one column based on value of another column

Apex Tabular Form -- disable one column based on value of another column


I have a Tabular Form, one col is an LOV(Phone MMS provider), another col is a text field, I would like to disable that text column if user doesn't choose "Other" in the LOV, otherwise make it enterable. 

Here is how to do it:

1. create a dynamic action:
    Event: Change on JQuery selector:  select[name='f08'] --- here f08 is the LOV field
    execute javascripts:
      var lov = this.triggeringElement.id;
      var row = lov.split("_")[1];
      if ($lov(el)  == "Other") {
      // disable the field 
       //       $x_disableItem("f09_" + row, false);  --- change this to below line, because I got no data found issue with this line after I added more than 16 rows in the tabular table, not sure the reason but changed it to below fixed the issue
              $( "#f09_" + row ).prop( 'readOnly', false);
      }
      else {
     // enable the field
     //        $x_disableItem("f09_" + row, true); ---- Change this to below line
             $( "#f09_" + row ).prop( 'readOnly', true);
      };

 --- f09 is the text field in the tabular form
2. copy the dynamic action, change the event to "Page Load"