I using a record relationship (1 - Many) (Dept -- Employee (multiple)). I am trying to create a interface, where in top grab the Dept details and in bottom Employee details for that Department , which is Editable grid. When I try to addRowLink - its not creating a new row. Pls see the code below and let me know , what is the issue.
a!localVariables( local!emp : 'recordType!{f4411d12-5d9e-43b0-9eb3-430ef2ea01b9}Emp.fields.{a808753b-fbba-4fd9-bd49-058256eae7a2}empno' : "", local!empnme : 'recordType!{f4411d12-5d9e-43b0-9eb3-430ef2ea01b9}Emp.fields.{62b2206f-9897-4495-9957-8fc3c3a6253a}ename': "", local!job : 'recordType!{f4411d12-5d9e-43b0-9eb3-430ef2ea01b9}Emp.fields.{47784a4a-362f-4104-a42d-4762074fddec}job':"", local!sal : 'recordType!{f4411d12-5d9e-43b0-9eb3-430ef2ea01b9}Emp.fields.{2d76dd3c-1e76-4924-af64-24652c4f3b4f}sal':"", a!formLayout( label: "Department & Employee Relationship", contents: { a!sectionLayout( label: "Department", contents: { a!textField( label: "Department No", labelPosition: "ADJACENT", value: ri!Dept['recordType!{52f2ed75-d5b5-46ce-b6ec-43c3a900feb1}Department.fields.{cde21b2f-05db-4f33-ac0c-e062d24a1f17}deptno'], saveInto: {ri!Dept['recordType!{52f2ed75-d5b5-46ce-b6ec-43c3a900feb1}Department.fields.{cde21b2f-05db-4f33-ac0c-e062d24a1f17}deptno']}, refreshAfter: "UNFOCUS", validations: {} ), a!textField( label: "Department Name", labelPosition: "ADJACENT", value : ri!Dept['recordType!{52f2ed75-d5b5-46ce-b6ec-43c3a900feb1}Department.fields.{5f09405f-001c-41c3-bc2e-5524c0f97428}dname'], saveInto: {ri!Dept['recordType!{52f2ed75-d5b5-46ce-b6ec-43c3a900feb1}Department.fields.{5f09405f-001c-41c3-bc2e-5524c0f97428}dname']}, refreshAfter: "UNFOCUS", validations: {} ), a!sectionLayout( label: "Employee Details", contents: { a!gridLayout( label: "", labelPosition: "ABOVE", headerCells: { a!gridLayoutHeaderCell(label: "Employee Number"), a!gridLayoutHeaderCell(label: "Employee Name"), a!gridLayoutHeaderCell(label: "Job"), a!gridLayoutHeaderCell(label: "Salary") }, columnConfigs: {}, rows: { a!forEach( items : ri!Dept['recordType!{52f2ed75-d5b5-46ce-b6ec-43c3a900feb1}Department.relationships.{71959808-8139-4958-b7aa-0ad4bdc3b517}DeptToEmployee'], expression: a!gridRowLayout( contents: { a!textField( label : "Employee Number", value: fv!item['recordType!{f4411d12-5d9e-43b0-9eb3-430ef2ea01b9}Emp.fields.{a808753b-fbba-4fd9-bd49-058256eae7a2}empno'], saveInto: fv!item['recordType!{f4411d12-5d9e-43b0-9eb3-430ef2ea01b9}Emp.fields.{a808753b-fbba-4fd9-bd49-058256eae7a2}empno'] ), a!textField( label : "Employee Name", value: fv!item['recordType!{f4411d12-5d9e-43b0-9eb3-430ef2ea01b9}Emp.fields.{62b2206f-9897-4495-9957-8fc3c3a6253a}ename'], saveInto: fv!item['recordType!{f4411d12-5d9e-43b0-9eb3-430ef2ea01b9}Emp.fields.{62b2206f-9897-4495-9957-8fc3c3a6253a}ename'] ), a!textField( label : "Job", value: fv!item['recordType!{f4411d12-5d9e-43b0-9eb3-430ef2ea01b9}Emp.fields.{47784a4a-362f-4104-a42d-4762074fddec}job'], saveInto: fv!item['recordType!{f4411d12-5d9e-43b0-9eb3-430ef2ea01b9}Emp.fields.{47784a4a-362f-4104-a42d-4762074fddec}job'] ), a!textField( label : "Salary", value: fv!item['recordType!{f4411d12-5d9e-43b0-9eb3-430ef2ea01b9}Emp.fields.{2d76dd3c-1e76-4924-af64-24652c4f3b4f}sal'], saveInto: fv!item['recordType!{f4411d12-5d9e-43b0-9eb3-430ef2ea01b9}Emp.fields.{2d76dd3c-1e76-4924-af64-24652c4f3b4f}sal'] ) } ) ) }, addRowLink: a!dynamicLink( label : "Add Employee", saveInto: { a!save(ri!Emp,append('recordType!{f4411d12-5d9e-43b0-9eb3-430ef2ea01b9}Emp.fields.{a808753b-fbba-4fd9-bd49-058256eae7a2}empno',local!emp)), a!save(ri!Emp,append('recordType!{f4411d12-5d9e-43b0-9eb3-430ef2ea01b9}Emp.fields.{62b2206f-9897-4495-9957-8fc3c3a6253a}ename',local!empnme)), a!save(ri!Emp,append('recordType!{f4411d12-5d9e-43b0-9eb3-430ef2ea01b9}Emp.fields.{47784a4a-362f-4104-a42d-4762074fddec}job',local!job)), a!save(ri!Emp,append('recordType!{f4411d12-5d9e-43b0-9eb3-430ef2ea01b9}Emp.fields.{2d76dd3c-1e76-4924-af64-24652c4f3b4f}sal',local!sal)),} ), selectionSaveInto: {}, validations: {}, rowHeader: 1, shadeAlternateRows: true ) } ) } ) }, buttons: a!buttonLayout( primaryButtons: { a!buttonWidget( label: "Submit", submit: true, style: "PRIMARY", loadingIndicator: true ) }, secondaryButtons: { a!buttonWidget( label: "Cancel", value: true, saveInto: {}, submit: true, style: "NORMAL", validate: false ) } )))
Discussion posts and replies are publicly visible
The issue with the addRowLink is that it is not saving the new employee record into the database. The saveInto property of the addRowLink is using the append() function to create a new record in memory, but it is not actually persisting the record to the database. You need to use the insert() function elastic man instead of the append() function. The insert() function takes the record type and the record values as arguments, and it persists the record to the database.
!!!!! ATTENTION !!!!!!!
"The insert() function takes the record type and the record values as arguments, and it persists the record to the database."
THIS IS COMPLETE NONSENSE! THE insert() FUNCTION DOES NOT INSERT ANYTHING INTO ANY DATABASE!!!!!
Unknown said:THIS IS COMPLETE NONSENSE! THE insert() FUNCTION DOES NOT INSERT ANYTHING INTO ANY DATABASE!!!!!
ChatGPT strikes again, maybe?