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

Question

Question

set business process variables of dropdown field in forms

asked on April 10, 2018

Hi,

I have multi-value string token %(Members) in my workflow and trying to set a dropdown field in forms using "Set Business Process Variables" activity as below.

 

 

In forms, dropdown is always filled with first value. Not all. Is it the correct way to pass multi-value token to dropdown field in forms?

1 0

Answer

SELECTED ANSWER
replied on April 10, 2018

Set Business Process Values actually selects a value for the field, it does not set the list of available values for a user to select from. Drop-down fields in Forms can only have one value selected at a time.

0 0

Replies

replied on April 11, 2018

Thanks Miruna for clarification. I was assuming that we can set the list of available values in dropdown field. But this is not the case. We can only set single value of the field from available values.

 

Anyhow, I have used another way to fill my dropdown list from lookup fields (database) in one hidden field in the form. I just set the hidden field from my workflow and form do field lookup to fill dropdown list and it's working perfect.

2 0
replied on August 27, 2018 Show version history

(Updated to include prepend empty option to top of the list)

There is a way that you can get around this by using workflows and Javascript.

In workflows:

We use a custom query activity to query our database for the information that we need. For example, members on an account. Our query returns multiple owners of the account in one string separated by a pipe. Ex. Member1|Member2|Member3

Then we use the "Set Business Variable" activity to push that string to Laserfiche Forms into an empty drop-down field.

In Laserfiche Forms we assign a specific css class to that field. For example: List_of_Owners

Then we use the following JavaScript to separate the string from Workflows out into drop-down field choices. (Replace "List_of_Owners" with whatever you named your css class)

$(document).ready(function () { 
//Compile correct list of Owners in "Person Making Request Field"
//Loop through all options in the drop-down list.
  var options = $('.List_of_Owners option:first-child').text().split('|');
  var index;
  for (index=0; index<options.length; index++) {
    $('.List_of_Owners select.form-item-field').append("<option>"+options[index]+"</option>");
  }
  $('.List_of_Owners option:first-child').remove();
  $("<option>", { value: '', selected: true }).prependTo(".List_of_Owners select.form-item-field");

//Prepend a blank option to the field
  $("<option>", { value: '', selected: true }).prependTo(".List_of_Owners select.form-item-field");

});

That should convert the string into drop down choices like you want.

Hope this helps. :)

 

 

2 0
replied on September 8, 2020

Hey Laryssa!  This is great!  I'm trying to use it, and I'm getting the pipe-separated value back into the empty dropdown field, but the JavaScript doesn't seem to be doing anything.  I applied the CSS class "List_of_Vendors" to the field I am using, and used the following code:

//Compile correct list of Vendors in "Vendor Managers List"
$(document).ready(function () { 
//Loop through all options in the drop-down list.
  var options = $('.List_of_Vendors option:first-child').text().split(' | ');
  var index;
  for (index=0; index<options.length; index++) {
    $('.List_of_Vendors select.form-item-field').append("<option>"+options[index]+"</option>");
  }
  $('.List_of_Vendors option:first-child').remove();
  $("<option>", { value: '', selected: true }).prependTo(".List_of_Vendors select.form-item-field");

});

The string coming over from Workflow is similar to "ASI|Lockton Companies|Allied Marketing Solutions (Affinion Group)|Campaign Monitor", but longer (about 95 values)

Any idea what I may be missing?

2 0
replied on September 9, 2020

Hey Paul! 

It looks like in the original post I made, I specified that I was separating values by a "|" but I was actually separating by " | " so my code wasn't working for you. :) I have updated code for you below that should work for your case. Sorry about that. I also had since added an additional line at the bottom that would prepend a blank to the top of the list instead of automatically selecting the first option in your string. Let me know if that doesn't work for you.

$(document).ready(function () { 
  
//Compile correct list of Vendors in "Vendor Managers List"
//Replace string separated by "|" into separate drop-down options
  
  var listoptions = $('.List_of_Vendors option:first-child').text().split('|');
  var listindex;
  for (listindex=0; listindex<listoptions.length; listindex++) {
    $('.List_of_Vendors select.form-item-field').append("<option>"+listoptions[listindex]+"</option>");
  }
 	//Remove the string from option one
  $('.List_of_Vendors option:first-child').remove();
  
 	//Prepend a blank to the field
  $("<option>", { value: '', selected: true }).prependTo(".List_of_Vendors select.form-item-field");
 
});

 

2 0
replied on September 9, 2020

Hey Laryssa!  Thanks for responding.  I tried this new code, and got the same result.  The vendors are still in a single pipe-delimited string as the only option for the dropdown.  It DOES, however, put a blank above it, so I know the code is doing something to the field.

 

Interestingly, If I remove the "option:first-child" from line 6, I get a closer output with a blank in position 1, the pipe-delimited string in position 2, position 3 with "Vendor Managersfield type drop-downASI" (ASI is the first option in the list), then the rest of the options in their own positions in the list.  I'm close, but still missing something.

replied on September 9, 2020 Show version history

I found my issue.  I had another issue with the form that was interfering with it by making that field read-only.  Your code works like a charm!  Thanks so much!

1 0
replied on April 10, 2018 Show version history

Not for nothing, but what I usually do is kick the forms process off from workflow with the other starting variables I want, and if there is a dropdown I want selections to be available for from the workflow, I add a step right before the 'Invoke Business Process' activity to add the multi-value token to a table as a column by iterating through it with a for each value and forming rows in the table.  Then all you have to do is use that table for a lookup when your form loads, and assign that column to your dropdown field.  Its a bit more work, but it does work nicely, as if there is a user task after the process begins, the user will have those selections to choose from, and they were still put there by the workflow so it accomplishes the same thing.

1 0
replied on April 10, 2018

One option could be to run a For Each Value loop and concatenate all your values separated by a brake. Some of the folks in here know this by heart and might put together an example really quick for you I'm sure.

I'll see if I can pull a similar example from some of the work I've done, since this seems like something we might use eventually as well.

0 0
replied on April 10, 2018

Hi,

Actually I'm already doing For Each, but instead of concatenating I'm appending the values to multi-value token %(Members). I'm not sure if multi-value token will fill the dropdown field in forms.

 

I'm trying to find how to set dropdown field values from workflow using "Set Business Process Variables" activity. Should we pass a multi-value token or a string separated with brake?

 

What is brake? Sorry couldn't get it.

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

Sign in to reply to this post.