This discussion is archived
13 Replies Latest reply: Nov 12, 2013 10:11 AM by Nicolette RSS

On change Dynmaic action on Tabular field- Problem with Set Value Action

Madonna Newbie
Currently Being Moderated

Dear All,

          I have created a dynamic action for an on change event on a tabular form field using class and jquery and the affected filed of the tabular form is again selected using class and jquery .
         It works well when I have static assignment which I just did for checking if my dynamic action works but my actual requirement is to set the value using SQL statement, and in the where condition I need to give the value of the first field which has the class="this".


When

:Change

:jQuery Selector
:.this


True Actions

Action:Set Value

Set Type: SQL Statement

SQL Statement:

                              Select PRIMARY_UNIT_OF_MEASURE

                              from MTL_system_items_b

                              where   inventory_item_id = (.this)???


Affected Elements

:jQuery Selector

:.myClass


I need to know how do I refer my tabular filed in the select query?


Thanks and Regards,

Madonna

  • 1. Re: On change Dynmaic action on Tabular field- Problem with Set Value Action
    vincent_deelen Pro
    Currently Being Moderated

    Hi Madonna,

     

    You can not combine jQuery/javascript and SQL in one statement (unless you are doing an AJAX call). I'd suggest you create a javascript dynamic action that sets a hidden page item with yuor ".this" value and an other dynamic action for your SQL statement.

    Second of, I strongly advice against the use of "this" as a class name. "this" is used by javascript to identify the object that invokes an event, Using it as aclass definition is confusing and might result in unexpected behaviour.

     

    Regards,

    Vincent

  • 2. Re: On change Dynmaic action on Tabular field- Problem with Set Value Action
    Madonna Newbie
    Currently Being Moderated

    Hi Vincent,

     

              Thank you , that was helpful!! and I will change my class name for the tabular form field.

    Do I write  javascript in the Set Value action to assign the value from the tabular form field to the hidden item?

     

    Thanks and Regards,

    Madonna

  • 3. Re: On change Dynmaic action on Tabular field- Problem with Set Value Action
    Nicolette Expert
    Currently Being Moderated

    Madonna

     

    Please read this thread detail tabular form.

    Newby_egy is trying to a similar thing with setting the price after choosing a test in a tabular form.

     

    Nicolette

  • 4. Re: On change Dynmaic action on Tabular field- Problem with Set Value Action
    Madonna Newbie
    Currently Being Moderated

    Hi Nicolette

     

    That thread was helpful, but have some doubts in some places like "On demand Process"  and in dynamic actions.

     

    Actually i have a tabular form where all the fields are refered from the DB Table. Select List field (f08) and text field (f09). I want to populate the text field when i select a value for select list.

     

    1     I have added the column formatting for text field (Column Name = 'ARR_CITY') in Report Attributes  as 

    <span id="PRICE_#ROWNUM#" name="ARR_CITY"></span>

     

    2     Created a dynamic actions

    name - get price

    Event = Chnage

    Selection Type -  jQuery Selector

    jQuery Selector - (name="f08")

    Action - Execute Jave Script code

     

    Code:

    VAR row, PRICEELEMENT, TESTELEMENT,PRICE,GETPRICEAJAX,PRICE;  

    TESTELEMENT = APEX.JQUERY('#'+THIS.TRIGGERINGELEMENT.id);  

    row = testElement.closest('tr'); 

    PRICEELEMENT = row.FIND('[name="PRICE"]');  

    getPriceAJAX  = new htmldb_Get(null,$v('pFlowId'),'APPLICATION_PROCESS=get price',$v('pFlowStepId')); 

    GETPRICEAJAX.ADDPARAM('x01',$V(THIS.TRIGGERINGELEMENT.id));  

    PRICE = GETPRICEAJAX.GET(); 

    priceElement.text(price);

     

    Affected Element - No value

     

    Step3

    Added a ajax callback process

     

    declare

      cursor c_test(b_test_no in varchar2) 

      is 

        select ARR_CITY

        from   XXBCT_TRV_REQ_DET

        where  ARR_COUNTRY = B_TEST_NO    ; 

      V_TEST_NO varchar2(50);  

      V_PRICE   varchar2(50);  

    begin 

    v_test_no := (apex_application.g_x01); 

    open c_test(v_test_no);  

    fetch c_test  

    into  v_price;  

    close c_test; 

    SYS.HTP.PRN(TO_CHAR(V_PRICE,'L999G990D00')); 

    end;

     

    Kindly verify the above mentioned steps to get it work.. As of now nothing is firing..

  • 5. Re: On change Dynmaic action on Tabular field- Problem with Set Value Action
    Nicolette Expert
    Currently Being Moderated

    Madonna

     

    Just a quick reaction.

    In a case like this were essential asking us to help you debug the application. It would be extremely helpful to have access to your application.

    I would goes a as far as to say that with out that access any real help would be impossible.

    So please set up an example on apex.oracle.com.

    Madonna wrote:

     

    1     I have added the column formatting for text field (Column Name = 'ARR_CITY') in Report Attributes  as

    <span id="PRICE_#ROWNUM#" name="ARR_CITY"></span>

    This is only nessecary for a derived column. Since your are setting the value to a text field that text field already has a name and id attribute.

    Selection Type -  jQuery Selector

    jQuery Selector - (name="f08")

    The selector should be [name="f08"]. Use either an alert action or alert messages in the javascript code to see if the dynamic action is firing, to check if the selector is correct.

     

    Nicolette

  • 6. Re: On change Dynmaic action on Tabular field- Problem with Set Value Action
    Madonna Newbie
    Currently Being Moderated

    Hi Nicolette,

     

    You can access the below mentioned application in apex.oracle.com

     

    Workspace: bct_apex_demo

    User Name: CHINTHAMANIK@BAHWANCYBERTEK.COM

    Password: bct1bnco#

     

    Application ID: 26236

     

    Page: 3

     

    Dynamic action itself is not firing. You can refer any columns. I just want to display the value when i select a value in one field in tabular form.

  • 7. Re: On change Dynmaic action on Tabular field- Problem with Set Value Action
    Madonna Newbie
    Currently Being Moderated

    Hi Nicolette,

     

    Dynamic action written for testing the selector is firing now. Give me some idea on ondemand plsql process and javesript code in dynamic action.

  • 8. Re: On change Dynmaic action on Tabular field- Problem with Set Value Action
    Madonna Newbie
    Currently Being Moderated

    Hi Vincent ,

     

                   Like you said I created a dynamic action to the set the value of the a hiddent item from a  tabular field.

    The dynamic action triggers on Page Load

    I used the below javascript to set the value and it works well.

     

    $(".myClass").change(function(){

     

      $("#P36_GET_ITEM_ID").attr("value",$(".myClass").val());

     

    });

     

    but when I try to create the second dynamic action on Change of this hidden item to set the value of the next tabular field based on the value of the hidden item using a SQL statement, that doesn't work.

    What could be wrong?

     

    Thanks and regards,

    Madonna

  • 9. Re: On change Dynmaic action on Tabular field- Problem with Set Value Action
    Nicolette Expert
    Currently Being Moderated

    Madonna

     

    Javascript is case sensitive. This means that VAR != var and apex.jQuery != APEX.JQUERY.

    If your check your browsers developer tools you will notice that the code first gives an error on the line VAR row etc.

    That is because it doesn't know the statement VAR. This should be var.

    After correcting that it gives an error of not knowing the function APEX.JQUERY. and that should be apex,jQuery.

     

    Nicolette

  • 10. Re: On change Dynmaic action on Tabular field- Problem with Set Value Action
    Madonna Newbie
    Currently Being Moderated

    Nicolette,

     

    I have changed according to your points

     

    Please check the javascript code

     

    var row, PRICEELEMENT, TESTELEMENT,PRICE,GETPRICEAJAX,PRICE; 

    TESTELEMENT = apex,jQuery('#'+THIS.TRIGGERINGELEMENT.id); 

    row = testElement.closest('tr');

    PRICEELEMENT = row.FIND('[name="f09"]'); 

    getPriceAJAX = new htmldb_Get(null,$v('pFlowId'),'APPLICATION_PROCESS=get price',$v('pFlowStepId'));

    GETPRICEAJAX.ADDPARAM('x01',$V(THIS.TRIGGERINGELEMENT.id)); 

    PRICE = GETPRICEAJAX.GET();

    priceElement.text(price);

     

    Ajax callback process

     

    declare

      cursor c_test(b_test_no in varchar2) 

      is 

        select ARR_CITY

        from   XXBCT_TRV_REQ_DET

        where  ARR_COUNTRY = B_TEST_NO  

    and rownum = 1 ; 

      V_TEST_NO varchar2(50);  

      V_PRICE   varchar2(50);  

    begin 

    v_test_no := (apex_application.g_x01); 

    open c_test(v_test_no);  

    fetch c_test  

    into  v_price;  

    close c_test; 

    SYS.HTP.PRN(TO_CHAR(V_PRICE,'L999G990D00')); 

    end;

     

    Still it is not working.

  • 11. Re: On change Dynmaic action on Tabular field- Problem with Set Value Action
    Nicolette Expert
    Currently Being Moderated

    Madonna

     

    And as I said javascript is case sensitive. So since you felt the need to change the naming of objects, variables and functions to all uppercase.

    I will leave it up to you to either change all instances of an object to either the new or old name.

     

    Just compare your code and the code I pointed you to.

    And start using your browsers developer tools to debug javascript.

     

    Nicolette

  • 12. Re: On change Dynmaic action on Tabular field- Problem with Set Value Action
    Madonna Newbie
    Currently Being Moderated

    Hi,

     

    I have reached the destination where i can return the value from plsql process and able to get it inside the javascript code. Now in the final step.

    You told to use .val() for an input element, so i used priceElement.val(price) but it is not returning the value in a field.

     

    Since am a beginner for this jQuery and JavaScript, i am not able to get the proper code to make it.

  • 13. Re: On change Dynmaic action on Tabular field- Problem with Set Value Action
    Nicolette Expert
    Currently Being Moderated

    Madonna

     

    I have just tried your application and it is working.

    When I'm selecting "testing" of "sdfas" for Arr Country then a value is set in Arr City.

    Now why there isn't a Arr City for the other cities I don't know.

    But it is probably because there isn't an Arr city entered for that Arr Country.

     

    Nicolette