Possible to wrap autocomplete in a JS function, and trigger it only by a rule ?

Forums Autocomplete Possible to wrap autocomplete in a JS function, and trigger it only by a rule ?

This topic contains 2 replies, has 2 voices, and was last updated by  Erik Thomte 1 year ago.

  • Author
    Posts
  • #14274

    Erik Thomte
    Participant

    Hi

    Environment: Office 365, With the newest Version of DFFS, and 1.4.8.1 autocomplete plugin.

    As I understand it, the Autocomplete solution triggers when the form loads. Not sure if the type-Ahead search is on-the fly, or if the correspondinbg list values are cached somehow.

    My scenario:
    A field called *Incident ReporterCategory* contains some choices for the user

  • 1. Internal
    2. Customer
    3. Supplier
    4. Other
  • Rules are set up for this Field: if selected is Internal, unhide a radiobutton Field With Choices, if value=”other” unide a one-line text Field.

    If the user Selects customer or Supplier, then unhide a text Field, which has autocomplete Attached to it. Actually two fields With CAML Query to filter on Company type.

    Autocomplete is set up to get values from a Company Contacts list elsewhere.
    This list contains both customers and Suppliers, With a field for Company type, values Customer and Supplier.

    I assume that the form with the “Incident Reporter category” will have a increased load time if this company list contains a lot of records (lets say 4000).

    If the user doesn’t Select Customer or Supplier, then autocomplete isn’t needed, and load can be reduced.

    Q: Is it possible to wrap Autocomplete in a js function inside the custom JS area (preferably with some params), and trigger the js function via a DFFS rule ?

    Q: As a bonus, could the js function contain params so that only one autocomplete text field would be needed, eg params for the CAML Query filtering ?

    Regards
    Erik

  • #14294

    Alexander Bautz
    Keymaster

    Hi,
    Sorry for the late reply. Applying the autocomplete solution will not preload anything and shouldn’t put any extra strain on your server (or prolong the form load) as not query are run before the user starts typing into the field.

    When this is said, you can put the function call in a separate function and call it whenever you are ready. You cannot call it with parameters from a DFFS rule, but you can wrap each call (to customer or supplier) in separate functions an call these functions from DFFS rules. Here is an example:

    function customerAC(){
        spjs.ac.textField({
        	"applyTo":"CustomerAutocomplete",
        	"helpText":"Start typing to search for a customer...",
        	"listGuid":"TheCustomerList",
        	"filterCAML":"<Eq><FieldRef Name='CompanyType'/><Value Type='Text'>Customer</Value></Eq>"
        	"listBaseUrl":"/Sites/YourSite",
        	"showField":"Title",
        	"enforceUniqueValues":true,
        	"rowLimit":15,
        	"listOptionsOnFocus":false,
        	"reValidateOnLoad":false,
        	"allowAddNew":true, // New in v1.4
        	"isLookupInSelf":true, // New in v1.4
        	"setFields":[]					
        });
    }

    Then put “customerAC” in the “Run these functions / trigger these rules” field in your rule.

    To have a similar function for suppliers, just copy the “customerAC” function and all it “supplierAC” and call it form the other rule.

    Alexander

  • #14306

    Erik Thomte
    Participant

    Hi

    Thanks for the reply. Since Autocomplete doesn’t preload anything I will just use it as is.

  • You must be logged in to reply to this topic.