Automatically add linked items or files

You can automatically add linked items or files to a new form using a custom js step within the Logic screen.

Here is an example of a function to do this. 

insertSublistItems('internal Linked List name', [
{ Internal field name: 'value',
Internal field name: 'value'
}])

 

Warning

  1. We do not recommend changing system fields.

  2. Make sure that steps and conditions that you create do not create an infinite loop, you should ensure that adding of new items/files is stopped at some point.

  3. If from some reason during saving an error occurs (caused by invalid data in the sublist for example) - the main form and other sublists will be saved - unless they are invalid too.

 

Example

Here are examples of the various field types and how to set their values:

 

    1. Single line

      SingleLine: 'First Image',
    2. Multi-line

      MultiLine: 'Three\nline\ntext',

        Note

      For multi-line rich text fields you should use HTML syntax.

    3. Number

      Number: '7.5',
    4. Yes/No

      YesNo: '1',

        Note

      'Yes' = 1, 'No' = 0

    5. Date and time / Date

      DateTime: new Date(2019, 5, 1, 6, 30),
      Date: Date.now(),

        Note

      Remember that months in JS are indexed from 0. So DateTime: new Date(2019, 5, 1), will give you 2019/06/01 i.e. January is 0.

    6. Person/Group

      PersonGroup: ['groupSite Owners'],
      PersonMulti: ['slawek@sintel.ie', 'piotr@sintel.ie'],

        Note

      The SharePoint group must exist, and the user must have permissions to access the group, otherwise the record will be invalid and won't save.

    7. Choice

      Dropdown: 'Choice 1',
      Checkbox: ['Choice 1','Choice 2'],
      Radiobutton: 'Choice 3',
    8. Hyperlink/Picture

      Hyperlink: { url: 'https://twistedsifter.files.wordpress.com/2012/03/hover-cat-flying-cat-2.jpg?w=640&h=447', description: 'cat' },
      Picture: { url: 'https://apod.nasa.gov/apod/image/1901/MeteorMountain_Roemmelt_1371.jpg', description: 'space' },
    9. File (Document/Picture Library Linked List)

      File: { Name: 'hover-cat-flying-cat-2.jpg', Url: 'https://twistedsifter.files.wordpress.com/2012/03/hover-cat-flying-cat-2.jpg?w=640&h=447' },

        Note

      If the link will be invalid for some reason the whole row won't be added - be sure to check the given URL.

    10. Lookup

      Lookup: '1',

        Note

      The given number is an index of a list item from within the Linked List.

There are also two additional properties available:

  1. notEditable: 'true',
  2. notDeletable: 'true',

As the name suggests the first property causes that newly added items are not editable, the second property controls whether the items are deletable - this only applies to rows added via the insertSublistItems function.

  Note

In the examples above the 'true' statement is redundant, it is only added to improve readability. Changing this to 'false' does not change the property so if you want newly added row(s) to be editable simply delete the notEditable property.

Warning

These properties only apply to linked items or files added to a new form using a custom js step within the Logic screen.

 

Example

2019-06-24_0145.png

 

2019-06-23_1744.png

 

insertScript.gif
Was this article helpful?
0 out of 0 found this helpful