Automate

 View Only
  • 1.  How can I delete a row from a repeating table?

    Posted 11-13-2023 09:50

    Hello,

    I'm trying to figure out how to delete a row from a repeating table using a Javascript function. I can't find a form function to accomplish this. I have tried $form.deleteRow, $form.removeRow, $form.emptyRow and many others, none seem to work. I have also used $form.setdeleteRow but that only enables the delete option from the row, I want to actually delete the row, not just enable the ability to delete the row. Is there a form function to do this?

    Thank you,



    ------------------------------
    Marc
    marcus.obren

    ------------------------------


  • 2.  RE: How can I delete a row from a repeating table?

    Employee
    Posted 11-14-2023 07:10

    Hi Marcus

    Internally we use Method : removeGroupItem to remove the item, but unfortunately there is no way to call this from a custom javascript code from within the solution.

    The method expects an event, which is provided through the UI. Hence, you won't be able to use it.

    Regards



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



  • 3.  RE: How can I delete a row from a repeating table?

    Posted 11-14-2023 08:47

    Hi Marc,

    We actually use a javascript rule for our material plant extension process. It's 3 fold how we do it. A box needs to be checked, and the rule is on a button. There is also a function the Javascript Code on the "Solutions" tab in composer. Since at times we are deleting multiple rows, within the rule on the button, we also have a function to check if the UI is blocked and if so, repeat the process in 5 seconds. It continues through the table to delete all rows with the "Remove" box checked. I hope this helps at least give you some guidance for how you could make it work for your process. 

    Javascript Code on Solutions Tab

    function deleteRow(xPath, index){
        var binding = Utils.formatBindingFromXPath(xPath);
        binding = Utils.replaceLastIndex(binding, index);
        var rowTag = $j("[data-link='" + binding + "']").parents(".form-block-repeating");
        if (renderer) renderer.removeGroupItem(rowTag);
    }

    Check Box we call "Remove"

    Rule on the Button 

    jQuery.confirm('Are you sure you wish to remove the selected plants? If changes are necessary, click NO. If no changes are necessary, click Yes and the selected rows will be removed.','Inputs Complete', 
    function() {
        for (var i = 0; i < count('/my:myFields/my:BAPI_MATERIAL_PLANT_EXTEND_XML_RULES/my:BAPI_MATERIAL_PLANT_EXTEND_XML_RULES_Input/my:Repeating_Content/my:BP_DeletePERow'); i++){
        if($form.getValue('/my:myFields/my:BAPI_MATERIAL_PLANT_EXTEND_XML_RULES/my:BAPI_MATERIAL_PLANT_EXTEND_XML_RULES_Input/my:Repeating_Content['+i+']/my:BP_DeletePERow')=== 'true' || $form.getValue('/my:myFields/my:BAPI_MATERIAL_PLANT_EXTEND_XML_RULES/my:BAPI_MATERIAL_PLANT_EXTEND_XML_RULES_Input/my:Repeating_Content['+i+']/my:BP_DeletePERow')=== true){
        deleteRow('/my:myFields/my:BAPI_MATERIAL_PLANT_EXTEND_XML_RULES/my:BAPI_MATERIAL_PLANT_EXTEND_XML_RULES_Input/my:Repeating_Content/my:BP_DeletePERow', i);
    }
    var tid = setInterval(blockedCode,1000);
    function blockedCode() {
        var isUIBlocked = jQuery('#SVProcessingOverlay').length > 0;

        if (!isUIBlocked){
        for (var i = 0; i < count('/my:myFields/my:BAPI_MATERIAL_SO_EXTEND_XML_RULES/my:BAPI_MATERIAL_SO_EXTEND_XML_RULES_Input/my:Repeating_Content/my:BP_DeleteSORow'); i++){
    if($form.getValue('/my:myFields/my:BAPI_MATERIAL_SO_EXTEND_XML_RULES/my:BAPI_MATERIAL_SO_EXTEND_XML_RULES_Input/my:Repeating_Content['+i+']/my:BP_DeleteSORow')=== 'true' || $form.getValue('/my:myFields/my:BAPI_MATERIAL_SO_EXTEND_XML_RULES/my:BAPI_MATERIAL_SO_EXTEND_XML_RULES_Input/my:Repeating_Content['+i+']/my:BP_DeleteSORow')=== true){
        deleteRow('/my:myFields/my:BAPI_MATERIAL_SO_EXTEND_XML_RULES/my:BAPI_MATERIAL_SO_EXTEND_XML_RULES_Input/my:Repeating_Content/my:BP_DeleteSORow', i);
        break;
    }
            clearInterval(tid);
      }  }
    }}
    });



    ------------------------------
    Vanessa Kutasi
    Foundation Admin./Application Analyst II
    Idexx Operations, Inc.
    USA
    ------------------------------



  • 4.  RE: How can I delete a row from a repeating table?

    Posted 11-16-2023 17:38

    Hi Vanessa,

    I wanted to thank you for sharing the suggestion above. I've been working on trying to get custom Javascript in a form to get rows updated in a repeating table after calling a webservice that wasn't working correctly. Your reference above about the function to check if the UI is blocked helped put me in the right direction and get it working :D

    Thank you!



    ------------------------------
    Shelby Murrell
    SAP Winshuttle Analyst
    Monster Beverage Corp
    WA
    ------------------------------



  • 5.  RE: How can I delete a row from a repeating table?

    Posted 11-17-2023 08:29

    Awesome, I'm glad it has helped :)



    ------------------------------
    Vanessa Kutasi
    Foundation Admin./Application Analyst II
    Idexx Operations, Inc.
    USA
    ------------------------------