Questions and discussion about using ProcessMaker 2: user interface, running cases and functionality
Forum rules: Please search to see if a question has already been asked before posting. Please don't ask the same question in multiple forums.
By Bosatzu
#785077
Hello everyone


I'm trying to add some information inside a grid, but i'm having problems with the second and ahead row to add with the function getObject("GRL_M_GENERAL_LAB").addGridRow();


The JS that i'm using is:
Code: Select all
getField('BTN_AGREGAR').onclick = function() {
  
  if(getField('TXT_DESC_LAB').value == '' && getField('TXT_COD_LAB').value == ''){
    return false;
  }
  else{    
    if(getField('TXT_DESC_LAB').value != '' && getField('TXT_COD_LAB').value == ''){
      var codigo = getField('TXT_DESC_LAB').value;
      var descripcion = getField('TXT_DESC_LAB_label').value;
      getField('TXT_DESC_LAB').value = '';
      getField('TXT_DESC_LAB_label').value = '';
    }
    if(getField('TXT_DESC_LAB').value == '' && getField('TXT_COD_LAB').value != ''){
      var descripcion = getField('TXT_COD_LAB').value;
      var codigo = getField('TXT_COD_LAB_label').value;
      getField('TXT_COD_LAB').value = '';
      getField('TXT_COD_LAB_label').value = '';
    }    
  }  

  var nRows = Number_Rows_Grid("GRL_M_GENERAL_LAB", "TXT_COD_LAB");
  
  for (var i = 1; i <= nRows; i++) {
      if (getGridField("GRL_M_GENERAL_LAB",i,"TXT_COD_LAB").value == codigo){
              alert('Este exámen de laboratorio ya esta agregado.');
              return false;
      }
  }
          
  if(Number_Rows_Grid("GRL_M_GENERAL_LAB","TXT_COD_LAB") == 1 && getGridField("GRL_M_GENERAL_LAB",1,"TXT_COD_LAB").value == ''){    
    getGridField("GRL_M_GENERAL_LAB",1,"TXT_COD_LAB").value = codigo;
    getGridField("GRL_M_GENERAL_LAB",1,"TXT_DESC_LAB").value = descripcion;
  }
  else{
    getObject("GRL_M_GENERAL_LAB").addGridRow();
    var n = Number_Rows_Grid("GRL_M_GENERAL_LAB","TXT_COD_LAB");    
    getGridField("GRL_M_GENERAL_LAB",n,"TXT_COD_LAB").value = codigo;
    getGridField("GRL_M_GENERAL_LAB",n,"TXT_DESC_LAB").value = descripcion;
  }  
  return false;
}

And the XML form is:
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<dynaForm name="67820499156b3c88b90f790066162440/82807150256ec32811d5483038671822" type="xmlform" width="900" mode="" nextstepsave="prompt" printdynaform="" adjustgridswidth="1" enabletemplate="1">
  <TIT_PRINCIPAL type="title" required="0" readonly="0" optgroup="0">
    <es>HEALTH - EXÁMENES DE LABORATORIO</es>
  </TIT_PRINCIPAL>
  <SUB_BUSQUEDA type="subtitle" required="0" readonly="0" optgroup="0">
    <es>BÚSQUEDA DE EXÁMENES</es>
  </SUB_BUSQUEDA>
  <TXT_COD_LAB type="suggest" required="0" size="200" mode="edit" sqlconnection="29942763556bbc604c18b24012677227" maxresults="6" searchtype="*searchtype*" table="0" readonly="0" optgroup="0"><![CDATA[select desc_lab ,cod_lab,desc_lab as descripcion from pmt_lab_clinico
    ]]><es>Código</es></TXT_COD_LAB>
  <TXT_DESC_LAB type="suggest" required="0" size="200" mode="edit" sqlconnection="29942763556bbc604c18b24012677227" maxresults="6" shownoresults="1" searchtype="*searchtype*" table="0" readonly="0" optgroup="0"><![CDATA[select cod_lab,desc_lab,cod_lab as codigo from pmt_lab_clinico
    
    
    ]]><es>Descripción</es></TXT_DESC_LAB>
  <BTN_AGREGAR type="button" required="0" readonly="0" optgroup="0">
    <es>Agregar Laboratorio</es>
  </BTN_AGREGAR>
  <GRL_M_GENERAL_LAB type="grid" xmlgrid="67820499156b3c88b90f790066162440/39664920056c3a17aeb7e59006990907" addrow="0" deleterow="1" required="0" readonly="0" optgroup="0"/>
  <arrow type="javascript" meta=""><![CDATA[function arrow(){
  hidden(getField("DYN_BACKWARD").parentNode);
  hidden(getField("DYN_FORWARD").parentNode);
}
arrow();]]></arrow>
  <validar_formulario type="javascript" meta=""><![CDATA[getField('BTN_AGREGAR').onclick = function() {
  
  if(getField('TXT_DESC_LAB').value == '' && getField('TXT_COD_LAB').value == ''){
    return false;
  }
  else{    
    if(getField('TXT_DESC_LAB').value != '' && getField('TXT_COD_LAB').value == ''){
      var codigo = getField('TXT_DESC_LAB').value;
      var descripcion = getField('TXT_DESC_LAB_label').value;
      getField('TXT_DESC_LAB').value = '';
      getField('TXT_DESC_LAB_label').value = '';
    }
    if(getField('TXT_DESC_LAB').value == '' && getField('TXT_COD_LAB').value != ''){
      var descripcion = getField('TXT_COD_LAB').value;
      var codigo = getField('TXT_COD_LAB_label').value;
      getField('TXT_COD_LAB').value = '';
      getField('TXT_COD_LAB_label').value = '';
    }    
  }  

  var nRows = Number_Rows_Grid("GRL_M_GENERAL_LAB", "TXT_COD_LAB");
  
  for (var i = 1; i <= nRows; i++) {
      if (getGridField("GRL_M_GENERAL_LAB",i,"TXT_COD_LAB").value == codigo){
              alert('Este exámen de laboratorio ya esta agregado.');
              return false;
      }
  }
          
  if(Number_Rows_Grid("GRL_M_GENERAL_LAB","TXT_COD_LAB") == 1 && getGridField("GRL_M_GENERAL_LAB",1,"TXT_COD_LAB").value == ''){    
    getGridField("GRL_M_GENERAL_LAB",1,"TXT_COD_LAB").value = codigo;
    getGridField("GRL_M_GENERAL_LAB",1,"TXT_DESC_LAB").value = descripcion;
  }
  else{
    getObject("GRL_M_GENERAL_LAB").addGridRow();
    var n = Number_Rows_Grid("GRL_M_GENERAL_LAB","TXT_COD_LAB");    
    getGridField("GRL_M_GENERAL_LAB",n,"TXT_COD_LAB").value = codigo;
    getGridField("GRL_M_GENERAL_LAB",n,"TXT_DESC_LAB").value = descripcion;
  }  
  return false;
}]]></validar_formulario>
  <BTN_CONTINUAR type="submit" required="0" readonly="0" optgroup="0">
    <es>Continuar</es>
  </BTN_CONTINUAR>
</dynaForm>

I would like that you can help me up, the error that i get is: Uncaught TypeError: Cannot read property 'value' of null
By hiteshsingla
#786502
Hi,

Any luck with this particular problem, as for me also addGridRow() is not working once I import a process built in 2.5.2 to ProcessMaker 3. Is there any backward compatibility for this or any workaround available to make it funciton in ProcessMaker 3 as well?
Thanks in advance!!

💥 Join the Exclusive Trading Community and Experie[…]

Briefly introduce the topic and provide context. S[…]

If you want to know the best technique to export P[…]

Nursing dissertation help topics

Home of Dissertations is the most used platform th[…]