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

Question

Question

Retrieve data from Collection Field into a Table Field

asked on August 9, 2019

Hi,

I have two forms. The first form is for collecting data. The second form is for presenting summary level of the same data.

In the first form, I use Collection field to capture complex attributes of the data I am collecting from users. The user will add data as required, there is no limits specified as to the number of data that can be added into the Collection field.

In the second form, I want to create a Table field that captures all the data entered by the user along with select attributes (not all of them) and then summarizes them in the Table field.

Is there a way to achieve this? Preferably without JavaScript.. Thanks for your help.

0 0

Replies

replied on August 9, 2019

Wissam, the best way I have found to do what you are suggesting is to call a Workflow that updates a SQL table with the content from your collection.  Then you can call on the same table from the second form to evaluate and summarize your collection data in a new table.

Question, have you thought of using the summary option in Forms reporting to provide the same summary information to your users without needing to create the second form?

1 0
replied on August 9, 2019

HI Michelle - Thanks for your quick response.

Yes I thought about utilizing the reporting feature; however, I understand that I can only utilize it to present data in a reporting format, but I cannot run an approval workflow on it. Correct me if I am wrong.

I am trying to present select data and then have it approved by designated authority in the organization. I thought about achieving this requirement by creating the form that contains the data within the business process and then add an approval task.

I will try your suggestion and let you know if it works. Meanwhile, I welcome all suggestions. Thanks for your help.

0 0
replied on August 9, 2019

If the 2 forms are part of the same forms process, you can use a workflow to manipulate the data directly and prepare the resulting report data on the second form, which is then assigned for approval. No need for a seperate SQL database.

Just use the 2 activities in workflow, Retrieve Business Process Data to get the input and Assign Business Process Data to populate the table and make sure to wait for the workflow to finish before assigning the user task.

0 0
replied on August 9, 2019

Chad is right, if you don't want to use JavaScript, then your best bet is to just call a workflow that grabs the collection and uses those fields to populate the table columns.

It should really only need the Retrieve/Set Business Process Variables activities Chad listed.

0 0
replied on August 16, 2019 Show version history

Hi - Thanks for the feedback. I created the workflow and used a workflow service task to call it. However, the approval form is not capturing any data from the other form. 

I troubleshooted the issue but I am not sure about the cause of it. I have three questions:

  1. For the Workflow Service Task to trigger the Workflow I created, do I have to create a script or specify anything? 
  2. The previous step in the Business Process is Save to Repository Task. The task works fine and saves the content into Laserfiche Client. Could this impact the Workflow Service Task?
  3. The data that should be captured in the approval form set in Collection component which contains drop menus, bullet fields and check boxes. The Workflow does not see any data in them. I have values specified for every option/choice, but it does not see them. Is there something I am missing that should be done?

So far your feedback has been very helpful. Thanks for your time.

0 0
replied on August 16, 2019

I'm not sure exactly what you mean that the approval form is not capturing data from the other form.

Is the workflow running at all? Do you have the Retrieve Business Process Variables and the Set Business Process Variables activities?

In the retrieve business process variables activity, are you seeing the list of forms and variables?

0 0
replied on August 16, 2019

Hi Jason - Yes I did exactly that. Here is a brief about the workflow:

  1. Start 
  2. Retrieve Business Process Variable activity >
    • Selected all variables that I want to process
  3. For Each activity>
    • Added: Retrieve Business Process Variable activity for variables within Collection fields
    • I created 4 similar steps for each collection field I have
  4. Set Business Process Variable activity >
    • Selected all variables that I will use
    • Assigned each selected variable to the data coming from the initial form by using Capture statement example: AS_Project_Name=%(CaptureInformationClassificationResults_RI_Project_Name)
  5. For Each activity >
    • Added: Set Business Process Variable activity for values that will be assigned to variables within Collection fields.
    • I created 4 similar steps for each Collection field I have
    • I utilized the Capture statements to assign values to the right variable. example: example: AS_Project_Name=%(CaptureInformationClassificationResults_RI_Project_Name)
  6. End

 

  • Validated the workflow. There is no errors or warnings.
  • Published it without any issue.
  • Created Workflow Service Task in the Business Process
    • Entered the workflow name in the designated field
    • Clicked on "Wait for the workflow to finish before proceeding"
    • Outflow is set and selected to be the default path
  • Created Approval task
  • Created Save to Repository Task

 

When I check the workflow results in the Workflow Designer, i get error that mentions the workflow did not get any results.

0 0
replied on August 16, 2019

You cannot do Set Business Process Variables in a loop. If you do that, it will just overwrite the previous values each time it runs the activity.

You need to have all of your values in multi value tokens, and assign to the appropriate values all at the same time in a single Set Business Process Variables activity.

 

When you say the workflow "didn't get any results" which activity was giving that error?

Can you provide a screen shot of the workflow? You should only have 1 Retrieve Business Process Variables activity, and 1 Set Business Process Variables activity, and neither should be inside of a loop.

1 0
replied on June 12, 2020

Hi Jason, 

We are doing something similar.

We have 8 text fields coming from different parts of the form.

If data is entered into the field we want it listed in a table column.

How do you write the javascript to get a text field entry into a table column/row?

For example:

0 0
replied on June 12, 2020

The JavaScript would really depend on how your table and fields are set up.

If you need a dynamic number of rows, then that gets much more complicated because if the number of rows isn't fixed you'd need to add/remove rows based on how many values you have.

In general, I'd say the first step is to give the same custom CSS class to all of your "source" fields so you can grab them all at once.

From there, you could iterate through all the values in a loop and add them to the table using the index of the loop to target the row.

Something like

$(document).ready(function(){
  // update table column when source values change
  $('.sourceField input').on('change',function(){
    updateRows();
  });
});

function updateRows(){
  var rows = [];
  
  // iterate through each source field
  $('.sourceField input').each(function(index){
    // get non-blank values
    if($(this).val() !== '') rows.push($(this).val());
  });
  
  // reset table rows
  $('.myTable .cf-table-delete').click();
  
  // iterate through actual values
  for(var i = 0; i < rows.length; i++){
    // add table row
    $('.myTable .cf-table-add-row').click();
    
    // update value for corresponding row
    $('.myTable .targetField input').eq(i).val(rows[i]).change();
  }
}

Note that this is only an example to demonstrate some of the various functions you might use and it might not behave perfectly.

1 0
replied on June 12, 2020

Thank you, Jason!

Will give this a try and let you know if it works out. Appreciate your help!

0 0
replied on June 12, 2020

Hi Jason,

It worked perfectly! 

Thank you again!

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

Sign in to reply to this post.