The JavaScript API

Sintel Forms contains a rich JavaScript API which can be used to manipulate fields on forms.

Warning!

In all cases when manipulating fields the fieldName parameter must match the internal name of the SharePoint field or column and not the Title nor the display name set within the layout in Sintel Forms.

You can use this API to quickly get and set various fields on a form using conditions and steps within rules in the logic screen of the Sintel Forms Designer.

 

No. Function Description
1 getValue() Returns the value of a field on the form
2 setValue() Sets the value of a field on the form.
3 getCurrentUser() Returns the details of the currently logged in user.
4

setCurrentUser()

Sets the details of the currently logged in user.
5 setCurrentDate() Sets the current date.
6 updateLookupValues()  Overrides the contents of dropdown (lookup fields).
7 cascadingDropdowns()  Allows the set up of a cascading relationship between dropdowns (e.g. Country, City).

 

  1. getValue()

    Function Parameters:
    fieldName (string)

     

    Example

    Get the value of the "Country" field...
    getValue('Country')

      Note

    The value is case sensitive.
    The return value type depends on the type of field that the function has been invoked for:

    Field Type Return Type
    User (both single and multi-select) Array of User
    Lookup (single) LookupItem
    Lookup (multi) Array of LookupItem
    Date Date
    Choice (single) String
    Choice (multi) Array of String
    Currency/Number Number
    Text String
    URL Url
    Flag Boolean
  2. setValue()

    Function Parameters:
    fieldName: the field to be set

    Example

    Set the value of the "Shipping Costs" field...
    let country = getValue("Country");
    
    if (country == "England")
    {
      setValue("ShippingCosts", "10")
    }

     

    2019-04-09_0943.png

     

    getsetvalue.gif

     

  3. getCurrentUser()


    Function Parameters:
    None

    Example

    Get the details of the currently logged in user...
    getCurrentUser()

      Note

    Returns the object of User type, holding information about the currently logged in user.

  4. setCurrentUser()


    Function Parameters:
    fieldName: the field to be set

    Example

    Set the details of the currently logged in user into the "User" field...
    setCurrentUser('User')

     

    2019-04-09_1306.png

     

    getsetuser.gif

     

      Note

    Sets the value taken from the "getCurrentUser()" function into a given field. Should be used with "User" field types. To allow for the "User" field type to receive an array of User object types, this function's implementation is as follows: setValue(fieldName, [getCurrentUser()]); (note the square brackets around the 2nd parameter)

  5. setCurrentDate()


    Function Parameters:
    fieldName: the field to be set

    Example

    Set the Date Picker field to the current date...
    setCurrentDate('DatePicker')

     

    2019-04-10_0955.png

     

    setdate.gif

     

      Note

    Sets the value taken from the "getCurrentDate()" function into a given field.

  6. updateLookupValues()


    Function Parameters:
    fieldName: name of the lookup field
    lookupValues: array of new lookup values that should be assigned to the lookup.

    Example

    let lookupFieldName = "Countries";
    updateLookupValues(lookupFieldName, [{id: 1, value: "Country #1"},{id: 2, value: "Country #2"}] 

      Note

    This function overrides the dropdown content of the provided lookup field. It is meant to be used internally (by cascadingDropdowns function), so try to avoid using it in your custom logic)

  7. cascadingDropdowns()


    Function Parameters:

    parentLookupFieldName: The field containing parent lookup field (which the item id will be taken from)

    childLookupFieldName: The field containing child lookup field (the one which values will be filtered)

    childLookupFilterFieldName (The field in child lookup that should be used to compare the parent id values)


    Example A

    Implement cascading drop-downs between Countries and Cities.
    Assumptions:
    a) there is a "Countries" list containing countries
    b) there is a "Cities" list containing cities and a lookup to the "Countries" list (named CountryLookup)
    c) within the main list (the one in which Sintel Forms is enabled - let's call it "TestList") there are 2 lookup fields in the main list "City" and "Country" fields that are linked to the "Countries" and "Cities" lists respectively
    let parentLookupFieldName = 'Country';
    let childLookupFieldName= 'City';
    let childLookupFilterFieldName = 'CountryLookup';
    
    cascadingDropdowns(parentLookupFieldName , childLookupFieldName, childLookupFilterFieldName);

     

    2019-04-09_1429.png

     

    cascading.gif

     

    Example B

    Implement cascading dropdowns between Countries and Cities, but on a linked list level.
    Assumptions are similar to the ones above, but the "City" and "Country" fields are now located on a linked list named "TestList" (internal namelist from the previous example).
    let parentLookupFieldName = 'TestList.Country';
    let childLookupFieldName= 'TestList.City';
    let childLookupFilterFieldName = 'CountryLookup';
    
    cascadingDropdowns(parentLookupFieldName , childLookupFieldName, childLookupFilterFieldName);

     

    2019-04-09_1541.png

     

    cascadinglookup.gif

     

    Notes:
    Allows to set up a cascading relation between dropdowns.
    Type Definitions

    User
    Field Name Field Type
    displayName string
    id string



    LookupItem

    Field Name Field Type
    id number
    value string



    Url

    Field Name Field Type
    description string
    url string

 

Was this article helpful?
0 out of 0 found this helpful