using wherecontains function to find the index in a record type

Certified Senior Developer

Hello,

I've been trying to implement this functionality since morning but with no luck. We have a form where the user can input multiple locations if they want to. The functionality is as follows:

1. User fills out the address and additional questions as below

The information for these questions is saved in the Input record type which has a one-to-one relationship with Project Location record type. 

If the user clicks on add potential location, a new Project Location entry is appended to the existing Project Location array. We need to give the user the option to prepopulate the values of the previous location to the new location if they want. 

My approach is as follows:

I need to create a local!currentIndex variable that uses wherecontains function to tap into the values and give me the array. I then index into that array and store it to another local variable local!prepopulatedData

Problem is, I never used wherecontains before and the logic of this is confusing the hell out of me! If anyone ever did this before, where they had to prepopulate dropdown,checkboxes etc. from previous data, please let me know, I'd greatly appreicate the help! Here is what I have for the two local variable, I would idealy want the local!currentIndex to tap into the Project Location record type and get me the correct data

The read square above is where the logic of retrieving the array of the Project Location record type. 

If anyone needs any more information about this, let me know, I'll be happy to share!

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Senior Developer

    I still do not understand your problem with the provided information,

    But for the point how to use the wherecontains() here is the documentation and a small example.

    a!localVariables(
      local!data: {
        'recordType!{dbfc30b0-9268-4173-a567-8600fe9d66b8}KS Sample'(
          'recordType!{dbfc30b0-9268-4173-a567-8600fe9d66b8}KS Sample.fields.{90e53af2-608d-4fc7-b922-ec3a5c8182f7}id': 1,
          'recordType!{dbfc30b0-9268-4173-a567-8600fe9d66b8}KS Sample.fields.{3293898d-b8ac-46b6-9820-19869d0136ee}nameEmp': "xyz",
          'recordType!{dbfc30b0-9268-4173-a567-8600fe9d66b8}KS Sample.fields.{89609362-f196-4a2d-ac6c-87226cf14fcb}Days': 22
        ),
        'recordType!{dbfc30b0-9268-4173-a567-8600fe9d66b8}KS Sample'(
          'recordType!{dbfc30b0-9268-4173-a567-8600fe9d66b8}KS Sample.fields.{90e53af2-608d-4fc7-b922-ec3a5c8182f7}id': 2,
          'recordType!{dbfc30b0-9268-4173-a567-8600fe9d66b8}KS Sample.fields.{3293898d-b8ac-46b6-9820-19869d0136ee}nameEmp': "abc",
          'recordType!{dbfc30b0-9268-4173-a567-8600fe9d66b8}KS Sample.fields.{89609362-f196-4a2d-ac6c-87226cf14fcb}Days': 22
        ),
        'recordType!{dbfc30b0-9268-4173-a567-8600fe9d66b8}KS Sample'(
          'recordType!{dbfc30b0-9268-4173-a567-8600fe9d66b8}KS Sample.fields.{90e53af2-608d-4fc7-b922-ec3a5c8182f7}id': 3,
          'recordType!{dbfc30b0-9268-4173-a567-8600fe9d66b8}KS Sample.fields.{3293898d-b8ac-46b6-9820-19869d0136ee}nameEmp': "lmno",
          'recordType!{dbfc30b0-9268-4173-a567-8600fe9d66b8}KS Sample.fields.{89609362-f196-4a2d-ac6c-87226cf14fcb}Days': 22
        ),
        'recordType!{dbfc30b0-9268-4173-a567-8600fe9d66b8}KS Sample'(
          'recordType!{dbfc30b0-9268-4173-a567-8600fe9d66b8}KS Sample.fields.{90e53af2-608d-4fc7-b922-ec3a5c8182f7}id': 4,
          'recordType!{dbfc30b0-9268-4173-a567-8600fe9d66b8}KS Sample.fields.{3293898d-b8ac-46b6-9820-19869d0136ee}nameEmp': "pqr",
          'recordType!{dbfc30b0-9268-4173-a567-8600fe9d66b8}KS Sample.fields.{89609362-f196-4a2d-ac6c-87226cf14fcb}Days': 22
        )
      },
      local!previousvalues: a!map(id: 19, sampId: 2, product: "bottle"),
      wherecontains(
        local!previousvalues.sampId,
        local!data['recordType!{dbfc30b0-9268-4173-a567-8600fe9d66b8}KS Sample.fields.{90e53af2-608d-4fc7-b922-ec3a5c8182f7}id']
      )
    )

    whereContains()

Reply
  • 0
    Certified Senior Developer

    I still do not understand your problem with the provided information,

    But for the point how to use the wherecontains() here is the documentation and a small example.

    a!localVariables(
      local!data: {
        'recordType!{dbfc30b0-9268-4173-a567-8600fe9d66b8}KS Sample'(
          'recordType!{dbfc30b0-9268-4173-a567-8600fe9d66b8}KS Sample.fields.{90e53af2-608d-4fc7-b922-ec3a5c8182f7}id': 1,
          'recordType!{dbfc30b0-9268-4173-a567-8600fe9d66b8}KS Sample.fields.{3293898d-b8ac-46b6-9820-19869d0136ee}nameEmp': "xyz",
          'recordType!{dbfc30b0-9268-4173-a567-8600fe9d66b8}KS Sample.fields.{89609362-f196-4a2d-ac6c-87226cf14fcb}Days': 22
        ),
        'recordType!{dbfc30b0-9268-4173-a567-8600fe9d66b8}KS Sample'(
          'recordType!{dbfc30b0-9268-4173-a567-8600fe9d66b8}KS Sample.fields.{90e53af2-608d-4fc7-b922-ec3a5c8182f7}id': 2,
          'recordType!{dbfc30b0-9268-4173-a567-8600fe9d66b8}KS Sample.fields.{3293898d-b8ac-46b6-9820-19869d0136ee}nameEmp': "abc",
          'recordType!{dbfc30b0-9268-4173-a567-8600fe9d66b8}KS Sample.fields.{89609362-f196-4a2d-ac6c-87226cf14fcb}Days': 22
        ),
        'recordType!{dbfc30b0-9268-4173-a567-8600fe9d66b8}KS Sample'(
          'recordType!{dbfc30b0-9268-4173-a567-8600fe9d66b8}KS Sample.fields.{90e53af2-608d-4fc7-b922-ec3a5c8182f7}id': 3,
          'recordType!{dbfc30b0-9268-4173-a567-8600fe9d66b8}KS Sample.fields.{3293898d-b8ac-46b6-9820-19869d0136ee}nameEmp': "lmno",
          'recordType!{dbfc30b0-9268-4173-a567-8600fe9d66b8}KS Sample.fields.{89609362-f196-4a2d-ac6c-87226cf14fcb}Days': 22
        ),
        'recordType!{dbfc30b0-9268-4173-a567-8600fe9d66b8}KS Sample'(
          'recordType!{dbfc30b0-9268-4173-a567-8600fe9d66b8}KS Sample.fields.{90e53af2-608d-4fc7-b922-ec3a5c8182f7}id': 4,
          'recordType!{dbfc30b0-9268-4173-a567-8600fe9d66b8}KS Sample.fields.{3293898d-b8ac-46b6-9820-19869d0136ee}nameEmp': "pqr",
          'recordType!{dbfc30b0-9268-4173-a567-8600fe9d66b8}KS Sample.fields.{89609362-f196-4a2d-ac6c-87226cf14fcb}Days': 22
        )
      },
      local!previousvalues: a!map(id: 19, sampId: 2, product: "bottle"),
      wherecontains(
        local!previousvalues.sampId,
        local!data['recordType!{dbfc30b0-9268-4173-a567-8600fe9d66b8}KS Sample.fields.{90e53af2-608d-4fc7-b922-ec3a5c8182f7}id']
      )
    )

    whereContains()

Children
No Data