posted 10 hours ago

I've found some issues with Modern Form Designer and am having difficulties getting a custom drop-down to have the correct options using the LFForms object. So I thought I'd post here to see if anyone can figure out what's going on with this...

Process exported XML file renamed to .txt so it could be posted.

Issue1

Multipage Form is setup so that Page2 is only displayed when a checkbox is checked. When the Form is opened only the default page is shown so the Previous/Next Buttons aren't there and only the Submit button is shown. Clicking the checkbox adds the Tabs and moves the Submit button to Page2, however the Previous/Next Buttons never show up on the Default Page.





Issue 2 
Page 2, I'm working on a Drop-down which should be populated with labels and values from a Collection on the page. ( This is for a Form where the collection is populated from a workflow with API calls which are not available from a Data Source so I can't use Lookup Rules to populate the drop-down. ) 



 


LFForm.onFieldChange( 
  function (event) {

	updateCustomDropdown();
    
  }, {fieldId: 7});
LFForm.onFieldChange( 
  function (event) {

	updateCustomDropdown();
    
  }, {fieldId: 8});

function updateCustomDropdown()
{
   var optionLabels = LFForm.getFieldValues({fieldId: 7});
   var optionValues = LFForm.getFieldValues({fieldId: 8});
   var customDropdownValue = LFForm.getFieldValues({fieldId: 10});
   var dropdownOptions = LFForm.findFieldsByFieldId(10)[0].options; 
   var index = 0; 
    
   console.log("Clearing Options  - dropdown value = "+customDropdownValue+".");

	dropdownOptions.forEach(function (existingOption) {

      console.log("Removing Option "+existingOption.label+".");
   	  LFForm.changeFieldOptions({fieldId: 10}, [{label: existingOption.label}], "remove" );
    });
  
   console.log("Populating Options.");

   while( index < optionLabels.length ) 
   {
     	var selected = customDropdownValue == optionValues[index];
     
        console.log(" Add - Option - {selected: "+selected+", label: '"+optionLabels[index]+"', value: '"+optionValues[index]+"'}");
     
        LFForm.changeFieldOptions({fieldId: 10}, [{label: optionLabels[index], value: optionValues[index]}], "add" );
                         
  		index++;
	}
  
   console.log("Finished Populating Options.");
}

updateCustomDropdown();

Function updateCustomDropdown should grab the current options in the CustomDropdown (fieldId: 10) and remove each of them before grabbing the labels and values from the collection and adding them to the drop-down leaving the current value selected... however the JavaScript seems to be doing what it's supposed to be doing as the Choice2 and Choice3 default options keep remaining despite the console log telling me everything I expect to see....  





Anyone have any thoughts as to why the LFForms calls don't seem to be working?

On Prim; Laserfiche Forms Professional Version 12.0.2607.40137
 

0 0