Editable Grid Problem

Hi all,

Could somebody tell me what is wrong with this code:

 

a!gridLayout(
 totalCount: count(local!data),
 headerCells: {
   a!gridLayoutHeaderCell(label: "Datum" ),
   a!gridLayoutHeaderCell(label: "Oznaka" ),
   a!gridLayoutHeaderCell(label: "Sreden" ),
   a!gridLayoutHeaderCell(label: "DrzavaAng" ),
   a!gridLayoutHeaderCell(label: "NazivAng" ),
   a!gridLayoutHeaderCell(label: "" )
 },
 columnConfigs: {
   a!gridLayoutColumnConfig(width: "DISTRIBUTE", weight:3 ),
   a!gridLayoutColumnConfig(width: "DISTRIBUTE", weight:3 ),
   a!gridLayoutColumnConfig(width: "DISTRIBUTE", weight:3 ),
   a!gridLayoutColumnConfig(width: "DISTRIBUTE", weight:3 ),
   a!gridLayoutColumnConfig(width: "DISTRIBUTE", weight:3 ),
   a!gridLayoutColumnConfig(width: "ICON")
 },
 rows: a!forEach(
   items: local!data,
   expression: a!gridRowLayout(
     id: fv!index,
     contents: {
       a!textField(
         label: "Datum "& fv!index ,
         value: fv!item.Datum,
         saveInto: fv!item.Datum,
         required: true
       ),
       a!textField(
         label: "Oznaka " & fv!index,
         value: fv!item.Oznaka,
         saveInto: fv!item.Oznaka,
         required:true
       ),
       a!textField(
         label: "Sreden" & fv!index,
         value: fv!item.Sreden,
         saveInto: fv!item.Sreden,
         required:true
       ),
       a!textField(
         label: "DrzavaAng" & fv!index,
         value: fv!item.DrzavaAng,
         saveInto: fv!item.DrzavaAng,
         required:true
       ),
       a!textField(
         label: "Naziv Ang." & fv!index,
         value: fv!item.NazivAng,
         saveInto: fv!item.NazivAng,
         required:true
       ),
       a!imageField(
                label: "delete " & fv!index,
                images: a!documentImage(
                  document: a!iconIndicator("REMOVE"),
                  altText: "Remove Entry",
                  caption: "Remove " & fv!item.Oznaka,
                  link: a!dynamicLink(
                    value: fv!index,
                    saveInto: {
                      a!save(local!data, remove(local!data, save!value))
                    }
                  )
                ),
                size: "ICON"
              )
     }
   ),
   addRowlink: a!dynamicLink(
    label: "Add Entry",
    saveInto: {
     a!save(local!data, append(local!data, save!value))
    }
 )
)

 

The error on test that it generated, when I add new row is :

 

Could not display interface. Please check definition and inputs. Interface Definition: Expression evaluation error at function a!forEach [line 102]: Error in a!forEach() expression during iteration 1: Expression evaluation error at function a!dateTimeField [line 107]: Invalid index: Cannot index property 'Datum' of type Text into type DataSubset

 

And when I try to remove it remove the whole table with the Remove Icon on the first row.

 

Thanks in advance,Natasa

 

 

  Discussion posts and replies are publicly visible

Parents
  • I change fv!item.X with fvitem.data.X everywhere and now new error appear:
    nterface Definition: Expression evaluation error at function a!forEach [line 102]: Error in a!forEach() expression during iteration 1 with identifier 1: Expression evaluation error at function a!dateTimeField [line 107]: Invalid index: Cannot index property 'data' of type Text into type Kurs_Zbir

    Kurs_Zbir is the name of CDT.

    Any other suggestions?
  • Please share your entire code snippet?
  • The whole code:

    load(
    local!paging: a!pagingInfo(
    startIndex: 1,
    batchSize: 5,
    sort: a!sortInfo(
    field: "Datum",
    ascending: true
    )
    ),
    local!data:with(local!data, todatasubset({ri!Echange_rate_table}, local!paging
    )
    ),
    local!documentsToken,
    local!oldAttachments: if(
    or(isnull(ri!documents), count(ri!documents) < 1),
    0,
    length(ri!documents)
    ),

    a!formLayout(
    label: "PoC Start Form",
    instructions: "",
    contents: {
    a!sectionLayout(
    label: "PoC Input data",
    contents: {
    a!textField(
    label: "Process Name",
    labelPosition: "ABOVE",
    value: ri!PoC_Details.Process_Name,
    saveInto: ri!PoC_Details.Process_Name,
    refreshAfter: "UNFOCUS",
    required: true,
    validations: {}
    ),
    a!textField(
    label: "Description",
    labelPosition: "ABOVE",
    value: ri!PoC_Details.Description,
    saveInto: ri!PoC_Details.Description,
    refreshAfter: "UNFOCUS",
    validations: {}
    ),
    a!dropdownField(
    label: "Month",
    labelPosition: "ABOVE",
    placeholderLabel: "--- Select a Value ---",
    choiceLabels: {"Jan", "Feb","Mart"},
    choiceValues: {"Jan", "Feb","Mart"},
    value: ri!PoC_Details.Month,
    saveInto:ri!PoC_Details.Month,
    validations: {}
    ),
    a!integerField(
    label: "Year",
    labelPosition: "ABOVE",
    value: ri!PoC_Details.Year,
    saveInto: ri!PoC_Details.Year,
    refreshAfter: "UNFOCUS",
    validations: if(len(ri!PoC_Details.Year)<=4,null,"Your year data is not in appropriate format, only 4 characters are allow")
    ),
    a!textField(
    label: "Author Full Name",
    labelPosition: "ABOVE",
    value: ri!My_Sql_Name&" "&ri!My_Sql_Lastname,
    saveInto: ri!PoC_Details.Author_Full_Name,
    refreshAfter: "UNFOCUS",
    readonly: true,
    validations: {}
    ),
    a!textField(
    label: "Comment",
    labelPosition: "ABOVE",
    value: ri!My_Sql_Lastname,
    saveInto: {},
    refreshAfter: "UNFOCUS",
    masked: false,
    validations: {}
    )
    },
    iscollapsible: true
    ),
    a!sectionLayout(
    label: "Echange rate table",
    contents: {
    a!gridLayout(
    totalCount: count(local!data),
    headerCells: {
    a!gridLayoutHeaderCell(label: "Datum" ),
    a!gridLayoutHeaderCell(label: "Oznaka" ),
    a!gridLayoutHeaderCell(label: "Sreden" ),
    a!gridLayoutHeaderCell(label: "DrzavaAng" ),
    a!gridLayoutHeaderCell(label: "NazivAng" )
    },
    columnConfigs: {
    a!gridLayoutColumnConfig(width: "DISTRIBUTE", weight:3 ),
    a!gridLayoutColumnConfig(width: "DISTRIBUTE", weight:3 ),
    a!gridLayoutColumnConfig(width: "DISTRIBUTE", weight:3 ),
    a!gridLayoutColumnConfig(width: "DISTRIBUTE", weight:3 ),
    a!gridLayoutColumnConfig(width: "DISTRIBUTE", weight:3 )
    },
    rows: a!forEach(
    items: local!data,
    expression: a!gridRowLayout(
    id: fv!index,
    contents: {
    a!dateTimeField(
    label: "Datum "& fv!index ,
    value: fv!item.Datum,
    saveInto: fv!item.Datum,
    required: true()
    ),
    a!textField(
    label: "Oznaka " & fv!index,
    value: fv!item.data.Oznaka,
    saveInto: fv!item.data.Oznaka,
    required:true()
    ),
    a!floatingPointField(
    label: "Sreden" & fv!index,
    value: fv!item.data.Sreden,
    saveInto: fv!item.data.Sreden,
    required:true()
    ),
    a!textField(
    label: "DrzavaAng" & fv!index,
    value: fv!item.data.DrzavaAng,
    saveInto: fv!item.data.DrzavaAng,
    required:true()
    ),
    a!textField(
    label: "NazivAng" & fv!index,
    value: fv!item.data.NazivAng,
    saveInto: fv!item.data.NazivAng,
    required:true()
    )
    }
    )
    ),
    addRowlink: a!dynamicLink(
    label: "Add Entry",
    saveInto: {
    a!save(local!data, append(local!data, save!value))
    }
    )
    )}
    ),
    a!sectionLayout(
    label: "Documents",
    contents: a!gridLayout(
    label: "Attachments",
    emptyGridMessage: "No files have been attached to this record",
    headerCells: {
    a!gridLayoutHeaderCell(label: "File"),
    a!gridLayoutHeaderCell(label: "Uploaded On", align: "RIGHT"),
    a!gridLayoutHeaderCell(showWhen: or(isnull(ri!readOnly), not(ri!readOnly)))
    },
    columnConfigs: {
    a!gridLayoutColumnConfig(weight: 7),
    a!gridLayoutColumnConfig(weight: 3),
    a!gridLayoutColumnConfig(width: "ICON", showWhen: or(isnull(ri!readOnly), not(ri!readOnly)))
    },
    rows: a!forEach(
    items: ri!documents,
    expression: rule!PQ_AttachmentsGridRow(
    attachment: fv!item,
    index: fv!index,
    attachments: ri!documents,
    target: ri!target,
    readOnly: ri!readOnly,
    oldAttachments: local!oldAttachments,
    deletedAttachments: ri!deletedDocuments
    )
    ),
    showWhen: or(not(ri!readOnly), and(not(isnull(ri!documents)), count(ri!documents) > 0)),
    addRowLink: if(
    ri!readOnly,
    null,
    a!dynamicLink(
    label: "Attach New File",
    value: todocument(null),
    saveInto: a!save(ri!documents, append(ri!documents, save!value))
    )
    )
    )),
    a!sectionLayout(
    label: "Process History",
    contents: {},
    iscollapsible: true
    )
    },
    buttons: a!buttonLayout(
    primaryButtons: {
    a!buttonWidgetSubmit(
    label: "Submit",
    value: true(),
    saveInto: ri!cancel,
    style: "PRIMARY"
    )
    },
    secondaryButtons: {
    a!buttonWidgetSubmit(
    label: "Cancel",
    value: false(),
    saveInto: ri!cancel,
    style: "NORMAL",
    skipValidation: true
    )
    }
    ),
    validations: {}
    ))
Reply
  • The whole code:

    load(
    local!paging: a!pagingInfo(
    startIndex: 1,
    batchSize: 5,
    sort: a!sortInfo(
    field: "Datum",
    ascending: true
    )
    ),
    local!data:with(local!data, todatasubset({ri!Echange_rate_table}, local!paging
    )
    ),
    local!documentsToken,
    local!oldAttachments: if(
    or(isnull(ri!documents), count(ri!documents) < 1),
    0,
    length(ri!documents)
    ),

    a!formLayout(
    label: "PoC Start Form",
    instructions: "",
    contents: {
    a!sectionLayout(
    label: "PoC Input data",
    contents: {
    a!textField(
    label: "Process Name",
    labelPosition: "ABOVE",
    value: ri!PoC_Details.Process_Name,
    saveInto: ri!PoC_Details.Process_Name,
    refreshAfter: "UNFOCUS",
    required: true,
    validations: {}
    ),
    a!textField(
    label: "Description",
    labelPosition: "ABOVE",
    value: ri!PoC_Details.Description,
    saveInto: ri!PoC_Details.Description,
    refreshAfter: "UNFOCUS",
    validations: {}
    ),
    a!dropdownField(
    label: "Month",
    labelPosition: "ABOVE",
    placeholderLabel: "--- Select a Value ---",
    choiceLabels: {"Jan", "Feb","Mart"},
    choiceValues: {"Jan", "Feb","Mart"},
    value: ri!PoC_Details.Month,
    saveInto:ri!PoC_Details.Month,
    validations: {}
    ),
    a!integerField(
    label: "Year",
    labelPosition: "ABOVE",
    value: ri!PoC_Details.Year,
    saveInto: ri!PoC_Details.Year,
    refreshAfter: "UNFOCUS",
    validations: if(len(ri!PoC_Details.Year)<=4,null,"Your year data is not in appropriate format, only 4 characters are allow")
    ),
    a!textField(
    label: "Author Full Name",
    labelPosition: "ABOVE",
    value: ri!My_Sql_Name&" "&ri!My_Sql_Lastname,
    saveInto: ri!PoC_Details.Author_Full_Name,
    refreshAfter: "UNFOCUS",
    readonly: true,
    validations: {}
    ),
    a!textField(
    label: "Comment",
    labelPosition: "ABOVE",
    value: ri!My_Sql_Lastname,
    saveInto: {},
    refreshAfter: "UNFOCUS",
    masked: false,
    validations: {}
    )
    },
    iscollapsible: true
    ),
    a!sectionLayout(
    label: "Echange rate table",
    contents: {
    a!gridLayout(
    totalCount: count(local!data),
    headerCells: {
    a!gridLayoutHeaderCell(label: "Datum" ),
    a!gridLayoutHeaderCell(label: "Oznaka" ),
    a!gridLayoutHeaderCell(label: "Sreden" ),
    a!gridLayoutHeaderCell(label: "DrzavaAng" ),
    a!gridLayoutHeaderCell(label: "NazivAng" )
    },
    columnConfigs: {
    a!gridLayoutColumnConfig(width: "DISTRIBUTE", weight:3 ),
    a!gridLayoutColumnConfig(width: "DISTRIBUTE", weight:3 ),
    a!gridLayoutColumnConfig(width: "DISTRIBUTE", weight:3 ),
    a!gridLayoutColumnConfig(width: "DISTRIBUTE", weight:3 ),
    a!gridLayoutColumnConfig(width: "DISTRIBUTE", weight:3 )
    },
    rows: a!forEach(
    items: local!data,
    expression: a!gridRowLayout(
    id: fv!index,
    contents: {
    a!dateTimeField(
    label: "Datum "& fv!index ,
    value: fv!item.Datum,
    saveInto: fv!item.Datum,
    required: true()
    ),
    a!textField(
    label: "Oznaka " & fv!index,
    value: fv!item.data.Oznaka,
    saveInto: fv!item.data.Oznaka,
    required:true()
    ),
    a!floatingPointField(
    label: "Sreden" & fv!index,
    value: fv!item.data.Sreden,
    saveInto: fv!item.data.Sreden,
    required:true()
    ),
    a!textField(
    label: "DrzavaAng" & fv!index,
    value: fv!item.data.DrzavaAng,
    saveInto: fv!item.data.DrzavaAng,
    required:true()
    ),
    a!textField(
    label: "NazivAng" & fv!index,
    value: fv!item.data.NazivAng,
    saveInto: fv!item.data.NazivAng,
    required:true()
    )
    }
    )
    ),
    addRowlink: a!dynamicLink(
    label: "Add Entry",
    saveInto: {
    a!save(local!data, append(local!data, save!value))
    }
    )
    )}
    ),
    a!sectionLayout(
    label: "Documents",
    contents: a!gridLayout(
    label: "Attachments",
    emptyGridMessage: "No files have been attached to this record",
    headerCells: {
    a!gridLayoutHeaderCell(label: "File"),
    a!gridLayoutHeaderCell(label: "Uploaded On", align: "RIGHT"),
    a!gridLayoutHeaderCell(showWhen: or(isnull(ri!readOnly), not(ri!readOnly)))
    },
    columnConfigs: {
    a!gridLayoutColumnConfig(weight: 7),
    a!gridLayoutColumnConfig(weight: 3),
    a!gridLayoutColumnConfig(width: "ICON", showWhen: or(isnull(ri!readOnly), not(ri!readOnly)))
    },
    rows: a!forEach(
    items: ri!documents,
    expression: rule!PQ_AttachmentsGridRow(
    attachment: fv!item,
    index: fv!index,
    attachments: ri!documents,
    target: ri!target,
    readOnly: ri!readOnly,
    oldAttachments: local!oldAttachments,
    deletedAttachments: ri!deletedDocuments
    )
    ),
    showWhen: or(not(ri!readOnly), and(not(isnull(ri!documents)), count(ri!documents) > 0)),
    addRowLink: if(
    ri!readOnly,
    null,
    a!dynamicLink(
    label: "Attach New File",
    value: todocument(null),
    saveInto: a!save(ri!documents, append(ri!documents, save!value))
    )
    )
    )),
    a!sectionLayout(
    label: "Process History",
    contents: {},
    iscollapsible: true
    )
    },
    buttons: a!buttonLayout(
    primaryButtons: {
    a!buttonWidgetSubmit(
    label: "Submit",
    value: true(),
    saveInto: ri!cancel,
    style: "PRIMARY"
    )
    },
    secondaryButtons: {
    a!buttonWidgetSubmit(
    label: "Cancel",
    value: false(),
    saveInto: ri!cancel,
    style: "NORMAL",
    skipValidation: true
    )
    }
    ),
    validations: {}
    ))
Children
  • Hi Natasa,

    In a!forEach() used in the section 'Echange rate table', for the attribute 'items', configure local!data.data and configure fv!item.fieldname (corresponding) for the text field, datetime field etc., For items attribute in forEach(), a list should be passed. If local!data is configured, it means a datasubset is passed and it won't be multiple.

    a!forEach(
    items: local!data.data,
    expression:
    a!dateTimeField(
    label: "Datum " & fv!index,
    value: fv!item.Datum,
    saveInto: fv!item.Datum,
    required: true()
    )
    )

    Consider the above code as an example.

    Hope this helps!!!

    Thanks,
    Hema