The JavaScript API

Sintel Forms contains a rich JavaScript API which can be used to manipulate fields on 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.

  Note

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.

 

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 getCurrentDate() Returns the current date.
6 setCurrentDate() Sets the current date.
7 updateLookupValues()  Overrides the contents of dropdown (lookup fields) .
8 cascadingDropdowns()  Allows the set up of a cascading relationship between dropdowns (e.g. Country, City).
9 hasFieldChanged() Allows to check whether a field has changed its value.

 

Function Examples

  1. getValue()
    Function Parameters:
    fieldName (string)

     Sample

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

    Notes:
    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 (mulit) Array of String
    Currency/Number Number
    Text String
    URL Url
    Flag Boolean
  2. setValue()
    Function Parameters:
    fieldName: the field to be set

     Sample

    Set the value of the "Reciever" field...
    setValue('Reciever', 'Joe Bloggs')

    Notes:
    None

  3. getCurrentUser()
    Function Parameters:
    None

     Sample

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

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

  4. setCurrentUser()
    Function Parameters:
    fieldName: the field to be set

     Sample

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

    Notes:
    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. getCurrentDate()
    Function Parameters:
    None

     Sample

    Get the current date...
    getCurrentDate()

    Notes:
    Returns the current date

  6. setCurrentDate()
    Function Parameters:
    fieldName: the field to be set

     Sample

    Set the Submitted Date to the current date...
    setCurrentDate('SubmittedDate')

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

  7. updateLookupValues()
    Function Parameters:
    lookupListId: id of the list with lookup values
    lookupDisplayFieldName: name of the ShP field that is used as a display field in the lookup
    lookupValues: array of new lookup values that should be assigned to the lookup.)

     Sample

    <content coming>

    Notes:
    Overrides the dropdown content of all lookup fields that use lookup values from the list of given Id and display field.

  8. 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)

     Sample

    Implement cascading dropdowns between Countries and Cities...
    let parentLookupFieldName = 'Country';
    let childLookupFieldName= 'City';
    let childLookupFilterFieldName = 'Country';
    
    cascadingDropdowns(parentLookupFieldName , childLookupFieldName, childLookupFilterFieldName);

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

  9. hasFieldChanged()
    Function Parameters:
    fieldName: name of the field which value should be checked

     Sample

    <content coming>

    Notes:
    Allows to check whether a field has changed its value since last Rule execution
    Evaluates true if the field has changed, otherwise false.

    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



Examples

  1. Getting a field and setting a field

  2. Getting the Current User and setting a User field

  3. Getting a date and setting a date field

  4. Updating a lookup

  5. Adding Cascading Drop-downs

  6. Setting a People Picker

  7. Checking if a field has changed

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