We have 3 records in our application say record A, record B and record C. Record A is having one to many relation with record B where record B is having one to many relation with record C. Record A is having generic details, record B is having section details which can be multiple and record C is having one editable grid having multiple entries which is present in the above section. We are facing issue while displaying and saving the value into the rule input since we are not able to use [fv!index] for record variables. We are using only one rule input of record type A. How to make sure to show the values properly and save them properly?? This is just a mock UI i created for explaining the issue. Add member will add one more row in developer details grid. Add Team will repeat the whole section again.
Discussion posts and replies are publicly visible
I hope this quick example helps
Hi Stefan,I am assuming this example is between 2 records having one to many relationship. Can you please let me know how to extend the same logic for 3 records where 1st record is having one to many relationship with 2nd record and 2nd record is having one to many relationship with 3rd record?
It's the same logic. Just treat the relationship like a field and store your list of records to it.
I tried to replicate the same logic but I am getting some error. Can you let me know if I am following the correct step? Attaching code and error screenshot for reference
a!localVariables( local!companyDetails: 'recordType!{8a6434de-961a-4353-8d0b-a839f5e2550a}WTA Company Details'( 'recordType!{8a6434de-961a-4353-8d0b-a839f5e2550a}WTA Company Details.relationships.{252cc54f-351a-40c4-b5ec-9d03b93d6b71}wtaManagerDetails': 'recordType!{43f22b1a-0375-4d5d-be0b-b660b9e6583c}WTA Manager Details'( 'recordType!{43f22b1a-0375-4d5d-be0b-b660b9e6583c}WTA Manager Details.fields.{a23cf196-9063-46d9-99dc-2ee2241f7499}managerName': "", 'recordType!{43f22b1a-0375-4d5d-be0b-b660b9e6583c}WTA Manager Details.relationships.{1754fbb4-0f53-4c42-98d4-1b7efecaf226}wtaDeveloperDetails': 'recordType!{b1ea8073-bc4b-4054-b4bb-9a8dfc3ce0d5}WTA Developer Details'( 'recordType!{b1ea8073-bc4b-4054-b4bb-9a8dfc3ce0d5}WTA Developer Details.fields.{97fa912d-c1b3-4e67-8256-552882f4693c}developerName': "" ) ) ), { a!sectionLayout( label: "Team Details", contents: { a!forEach( items: local!companyDetails['recordType!{8a6434de-961a-4353-8d0b-a839f5e2550a}WTA Company Details.relationships.{252cc54f-351a-40c4-b5ec-9d03b93d6b71}wtaManagerDetails'], expression: a!localVariables( local!managerIndex: fv!item, local!index: fv!index, { a!columnsLayout( columns: { a!columnLayout( contents: { a!textField( label: "Manager Name", labelPosition: "ABOVE", saveInto: {}, refreshAfter: "UNFOCUS", validations: {} ) } ), a!columnLayout( contents: { a!textField( label: "Manager Number", labelPosition: "ABOVE", saveInto: {}, refreshAfter: "UNFOCUS", validations: {} ) } ) } ), a!gridLayout( label: "Developer Details", labelPosition: "ABOVE", headerCells: { a!gridLayoutHeaderCell(label: "Name"), a!gridLayoutHeaderCell(label: "Mobile No") }, columnConfigs: {}, rows: { a!forEach( items: local!managerIndex['recordType!{43f22b1a-0375-4d5d-be0b-b660b9e6583c}WTA Manager Details.relationships.{1754fbb4-0f53-4c42-98d4-1b7efecaf226}wtaDeveloperDetails'], expression: a!gridRowLayout( contents: { a!textField( value: fv!item['recordType!{b1ea8073-bc4b-4054-b4bb-9a8dfc3ce0d5}WTA Developer Details.fields.{97fa912d-c1b3-4e67-8256-552882f4693c}developerName'], saveInto: { fv!item['recordType!{b1ea8073-bc4b-4054-b4bb-9a8dfc3ce0d5}WTA Developer Details.fields.{97fa912d-c1b3-4e67-8256-552882f4693c}developerName'], a!save( local!companyDetails['recordType!{8a6434de-961a-4353-8d0b-a839f5e2550a}WTA Company Details.relationships.{252cc54f-351a-40c4-b5ec-9d03b93d6b71}wtaManagerDetails.relationships.{1754fbb4-0f53-4c42-98d4-1b7efecaf226}wtaDeveloperDetails'], append( local!companyDetails['recordType!{8a6434de-961a-4353-8d0b-a839f5e2550a}WTA Company Details.relationships.{252cc54f-351a-40c4-b5ec-9d03b93d6b71}wtaManagerDetails.relationships.{1754fbb4-0f53-4c42-98d4-1b7efecaf226}wtaDeveloperDetails'], 'recordType!{b1ea8073-bc4b-4054-b4bb-9a8dfc3ce0d5}WTA Developer Details'( 'recordType!{b1ea8073-bc4b-4054-b4bb-9a8dfc3ce0d5}WTA Developer Details.fields.{97fa912d-c1b3-4e67-8256-552882f4693c}developerName': fv!item['recordType!{b1ea8073-bc4b-4054-b4bb-9a8dfc3ce0d5}WTA Developer Details.fields.{97fa912d-c1b3-4e67-8256-552882f4693c}developerName'], ) ) ) } ), a!textField( value: fv!item['recordType!{b1ea8073-bc4b-4054-b4bb-9a8dfc3ce0d5}WTA Developer Details.fields.{17f5b725-96de-4ba4-850a-a4890c5b0a14}developerDesignation'], saveInto: fv!item['recordType!{b1ea8073-bc4b-4054-b4bb-9a8dfc3ce0d5}WTA Developer Details.fields.{17f5b725-96de-4ba4-850a-a4890c5b0a14}developerDesignation'] ), } ) ) }, selectionSaveInto: {}, validations: {}, shadeAlternateRows: true, addRowLink: a!dynamicLink( label: "Add Member", saveInto: { a!save( local!managerIndex['recordType!{43f22b1a-0375-4d5d-be0b-b660b9e6583c}WTA Manager Details.relationships.{1754fbb4-0f53-4c42-98d4-1b7efecaf226}wtaDeveloperDetails'], append( local!managerIndex['recordType!{43f22b1a-0375-4d5d-be0b-b660b9e6583c}WTA Manager Details.relationships.{1754fbb4-0f53-4c42-98d4-1b7efecaf226}wtaDeveloperDetails'], 'recordType!{b1ea8073-bc4b-4054-b4bb-9a8dfc3ce0d5}WTA Developer Details'() ) ), /*a!update(*/ /*local!companyDetails*/ /*local!index,*/ /* */ /*)*/ } ) ) } ) ), a!linkField( links: { a!dynamicLink( label: "+ Add Team", value: 'recordType!{43f22b1a-0375-4d5d-be0b-b660b9e6583c}WTA Manager Details'(), saveInto: a!save( local!companyDetails['recordType!{8a6434de-961a-4353-8d0b-a839f5e2550a}WTA Company Details.relationships.{252cc54f-351a-40c4-b5ec-9d03b93d6b71}wtaManagerDetails'], append( local!companyDetails['recordType!{8a6434de-961a-4353-8d0b-a839f5e2550a}WTA Company Details.relationships.{252cc54f-351a-40c4-b5ec-9d03b93d6b71}wtaManagerDetails'], save!value ) ) ) } ) } ) } )
You commented the only a!update in the code, and I do not understand what you are trying to do here.
On click on Add member link, it will create a new row and append developer record. When Add team link is clicked, it will append a manager record and the whole section will get repeated. Its like a variable having an array variable where that variable is having another array variable - 3 levels of nesting
I spent the time to make your code work for me. The main issue is, that your did not create lists for the relationships in which you want to append items to.
a!localVariables( local!companyDetails: a!map( wtaManagerDetails: { /* This must be a list ! */ a!map( managerName: "", wtaDeveloperDetails: { /* This must be a list ! */ a!map( developerName: "" ) } ) } ), { a!sectionLayout( label: "Team Details", contents: { a!forEach( items: local!companyDetails["wtaManagerDetails"], expression: a!localVariables( local!managerItem: fv!item, { a!columnsLayout( columns: { a!columnLayout( contents: { a!textField( label: "Manager Name", labelPosition: "ABOVE", value: fv!item["managerName"], saveInto: fv!item["managerName"], ) } ), a!columnLayout( contents: { a!textField( label: "Manager Number", labelPosition: "ABOVE", value: fv!item["managerNumber"], saveInto: fv!item["managerNumber"], ) } ) } ), a!gridLayout( label: "Developer Details", labelPosition: "ABOVE", headerCells: { a!gridLayoutHeaderCell(label: "Name"), a!gridLayoutHeaderCell(label: "Mobile No") }, columnConfigs: {}, rows: { a!forEach( items: local!managerItem["wtaDeveloperDetails"], expression: a!gridRowLayout( contents: { a!textField( value: fv!item["developerName"], saveInto: fv!item["developerName"], ), a!textField( value: fv!item["developerDesignation"], saveInto: fv!item[""] ), } ) ) }, selectionSaveInto: {}, validations: {}, shadeAlternateRows: true, addRowLink: a!dynamicLink( label: "Add Member", saveInto: { a!save( local!managerItem["wtaDeveloperDetails"], append( local!managerItem["wtaDeveloperDetails"], a!map() ) ), } ) ) } ) ), a!linkField( links: { a!dynamicLink( label: "+ Add Team", saveInto: a!save( local!companyDetails["wtaManagerDetails"], append( local!companyDetails["wtaManagerDetails"], a!map() ) ) ) } ) } ) } )