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

Question

Question

Create checkbox choices using Invoke Business Process

asked on March 6, 2024

From a workflow, I'm using Invoke Business Process to pass in values to a form.  So far everything I've tried has been straightforward.  I've pre-filled multiple single line fields and even pre-selected checkboxes.  I would like to add choices to a checkbox.  

I've created a small form for testing.  My form has a checkbox with one choice as a placeholder and a single line field to show what was sent from the workflow.  The whole form looks like this...

 

 

What I was hoping to be able to do was to create the checkbox choices that looked like this

 

The workflow I created for testing only has two steps in it...

 

I create a token with the choices for the checkbox.

 

Then, I pass those along to populate the form

 

 

 

On the live form, the choices for checkbox that are being passed in will be different for each person that runs the process.  The quantity of choices could be one or a few or many.  

Is this even possible?  

 

0 0

Answer

SELECTED ANSWER
replied on March 6, 2024 Show version history

What you are passing into the variables from Workflow are the selected values, not the displayed labels.

In order to do any changes on the checkbox labels dynamically, you would need to utilize Javascript.  If you want to go that route, I'm happy to provide some guidance on how that could be done, I would just need to know if you are wanting to do this in the Classic Designer or the New Designer.

EDIT TO ADD - Here's the Javascript Code.  In both cases, the checkbox is field q1 and the single line field with the options is field q2, you'll need to update the Javascript accordingly to match your actual fields.

For the Classic Designer.  This requires your checkbox field to have more options that your custom options could be at a maximum.  It's going to update the labels and values on the fly, and hide the unused options. 

$(document).ready(function() {
  
  var checkboxValues = $('#q2 input').val().split(',');
  var checkboxCounter = 0; 
  $('#q1 .choice label').each(function() { 
    $(this).text(checkboxValues[checkboxCounter]);
    $(this).parent().find('input').attr('value', (checkboxValues[checkboxCounter]).replace(/ /g,"_"));
    if(checkboxValues[checkboxCounter] == undefined) { 
      $(this).parent().hide(); 
    }
    checkboxCounter++;
  });
  
});

 

 

For the New Designer (this requires Forms 11 Update 5 - which is 11.0.2311 - or newer).  In this case, it doesn't matter how many options your checkbox has, because they will all be replaced. 

var checkboxValues = LFForm.getFieldValues({fieldId: 2}).split(',');
LFForm.changeFieldOptions( { fieldId: 1 }, checkboxValues, "replace" );

 

3 0
replied on March 7, 2024

Thanks Matthew!  

Thanks for the solution.  I could see where this could be a helpful enhancement in the future.  But for now...javascript.  

0 0

Replies

replied on March 6, 2024

Is a form being filled out first and you want it to repopulate with what was checked in the next step or are you populating a form based on pre-determined outcomes from sql?

0 0
replied on March 7, 2024

Angela,

We actually create a 'document' using the input from our student information  system and the SDK.  The document has no pages, just metadata.  We have created a generic process that we use to do this.  It passes most of the data in as JSON.  That gives a lot more flexibility that creating many fields for a template.  And workflow can digest a JSON pretty easily.  Once the document exists in the repository, a workflow processes the associated data, looks some more data up, and starts a form that gets assigned to someone.  

If there was a way to create the checkbox with the SDK that would have saved us, but there isn't.  At least there isn't that we know of.  

 

Thanks...

Jamie

0 0
replied on March 7, 2024

That makes sense.  I was asking because the only way I know how to populate the checkboxes from another data source is a JS Script using JSON.  We actually collect student data from an application and save it in SQL.  If the parent needs to make a correction we send them a link and pull the saved data back into one hidden field and use an array to populate everything they previously filled out.  I wish you could populate the boxes and radio buttons from a basic lookup.  I'm just not sure how do that nicely from another system.

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

Sign in to reply to this post.