Questions and discussion about developing processes and programming in PHP, JavaScript, web services & REST API.
Forum rules: Please search to see if a question has already asked before creating a new topic. Please don't post the same question in multiple forums.
#814344
What's the best way to keep a dropdown of a few thousand entries updated weekly? I have data being added and removed.

I had been using a PM Table to populate my dropdown but didn't realize that deleting an entry will also delete it from completed and in-process cases. I had considered converting the PM Table data into an array variable but it seems like it would be needlessly clunky to keep a massive array in every case. Is there a better option out there?

Thanks!
#814359
If you are displaying the same field multiple times in different DynaForms in a process, then in the first DynaForm, you can use a dropdown and then after that you can use a suggest box to display the same variable. The suggest box will preserve the value, even if it is deleted from the database.

Another option is to use JavaScript to automatically add the deleted option to the list of options in the dropdown box.

This JavaScript code will preserve the original value, by adding it as an option to the dropdown box:
Code: Select all
var dropdownId = "paymentMethod"; //set to ID of dropdown field 
var drpValue = $("#"+dropdownId).getValue();

if (drpValue != '') {
  var drpLabel = $("#"+dropdownId).getText();
  var aOpts = getFieldById(dropdownId).model.attributes.options;
  var found = false;

  //search for the dropdown's current value in its list of available options:
  for (idx in aOpts) {
    if (aOpts[idx].value == drpValue) {
      found = idx;
      break;
    }
  }

  //if the current value of the dropdown is not in the list of options,
  //then the value has been deleted from the database, so temporarily
  //add it to the list of options so the user can see it:
  if (found === false) {
    $("#"+dropdownId).getInfo().options.push({value: drpValue, label: drpLabel});
    $("#form\\["+dropdownId+"\\]").append( $(new Option(drpLabel, drpValue)) );
    getFieldById(dropdownId).setValue(drpValue);
  }
}
Want to create your own meme coin?

In the world of cryptocurrencies, a unique and exc[…]

The market for cryptocurrencies is demonstrating a[…]

What's SAP FICO?

Embarking on a dissertation can be one of the most[…]

Hello. For rental housing, there are software solu[…]