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 Associate Developer

    Hi  ,

    do you need to prepopulate the previous values to the newly added project entry location?

  • 0
    Certified Senior Developer
    in reply to Vyshnavi Naripeddi

    Thank you for your reply Vyshnavi,

    Yes, I got it down where I retrieve the index - 1 of all projects and then they are prepopulated when I click the button, but now I'm facing an issue where the checkbox field is not being pre-populated with the saved value. I'm guessing it's because I'm displaying the value of the checkbox field as a rule input and not as a value from the record

    Below is an image of the checkbox field logic and a video of everything working except for the checkbox field (even though the values are saved correctly in the database -- the values are boolean)

    Also below is the logic for saving the checkbox values into the record when the user click on "prepopulate" link. The values are saved correctly but are not displayed when the user clicks back on the created form 

    a!richTextDisplayField(
                label: "",
                value: {
                  a!richTextIcon(
                    icon: "archive",
                    linkStyle: "STANDALONE",
                    link: a!dynamicLink(
                      label: "Prepopulate with values from previous location",
                      saveInto: {
                        a!save(ri!projectLocation['recordType!{27334095-47d5-4486-897d-e61f2c02b0fa}GF Project Plan Location.relationships.{b2a233ce-de5d-4abb-8641-e5ab9f7cc367}gfProjectPlanLocationInput.fields.{858049fe-d5c2-45ef-80ad-b5e933926a85}evChargingId'], local!prepopulatedData['recordType!{27334095-47d5-4486-897d-e61f2c02b0fa}GF Project Plan Location.relationships.{b2a233ce-de5d-4abb-8641-e5ab9f7cc367}gfProjectPlanLocationInput.fields.{858049fe-d5c2-45ef-80ad-b5e933926a85}evChargingId']),
                        a!save(ri!projectLocation['recordType!{27334095-47d5-4486-897d-e61f2c02b0fa}GF Project Plan Location.relationships.{b2a233ce-de5d-4abb-8641-e5ab9f7cc367}gfProjectPlanLocationInput.fields.{a6dfefd6-0ec1-4cf4-80b1-51ff27f82eba}tenantRightId'], local!prepopulatedData['recordType!{27334095-47d5-4486-897d-e61f2c02b0fa}GF Project Plan Location.relationships.{b2a233ce-de5d-4abb-8641-e5ab9f7cc367}gfProjectPlanLocationInput.fields.{a6dfefd6-0ec1-4cf4-80b1-51ff27f82eba}tenantRightId']),
                        a!save(ri!projectLocation['recordType!{27334095-47d5-4486-897d-e61f2c02b0fa}GF Project Plan Location.relationships.{b2a233ce-de5d-4abb-8641-e5ab9f7cc367}gfProjectPlanLocationInput.fields.{8efcab4d-e2c2-4b42-81af-5e8816315119}isLandowner'], local!prepopulatedData['recordType!{27334095-47d5-4486-897d-e61f2c02b0fa}GF Project Plan Location.relationships.{b2a233ce-de5d-4abb-8641-e5ab9f7cc367}gfProjectPlanLocationInput.fields.{8efcab4d-e2c2-4b42-81af-5e8816315119}isLandowner']),
                        a!save(ri!projectLocation['recordType!{27334095-47d5-4486-897d-e61f2c02b0fa}GF Project Plan Location.relationships.{b2a233ce-de5d-4abb-8641-e5ab9f7cc367}gfProjectPlanLocationInput.fields.{e7e77ed4-6672-4535-8745-4e188417870b}landOwnerEasementObtained'], local!prepopulatedData['recordType!{27334095-47d5-4486-897d-e61f2c02b0fa}GF Project Plan Location.relationships.{b2a233ce-de5d-4abb-8641-e5ab9f7cc367}gfProjectPlanLocationInput.fields.{e7e77ed4-6672-4535-8745-4e188417870b}landOwnerEasementObtained']),
                        a!save(ri!projectLocation['recordType!{27334095-47d5-4486-897d-e61f2c02b0fa}GF Project Plan Location.relationships.{b2a233ce-de5d-4abb-8641-e5ab9f7cc367}gfProjectPlanLocationInput.fields.{8a263249-2671-4bc2-a949-0fff33a49dd0}authorization'], local!prepopulatedData['recordType!{27334095-47d5-4486-897d-e61f2c02b0fa}GF Project Plan Location.relationships.{b2a233ce-de5d-4abb-8641-e5ab9f7cc367}gfProjectPlanLocationInput.fields.{8a263249-2671-4bc2-a949-0fff33a49dd0}authorization']),
                        a!save(ri!projectLocation['recordType!{27334095-47d5-4486-897d-e61f2c02b0fa}GF Project Plan Location.relationships.{b2a233ce-de5d-4abb-8641-e5ab9f7cc367}gfProjectPlanLocationInput.fields.{c1ddfea3-fd09-4953-8325-2dd8443f95b9}permits'], local!prepopulatedData['recordType!{27334095-47d5-4486-897d-e61f2c02b0fa}GF Project Plan Location.relationships.{b2a233ce-de5d-4abb-8641-e5ab9f7cc367}gfProjectPlanLocationInput.fields.{c1ddfea3-fd09-4953-8325-2dd8443f95b9}permits']),
                        a!save(ri!projectLocation['recordType!{27334095-47d5-4486-897d-e61f2c02b0fa}GF Project Plan Location.relationships.{b2a233ce-de5d-4abb-8641-e5ab9f7cc367}gfProjectPlanLocationInput.fields.{ae530101-526e-4d43-9061-60e62e9d6341}zoningRestrictionId'], local!prepopulatedData['recordType!{27334095-47d5-4486-897d-e61f2c02b0fa}GF Project Plan Location.relationships.{b2a233ce-de5d-4abb-8641-e5ab9f7cc367}gfProjectPlanLocationInput.fields.{ae530101-526e-4d43-9061-60e62e9d6341}zoningRestrictionId']),
                        a!save(ri!projectLocation['recordType!{27334095-47d5-4486-897d-e61f2c02b0fa}GF Project Plan Location.relationships.{b2a233ce-de5d-4abb-8641-e5ab9f7cc367}gfProjectPlanLocationInput.fields.{0b920b80-fbdd-4cc4-821d-ae5859e4ebf0}zoningExplanation'], local!prepopulatedData['recordType!{27334095-47d5-4486-897d-e61f2c02b0fa}GF Project Plan Location.relationships.{b2a233ce-de5d-4abb-8641-e5ab9f7cc367}gfProjectPlanLocationInput.fields.{0b920b80-fbdd-4cc4-821d-ae5859e4ebf0}zoningExplanation'])
    
                      }
                    ),
                    showWhen: a!isNotNullOrEmpty(local!prepopulatedData)
                  ),
                  " ",
                  a!richTextItem(
                    text: "Prepopulate values from previous location",
                    link: a!dynamicLink(
                      label: "Prepopulate with values from previous location",
                      saveInto: {
                        a!save(ri!projectLocation['recordType!{27334095-47d5-4486-897d-e61f2c02b0fa}GF Project Plan Location.relationships.{b2a233ce-de5d-4abb-8641-e5ab9f7cc367}gfProjectPlanLocationInput.fields.{858049fe-d5c2-45ef-80ad-b5e933926a85}evChargingId'], local!prepopulatedData['recordType!{27334095-47d5-4486-897d-e61f2c02b0fa}GF Project Plan Location.relationships.{b2a233ce-de5d-4abb-8641-e5ab9f7cc367}gfProjectPlanLocationInput.fields.{858049fe-d5c2-45ef-80ad-b5e933926a85}evChargingId']),
                        a!save(ri!projectLocation['recordType!{27334095-47d5-4486-897d-e61f2c02b0fa}GF Project Plan Location.relationships.{b2a233ce-de5d-4abb-8641-e5ab9f7cc367}gfProjectPlanLocationInput.fields.{a6dfefd6-0ec1-4cf4-80b1-51ff27f82eba}tenantRightId'], local!prepopulatedData['recordType!{27334095-47d5-4486-897d-e61f2c02b0fa}GF Project Plan Location.relationships.{b2a233ce-de5d-4abb-8641-e5ab9f7cc367}gfProjectPlanLocationInput.fields.{a6dfefd6-0ec1-4cf4-80b1-51ff27f82eba}tenantRightId']),
                        a!save(ri!projectLocation['recordType!{27334095-47d5-4486-897d-e61f2c02b0fa}GF Project Plan Location.relationships.{b2a233ce-de5d-4abb-8641-e5ab9f7cc367}gfProjectPlanLocationInput.fields.{8efcab4d-e2c2-4b42-81af-5e8816315119}isLandowner'], local!prepopulatedData['recordType!{27334095-47d5-4486-897d-e61f2c02b0fa}GF Project Plan Location.relationships.{b2a233ce-de5d-4abb-8641-e5ab9f7cc367}gfProjectPlanLocationInput.fields.{8efcab4d-e2c2-4b42-81af-5e8816315119}isLandowner']),
                        a!save(ri!projectLocation['recordType!{27334095-47d5-4486-897d-e61f2c02b0fa}GF Project Plan Location.relationships.{b2a233ce-de5d-4abb-8641-e5ab9f7cc367}gfProjectPlanLocationInput.fields.{e7e77ed4-6672-4535-8745-4e188417870b}landOwnerEasementObtained'], local!prepopulatedData['recordType!{27334095-47d5-4486-897d-e61f2c02b0fa}GF Project Plan Location.relationships.{b2a233ce-de5d-4abb-8641-e5ab9f7cc367}gfProjectPlanLocationInput.fields.{e7e77ed4-6672-4535-8745-4e188417870b}landOwnerEasementObtained']),
                        a!save(ri!projectLocation['recordType!{27334095-47d5-4486-897d-e61f2c02b0fa}GF Project Plan Location.relationships.{b2a233ce-de5d-4abb-8641-e5ab9f7cc367}gfProjectPlanLocationInput.fields.{8a263249-2671-4bc2-a949-0fff33a49dd0}authorization'], local!prepopulatedData['recordType!{27334095-47d5-4486-897d-e61f2c02b0fa}GF Project Plan Location.relationships.{b2a233ce-de5d-4abb-8641-e5ab9f7cc367}gfProjectPlanLocationInput.fields.{8a263249-2671-4bc2-a949-0fff33a49dd0}authorization']),
                        a!save(ri!projectLocation['recordType!{27334095-47d5-4486-897d-e61f2c02b0fa}GF Project Plan Location.relationships.{b2a233ce-de5d-4abb-8641-e5ab9f7cc367}gfProjectPlanLocationInput.fields.{c1ddfea3-fd09-4953-8325-2dd8443f95b9}permits'], local!prepopulatedData['recordType!{27334095-47d5-4486-897d-e61f2c02b0fa}GF Project Plan Location.relationships.{b2a233ce-de5d-4abb-8641-e5ab9f7cc367}gfProjectPlanLocationInput.fields.{c1ddfea3-fd09-4953-8325-2dd8443f95b9}permits']),
                        a!save(ri!projectLocation['recordType!{27334095-47d5-4486-897d-e61f2c02b0fa}GF Project Plan Location.relationships.{b2a233ce-de5d-4abb-8641-e5ab9f7cc367}gfProjectPlanLocationInput.fields.{ae530101-526e-4d43-9061-60e62e9d6341}zoningRestrictionId'], local!prepopulatedData['recordType!{27334095-47d5-4486-897d-e61f2c02b0fa}GF Project Plan Location.relationships.{b2a233ce-de5d-4abb-8641-e5ab9f7cc367}gfProjectPlanLocationInput.fields.{ae530101-526e-4d43-9061-60e62e9d6341}zoningRestrictionId']),
                        a!save(ri!projectLocation['recordType!{27334095-47d5-4486-897d-e61f2c02b0fa}GF Project Plan Location.relationships.{b2a233ce-de5d-4abb-8641-e5ab9f7cc367}gfProjectPlanLocationInput.fields.{0b920b80-fbdd-4cc4-821d-ae5859e4ebf0}zoningExplanation'], local!prepopulatedData['recordType!{27334095-47d5-4486-897d-e61f2c02b0fa}GF Project Plan Location.relationships.{b2a233ce-de5d-4abb-8641-e5ab9f7cc367}gfProjectPlanLocationInput.fields.{0b920b80-fbdd-4cc4-821d-ae5859e4ebf0}zoningExplanation'])
    
    
                      }
    
                    ),
                    showWhen: a!isNotNullOrEmpty(local!prepopulatedData)
                  )
    
    
                }
              ),

  • 0
    Certified Associate Developer
    in reply to Tamara Saadeh

    It seems the issue with the checkbox field lies in the value and saveinto parameters. If ri!inputValues is an array, you should use the current index in both value and saveinto.

Reply Children
No Data