Automate

 View Only
  • 1.  Javascript to add dynamically add rows to Repeating Content Table

    Posted 28 days ago

    I am looking for a method to dynamically add additional rows to a repeating table.

    The following works to add to the first line: if (org == '1000' && ctry == 'CA') it sets the value of GST

    How do I added a second line: if(org == '1000' && ctry == 'CA' && reg=='QC') to set the value of QST

    function canadaTax() {
        debugger;
        var ctry = $form.getValue('/my:myFields/my:Country');
        var reg = $form.getValue('/my:myFields/my:Region');

        var org = $form.getValue('/my:myFields/my:Sales_Organization');
        var gst = "GST";
        var qst = "QST";
        if (org == '1000' && ctry == 'CA') {
            var rowNumber = count('/my:myFields/my:LineItems1/my:Repeating_Content/my:Text_Line_3','[^\\s]');
            var xPath = '/my:myFields/my:LineItems1/my:Repeating_Content['+(rowNumber)+']/my:Text_Line_3';
            $form.setValue(xPath, gst);
            }
    }

    Thanks,

    Puff



    ------------------------------
    Kurt Marshman
    Old World Industries, LLC
    ------------------------------


  • 2.  RE: Javascript to add dynamically add rows to Repeating Content Table

    Posted 28 days ago

    hi,

    I am using:

    $form.addNewRow('/my:myFields/my:Repeating_Table_conditions');

    around this you can have IF statements etc.

    always be aware that first row in a rep.tab. is row 0

    Hope this helps.



    ------------------------------
    Ed Meiners
    Lead Consultant MDIM
    Wessanen Nederland Holding BV
    Amsterdam
    ------------------------------



  • 3.  RE: Javascript to add dynamically add rows to Repeating Content Table

    Posted 27 days ago

    Hi Ed,

    I appreciate the response back.

    I create 2 separate functions just to see if I could them working. Neither work. The first should not need to add a row since it is zero and the second function couldn't exist without the first one being true.

    I get the following error:

    SyntaxError: '[data-link*='my_myFields.my_TRN_SP_SAVE_TEXT_ZINV.my_TRN_SP_SAVE_TEXT_ZINV_Input.my_LineItems1']:first' is not a valid selector.

    I would appreciate any thoughts.

    Thanks,

    Puff

     

    function canadaTaxGST() {
    debugger;
    var org = $form.getValue('/my:myFields/my:TR_BP_G_C/my:TR_BP_G_C_Input/my:Organization');
    var ctry = $form.getValue('/my:myFields/my:TR_BP_G_C/my:TR_BP_G_C_Input/my:Country');
    var countRelrows = count('/my:myFields/my:TRN_SP_SAVE_TEXT_ZINV/my:TRN_SP_SAVE_TEXT_ZINV_Input/my:LineItems1/my:Repeating_Content/my:Text_Line_3','[^\\s]');
    var gst = "GST";
    if (org == '1030' && ctry == 'CA') {
        if(countRelrows > 0)
        {
            $form.addNewRow('/my:myFields/my:TRN_SP_SAVE_TEXT_ZINV/my:TRN_SP_SAVE_TEXT_ZINV_Input');
        }
        $form.setValue('/my:myFields/my:TRN_SP_SAVE_TEXT_ZINV/my:TRN_SP_SAVE_TEXT_ZINV_Input/my:LineItems1/my:Repeating_Content[' + countRelrows + ']/my:Text_Line_3', gst);
    }
    }
     
    function canadaTaxQST() {
    debugger;
    var org = $form.getValue('/my:myFields/my:TR_BP_G_C/my:TR_BP_G_C_Input/my:Organization');
    var ctry = $form.getValue('/my:myFields/my:TR_BP_G_C/my:TR_BP_G_C_Input/my:Country');
    var reg = $form.getValue('/my:myFields/my:TR_BP_G_C/my:TR_BP_G_C_Input/my:Region');
    var countRelrows = count('/my:myFields/my:TRN_SP_SAVE_TEXT_ZINV/my:TRN_SP_SAVE_TEXT_ZINV_Input/my:LineItems1/my:Repeating_Content/my:Text_Line_3','[^\\s]');
    var qst = "QST";
    if (org == '1030' && ctry == 'CA' && reg == 'QC') {
        if(countRelrows > 0)
        {
            $form.addNewRow('/my:myFields/my:TRN_SP_SAVE_TEXT_ZINV/my:TRN_SP_SAVE_TEXT_ZINV_Input');
        }
        $form.setValue('/my:myFields/my:TRN_SP_SAVE_TEXT_ZINV/my:TRN_SP_SAVE_TEXT_ZINV_Input/my:LineItems1/my:Repeating_Content[' + countRelrows + ']/my:Text_Line_3', qst);
    }
    }


    ------------------------------
    Kurt Marshman
    Old World Industries, LLC
    ------------------------------



  • 4.  RE: Javascript to add dynamically add rows to Repeating Content Table

    Employee
    Posted 27 days ago

    Hi Kurt,

    Javascript shared looks fine to me syntax wise, is it possible if you can replicate this in a smaller version and share the solution using link:
    NowTransfer.de
    i can have a look to see if there is something missing.

    Regards



    ------------------------------
    Hammad Naeem
    *Precisely Software Inc.
    ------------------------------



  • 5.  RE: Javascript to add dynamically add rows to Repeating Content Table

    Posted 26 days ago

    Hammad,

    I can not replicate the issue. I created an example and it works as expected.

    image
    image
    image


    ------------------------------
    Kurt Marshman
    Old World Industries, LLC
    ------------------------------



  • 6.  RE: Javascript to add dynamically add rows to Repeating Content Table

    Employee
    Posted 26 days ago

    Hi Kurt,

    there must be something else blocking this in your main solution, if possible, can you share a copy of the original solution or may be raise a support ticket so that we can have a closer look at it.

    Regards



    ------------------------------
    Hammad Naeem
    *Precisely Software Inc.
    ------------------------------