CA Service Management

  • 1.  Get table values

    Posted May 05, 2015 06:10 AM

    Hi all,

     

    I'm trying to print the values inserted in a table (data mode) but without success. I've tried several different ways but I always get "undefined" which let me think that I am printing the wrong value.

     

    Imagine that I have a table named tbl and that I've inserted two values (_id is called row). I can get row count without any problem:

    var rows = ca_fdGetTableRowCount(ca_fd.formId, tbl);

     

    How can I print the value for each row?

     

    Thank you in advance.

     

    Regards,

    Pedro



  • 2.  Re: Get table values

    Posted May 05, 2015 03:37 PM

    If you are using r12.8 or higher you could use ca_fdGetInsertedTableRows.



  • 3.  Re: Get table values

    Posted May 06, 2015 06:46 AM

    Hi Lindsay,

     

    I've figured out what the problem is but I didn't solve it yet. I have several tables with Select components that queries mdb. I want to invoke a function to do some validations in each table so I have to pass table and select as argument:

     

    ca_fd.js.validar('tblRecursos','selNomeRecurso');

     

    validar : function (tbl,sel){

       var teste = ca_fdGetInsertedTableRows(ca_fd.formId, tbl);

       var rows = ca_fdGetTableRowCount(ca_fd.formId, tbl);

       var undefined = 0;

     

    for(var i = 0 ; i < rows ; i++){

            alert("1 - By param "+teste[i].sel+ " - Variable type: "+(typeof sel));

            alert("2 - Force select "+teste[i].selNomeRecurso+ " - Variable type: "+(typeof selNomeRecurso));

       }

    return undefined;

    }

     

    I'm having troube passing a Select as an argument. Alert 1 prints undefined and alerts 2 prints the correct value.

    "sel" typeof is string and that's why code has this behaviour.

    How can I deal with this?

     

    Thank you.

    Pedro



  • 4.  Re: Get table values

    Posted May 06, 2015 07:21 AM

    A picture is worth a 1000 words

    Untitled.png



  • 5.  Re: Get table values

    Posted May 06, 2015 11:00 AM

    Hi Pedro,

     

    I am not sure what you are trying to accomplish. It looks like you are populating the table from a report. Are you then wanting to identify which table rows the user selects?

     

    Regards,

    Lindsay



  • 6.  Re: Get table values

    Posted May 06, 2015 11:08 AM

    Hi Lindsay,

     

    I am populating the table manually with options suggested from a query. For the rows inserted I want to do some validations and that's why I need to call a function with table and select component as arguments.

     

    Regards,

    Pedro



  • 7.  Re: Get table values

    Posted May 06, 2015 12:14 PM

    I had to review my reference on JavaScript to figure this out. This is a JavaScript limitation.

     

    teste[i].selNomeRecurso works because selNomeRecurso is a column in the table

     

    teste[i].sel does not work because sel is not a column in the table

     

    I perceive that you are trying to create a single function to use with any table (by passing the column name to the function) but you will have to create a function for each table.



  • 8.  Re: Get table values

    Posted May 06, 2015 12:22 PM

    A function for each table will generate 10 functions. And, in my opinion, this validation is required because of a bug in Catalog. If the only values available to choose for the rows are the ones outputted by the query users shouldn't be able to add an empty line



  • 9.  Re: Get table values

    Posted May 06, 2015 01:18 PM

    Have you tried setting Required to True on selNomeRecurso?



  • 10.  Re: Get table values

    Posted May 06, 2015 02:13 PM

    Yes and it worked. However this is required only if another option is True. Due to that selNomeRecurso can't be required by default. I control that with a function on onSubmit.