2 Replies Latest reply on Nov 20, 2012 8:08 PM by Merlin128

    JavaScript CloneRow stopped working in Apex 4.2

    Merlin128
      we ran a javascript Clone Row on our Tabular Forms in Apex 4.0
      after upgrading to 4.2 we get

      ERROR:
      Current version of data in database has changed since user initiated update process. current row version identifier = "719C601E3911F88E9AD268A7EF06331F" application row version identifier = "Z"

      column attribute: HTML EXPRESSION:
      <a href="#" onclick="javascript:cloneRow(this)"><img src="#IMAGE_PREFIX#FNDADD11.gif"></a>
      Page Header:
      <script type="text/javascript"> 
      
      function fn_delete(t) 
      { 
        var l_tr=$x_UpTill(t,'TR'); 
        l_tr.parentNode.removeChild(l_tr); 
      } 
      
      function pad(n) 
      { 
       var s = '0000' + n; 
       return s.substr(s.length-4); 
      } 
      
      function updateFields(f) 
      { 
        var fields = document.getElementsByName(f); 
      
        var j; 
        if (fields.length > 0) 
        { 
          for (j = 0; j < fields.length; j++) 
          { 
            fields[j].id = f + "_" + pad(j+1); 
          } 
        } 
      } 
      
      function cloneRow(y) 
      { 
      $(y).parent().parent().clone(true,false).insertAfter($(y).parent().parent()); 
      
              //CREATE NEW ROW 
              newRow = $(y).parent().parent().next(); 
      
              //BLANK N_PK AND ANY OTHER HIDDEN FIELDS 
              newRow.find('[name=f02]').val(''); 
      
              //DONT KNOW WHAT THIS DOES 
              newRow.find('[name=fcs]').val('Z'); 
      
              //REMOVE CHECKBOX SINCE IT WONT WORK ON THE NEW ROW 
              newRow.find('[type=checkbox]').remove();   
            
              //HIGHLIGHT NEW ROW 
              html_RowHighlight($(newRow).get(0),"#9E0200"); 
              
              //CHANGE CLONE ICON TO A DELETE ICON 
              newLink = $(newRow).find('img')[0]; 
              newLink.src = '#IMAGE_PREFIX#FNDERROR.gif'; 
              $(newLink).parent().removeAttr('onclick'); 
              $(newLink).parent().get(0).onclick = function() 
              {fn_delete(this)}; 
      
              //Remove Datepicker 
              if ($(newRow).find('img').length > 0) 
              { 
                    for (dt = 1; dt < $(newRow).find('img').length; dt++) 
                    { 
                    remDate = $(newRow).find('img')[dt]; 
                    remDate.width = '0'; 
                    remDate.hieght = '0'; 
                    } 
              } 
              
              //UPDATE NEW FIELD IDs 
              $(newRow).find('INPUT').each(function(index) 
              { 
              var x = '0' + index; 
              x = x.substr(x.length-2); 
      
              updateFields('f'+x); 
              }); 
      } 
      
      </script>