You are viewing limited content. For full access, please sign in.

Question

Question

Create new table from existing table

asked on September 21, 2018

Hey Everyone!

Hope someone with some awesome Javascripting skills can help me out.  I have an Education Reimbursement Process and it is made of two forms.  A pre-authorization for reimbursement form and a Post-Class Completion form.

  Basically an employee will fill out a table saying which classes they are taking and any costs and get this pre-approved.  When the class end date passes, I want the post completion form to be assigned.  I would like to take the class table from the pre-auth from and have it read only on the post class completion form and have a new table which will list the classes that the employee is requesting reimbursement for.  This way, management can see what was pre-approved and what the current reimbursement is for.  I cannot for the life of me find a way to copy the information from the pre-approved table to show up in the post completion table so the employee doesn't have to retype everything.  Hope this makes sense!

 

 

Drew 

0 0

Answer

SELECTED ANSWER
replied on September 21, 2018 Show version history

The functions and JavaScript I added below are already dynamic. The JavaScript pulls the number of rows for the current form, not a static value, and the Functions use built-in indexing to pull data from corresponding rows.

For example, if User A loads a form with 3 rows, it will put 3 rows in the duplicate table.

If User B loads a form with 10 rows, it will put 10 rows in the duplicate table.

0 0

Replies

replied on September 21, 2018

To copy the values, you could just use Functions. For example, if you put the following function in for the first column of your second table (replacing the table variables with yours of course).

=INDEX(Table1.Column1,ROW())

It will automatically copy the value from the corresponding row of Table 1.

The only catch there is that everything has to stay in the same order because they are copied row-to-row (row 1 to row 1, row 2 to row 2, etc.).

If you wanted to get fancy, you could add a field in the second table and use that value instead of the ROW() function so they could change the order.

For example,

=IF(INDEX(Table2.Row,ROW())>0,
INDEX(Table1.Column1,INDEX(Table2.Row,ROW())),"")

Where Table2.Row references the value of the "row" column on your duplicate table.

If you just want to copy the entire table, then use the first formula, add a CSS class to your first table called "originalTable" and a class to your second table called "duplicateTable" then add the following JavaScript.

$(document).ready(function(){
  var r1 = $('.originalTable .propCount').val();
  
  while($('.duplicateTable .propCount').val() < r1){
    $('.duplicateTable .cf-table-add-row').click();
  };
});

Forms tables have a hidden input element with a class of "propCount" that stores the number of rows; this function will run a loop and add rows to the duplicate table until the row counts match.

3 0
replied on September 26, 2018

Hey Jason,

I apologize for the delay but what you listed here worked like a charm!  Thanks so much for helping me out

 

Drew

0 0
replied on November 29, 2019

Awesome, Jason!  This worked for me, too!!!

0 0
replied on September 21, 2018 Show version history

Another way to look at this would be to save the Pre-Authorization form into the repository and collect the table as metadata.  Once the class has completed, you could run a business process on the saved form and populate the new form with your previously saved metadata values.

2 0
replied on September 21, 2018

That's a pretty good idea. Technically, you don't even need to store the table as metadata since it seems to be part of the same business process. You could just pull the table in Workflow then use it to update the duplicate table before assigning the new task.

0 0
replied on September 21, 2018

Hey Jason, thanks for the help!  With the tables however, the number of rows can vary person to person and I don't necessarily want a fixed number of rows.  Any hints that you might have for this? 

0 0
SELECTED ANSWER
replied on September 21, 2018 Show version history

The functions and JavaScript I added below are already dynamic. The JavaScript pulls the number of rows for the current form, not a static value, and the Functions use built-in indexing to pull data from corresponding rows.

For example, if User A loads a form with 3 rows, it will put 3 rows in the duplicate table.

If User B loads a form with 10 rows, it will put 10 rows in the duplicate table.

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.