Hi! I have created the following editable grid:
Appart from the fields shown in the editable grid, I would like to create for each row a CONCAT() from two fields (idPedido, Material), BUT NOT SHOW IT IN THE EDITABLE GRID, only saving it into my local variable
I´ve tried with the following code but when I try to add a new row an error appears: fv!item not detected (line 189). Is my approach of trying to save it in the append correct? In case it is correct, how can I fix the code and the fv!item? If not, which is the best way to save it in the local variable or another way?
Thanks a lot!
a!localVariables( local!LineasPedido: {}, { a!sectionLayout( label: "Líneas Pedido", labelIcon: "list-alt-solid", contents: { a!gridLayout( label: "A continuación, incorpore las líneas de pedido correspondientes y pulse el botón de creación", headerCells: { a!gridLayoutHeaderCell(label: "Linea Pedido"), a!gridLayoutHeaderCell(label: "Pedido"), a!gridLayoutHeaderCell(label: "Proveedor"), a!gridLayoutHeaderCell(label: "Material"), a!gridLayoutHeaderCell(label: "Cantidad"), a!gridLayoutHeaderCell(label: "Precio Unitario"), a!gridLayoutHeaderCell(label: "Importe Total"), a!gridLayoutHeaderCell() }, columnConfigs: { a!gridLayoutColumnConfig(width: "DISTRIBUTE"), a!gridLayoutColumnConfig(width: "DISTRIBUTE"), a!gridLayoutColumnConfig(width: "DISTRIBUTE"), a!gridLayoutColumnConfig(width: "DISTRIBUTE"), a!gridLayoutColumnConfig(width: "DISTRIBUTE"), a!gridLayoutColumnConfig(width: "DISTRIBUTE"), a!gridLayoutColumnConfig(width: "DISTRIBUTE"), a!gridLayoutColumnConfig(width: "ICON") }, rows: a!forEach( items: local!LineasPedido, expression: a!gridRowLayout( contents: { a!textField( value: fv!item['recordType!{495578a9-1b23-4253-8145-6418faabe727}CPF Lineas Pedido.fields.{fcfa4b36-4398-4430-8055-ecfa59daf13a}idLineaPedido'], saveInto: { fv!item['recordType!{495578a9-1b23-4253-8145-6418faabe727}CPF Lineas Pedido.fields.{fcfa4b36-4398-4430-8055-ecfa59daf13a}idLineaPedido'] } ), a!textField( value: fv!item['recordType!{495578a9-1b23-4253-8145-6418faabe727}CPF Lineas Pedido.fields.{71427dbb-12db-4f83-bd99-f625bf9af271}idPedido'], saveInto: { fv!item['recordType!{495578a9-1b23-4253-8145-6418faabe727}CPF Lineas Pedido.fields.{71427dbb-12db-4f83-bd99-f625bf9af271}idPedido'] } ), a!textField( value: fv!item['recordType!{495578a9-1b23-4253-8145-6418faabe727}CPF Lineas Pedido.fields.{464f0883-d6d5-4c58-b054-4de8e9e99902}Proveedor'], saveInto: { fv!item['recordType!{495578a9-1b23-4253-8145-6418faabe727}CPF Lineas Pedido.fields.{464f0883-d6d5-4c58-b054-4de8e9e99902}Proveedor'] } ), a!textField( value: fv!item['recordType!{495578a9-1b23-4253-8145-6418faabe727}CPF Lineas Pedido.fields.{69e9a834-b2fb-4f35-a36d-3c526c97f4ac}Material'], saveInto: { fv!item['recordType!{495578a9-1b23-4253-8145-6418faabe727}CPF Lineas Pedido.fields.{69e9a834-b2fb-4f35-a36d-3c526c97f4ac}Material'] } ), a!integerField( value: fv!item['recordType!{495578a9-1b23-4253-8145-6418faabe727}CPF Lineas Pedido.fields.{e78c5b35-026f-4713-8404-05077c6c9152}Cantidad'], saveInto: { fv!item['recordType!{495578a9-1b23-4253-8145-6418faabe727}CPF Lineas Pedido.fields.{e78c5b35-026f-4713-8404-05077c6c9152}Cantidad'], a!save( fv!item['recordType!{495578a9-1b23-4253-8145-6418faabe727}CPF Lineas Pedido.fields.{beb59a89-a332-46d3-b718-a8285f58f942}Importe'], if( or( isnull( fv!item['recordType!{495578a9-1b23-4253-8145-6418faabe727}CPF Lineas Pedido.fields.{e78c5b35-026f-4713-8404-05077c6c9152}Cantidad'] ), isnull( fv!item['recordType!{495578a9-1b23-4253-8145-6418faabe727}CPF Lineas Pedido.fields.{47f4bf32-2e41-4c5a-a7e7-9fc7786bd753}PrecioUnit'] ) ), 0, fv!item['recordType!{495578a9-1b23-4253-8145-6418faabe727}CPF Lineas Pedido.fields.{e78c5b35-026f-4713-8404-05077c6c9152}Cantidad'] * fv!item['recordType!{495578a9-1b23-4253-8145-6418faabe727}CPF Lineas Pedido.fields.{47f4bf32-2e41-4c5a-a7e7-9fc7786bd753}PrecioUnit'] ) ) }, required: true, validations: { if( a!isNotNullOrEmpty( fv!item['recordType!{495578a9-1b23-4253-8145-6418faabe727}CPF Lineas Pedido.fields.{e78c5b35-026f-4713-8404-05077c6c9152}Cantidad'] ) = false, "", if( fv!item['recordType!{495578a9-1b23-4253-8145-6418faabe727}CPF Lineas Pedido.fields.{e78c5b35-026f-4713-8404-05077c6c9152}Cantidad'] < 1, "La cantidad debe ser superior a cero", "" ) ) } ), a!floatingPointField( value: fv!item['recordType!{495578a9-1b23-4253-8145-6418faabe727}CPF Lineas Pedido.fields.{47f4bf32-2e41-4c5a-a7e7-9fc7786bd753}PrecioUnit'], saveInto: { fv!item['recordType!{495578a9-1b23-4253-8145-6418faabe727}CPF Lineas Pedido.fields.{47f4bf32-2e41-4c5a-a7e7-9fc7786bd753}PrecioUnit'], a!save( fv!item['recordType!{495578a9-1b23-4253-8145-6418faabe727}CPF Lineas Pedido.fields.{beb59a89-a332-46d3-b718-a8285f58f942}Importe'], if( or( isnull( fv!item['recordType!{495578a9-1b23-4253-8145-6418faabe727}CPF Lineas Pedido.fields.{e78c5b35-026f-4713-8404-05077c6c9152}Cantidad'] ), isnull( fv!item['recordType!{495578a9-1b23-4253-8145-6418faabe727}CPF Lineas Pedido.fields.{47f4bf32-2e41-4c5a-a7e7-9fc7786bd753}PrecioUnit'] ) ), 0, fv!item['recordType!{495578a9-1b23-4253-8145-6418faabe727}CPF Lineas Pedido.fields.{e78c5b35-026f-4713-8404-05077c6c9152}Cantidad'] * fv!item['recordType!{495578a9-1b23-4253-8145-6418faabe727}CPF Lineas Pedido.fields.{47f4bf32-2e41-4c5a-a7e7-9fc7786bd753}PrecioUnit'] ) ) }, required: true, validations: { if( a!isNotNullOrEmpty( fv!item['recordType!{495578a9-1b23-4253-8145-6418faabe727}CPF Lineas Pedido.fields.{47f4bf32-2e41-4c5a-a7e7-9fc7786bd753}PrecioUnit'] ) = false, "", if( fv!item['recordType!{495578a9-1b23-4253-8145-6418faabe727}CPF Lineas Pedido.fields.{47f4bf32-2e41-4c5a-a7e7-9fc7786bd753}PrecioUnit'] < 0, "El precio unitario debe ser superior a cero", "" ) ) } ), a!floatingPointField( value: if( or( isnull( fv!item['recordType!{495578a9-1b23-4253-8145-6418faabe727}CPF Lineas Pedido.fields.{e78c5b35-026f-4713-8404-05077c6c9152}Cantidad'] ), isnull( fv!item['recordType!{495578a9-1b23-4253-8145-6418faabe727}CPF Lineas Pedido.fields.{47f4bf32-2e41-4c5a-a7e7-9fc7786bd753}PrecioUnit'] ) ), 0, fv!item['recordType!{495578a9-1b23-4253-8145-6418faabe727}CPF Lineas Pedido.fields.{e78c5b35-026f-4713-8404-05077c6c9152}Cantidad'] * fv!item['recordType!{495578a9-1b23-4253-8145-6418faabe727}CPF Lineas Pedido.fields.{47f4bf32-2e41-4c5a-a7e7-9fc7786bd753}PrecioUnit'] ), saveInto: { fv!item['recordType!{495578a9-1b23-4253-8145-6418faabe727}CPF Lineas Pedido.fields.{beb59a89-a332-46d3-b718-a8285f58f942}Importe'] }, required: true, validations: { if( a!isNotNullOrEmpty( fv!item['recordType!{495578a9-1b23-4253-8145-6418faabe727}CPF Lineas Pedido.fields.{beb59a89-a332-46d3-b718-a8285f58f942}Importe'] ) = false, "", if( fv!item['recordType!{495578a9-1b23-4253-8145-6418faabe727}CPF Lineas Pedido.fields.{beb59a89-a332-46d3-b718-a8285f58f942}Importe'] < 0, "El importe debe ser superior a cero", "" ) ) }, align: "RIGHT" ), a!richTextDisplayField( value: { a!richTextIcon( icon: "times-circle", link: a!dynamicLink( value: remove(local!LineasPedido, fv!index), saveInto: local!LineasPedido ), linkstyle: "STANDALONE", color: "NEGATIVE" ) } ) } ) ), addrowlink: a!dynamicLink( label: "Añadir nueva Línea de Pedido", saveInto: a!save( target: local!LineasPedido, value: append( local!LineasPedido, 'recordType!{495578a9-1b23-4253-8145-6418faabe727}CPF Lineas Pedido'( 'recordType!{495578a9-1b23-4253-8145-6418faabe727}CPF Lineas Pedido.fields.{71427dbb-12db-4f83-bd99-f625bf9af271}idPedido': ri!record['recordType!{3c95c0e4-e69d-43f6-b485-e72b24252af7}CPF Maestro Pedidos.fields.{7309402c-2312-4a4e-bdaa-5654789bffb2}idPedido'], 'recordType!{495578a9-1b23-4253-8145-6418faabe727}CPF Lineas Pedido.fields.{464f0883-d6d5-4c58-b054-4de8e9e99902}Proveedor': ri!record['recordType!{3c95c0e4-e69d-43f6-b485-e72b24252af7}CPF Maestro Pedidos.fields.{e11e6206-fc23-4a4b-9819-4db5a5bab685}nomProveedor'], 'recordType!{495578a9-1b23-4253-8145-6418faabe727}CPF Lineas Pedido.fields.{121ba298-9b36-4826-a191-72811974ee3c}createdOn': now() + intervalds(2, 0, 0), 'recordType!{495578a9-1b23-4253-8145-6418faabe727}CPF Lineas Pedido.fields.{4d0599e0-d6d6-4ad2-9a4a-8e7f3c270de9}createdBy': loggedInUser(), 'recordType!{495578a9-1b23-4253-8145-6418faabe727}CPF Lineas Pedido.fields.{fcfa4b36-4398-4430-8055-ecfa59daf13a}idLineaPedido': count({ local!LineasPedido }) + 1, 'recordType!{495578a9-1b23-4253-8145-6418faabe727}CPF Lineas Pedido.fields.{caf81eeb-f499-4adc-b078-f2692f6e38b2}ConcatPedidoMaterial': concat( fv!item['recordType!{495578a9-1b23-4253-8145-6418faabe727}CPF Lineas Pedido.fields.{71427dbb-12db-4f83-bd99-f625bf9af271}idPedido'], "-", fv!item['recordType!{495578a9-1b23-4253-8145-6418faabe727}CPF Lineas Pedido.fields.{69e9a834-b2fb-4f35-a36d-3c526c97f4ac}Material'] ) ) ) ) ) ) } ), a!buttonLayout( primaryButtons: { a!buttonWidget( label: "Completar Creación Pedido", saveInto: a!save( ri!recordLineasPedido, local!LineasPedido ), submit: true, style: "PRIMARY", validate: true ) }, secondaryButtons: { a!buttonWidget( label: "Cancelar", value: true, saveInto: ri!cancel2, submit: true, style: "NORMAL", validate: false ) } ) } )
Discussion posts and replies are publicly visible
If the values for the two source fields aren't being defined until the user fills them in, then trying to create the "concat" field upon Row Creation is useless, as it'll just be an empty value. The place to do the concat operation would be in the saveInto of both affected fields.