Editable grid is displaying unknown error for date and sum function?

a!localVariables(
local!projectdata:rule!totaltimesheet(),

local!projectid,

local!updateCounter: 0,
local!employee: a!refreshVariable(

refreshOnVarChange: local!updateCounter
),
{

a!dateField(
label: "Date",
labelPosition :"JUSTIFIED",
value: ri!timeline.taskdate,
saveInto:ri!timeline.taskdate,

),
a!sectionLayout(
label: "",
contents: {

a!gridLayout(
/*label: "Grid view of an employee Details",*/
labelPosition: "ABOVE",
totalCount: count(ri!timeline),
headerCells: {
/*a!gridLayoutHeaderCell(label: "Employee Name"),*/
a!gridLayoutHeaderCell(label: "Project Name"),
a!gridLayoutHeaderCell(label: "Task Name"),

a!gridLayoutHeaderCell(label: "Description"),
a!gridLayoutHeaderCell(label: "Hours"),

a!gridLayoutHeaderCell(label: "Status"),
a!gridLayoutHeaderCell(
label: ""
)

},
columnConfigs: {
/*a!gridLayoutColumnConfig(width: "DISTRIBUTE", weight:2),*/
a!gridLayoutColumnConfig(width: "DISTRIBUTE", weight:2),
a!gridLayoutColumnConfig(width: "DISTRIBUTE", weight:2),

a!gridLayoutColumnConfig(width: "DISTRIBUTE", weight:2),

a!gridLayoutColumnConfig(width: "DISTRIBUTE", weight:2),
a!gridLayoutColumnConfig(
width: "ICON"
)

},
rows: a!forEach(
items: ri!timeline,
expression:a!gridRowLayout(

contents: {
/*a!textField(*/
/* */
/*value: loggedInUser(),*/
/*saveInto: {fv!item.employerName, a!save(ri!timeline.employerName, save!value)},*/
/*refreshAfter: "UNFOCUS",*/
/*required: true,*/
/*readOnly: true */
/* */
/* */
/*),*/

a!dropdownField(
label: "project Name ",
placeholderLabel: " ",
choiceLabels: rule!CrochetDSR_Get_ProjectName().projectname,
choiceValues: rule!CrochetDSR_Get_ProjectName().projectid,
value: fv!item.projectid,
saveInto: fv!item.projectid,
required: true
),
/*a!dropdownField(*/
/*label: "task",*/
/*placeholderLabel: " ",*/
/*choiceLabels: rule!CrochetDSR_Get_MilestoneTaskName(projectid:local!projectid).taskname,*/
/*choiceValues: rule!CrochetDSR_Get_MilestoneTaskName(projectid:local!projectid).taskname,*/
/*value: fv!item.taskname,*/
/*saveInto: fv!item.taskname,*/
/* */
/*required: true*/
/*) ,*/
a!textField(
label: "Description ",
value: fv!item.taskname,
saveInto: fv!item.taskname,
required: true
),
a!textField(
label: "Description ",
value: fv!item.description,
saveInto: fv!item.description,
required: true
),
/*a!dateField(*/
/*label: "task date ",*/
/*value: fv!item.taskdate,*/
/*saveInto: fv!item.taskdate,*/
/*required: true */
/*),*/
a!textField(
label: "Hours ",
value: fv!item.noofhours,
saveInto: fv!item.noofhours,
required: true
),

a!dropdownField(
label: "Status ",
placeholderLabel: " ",
choiceLabels: {"Done","Pending"},
choiceValues: {"Done","Pending"},
value: fv!item.Status,
saveInto: fv!item.Status,
required: true
),
a!imageField(
label: "delete " & fv!index,
images: a!documentImage(
document: a!iconIndicator(
"REMOVE"
),
altText: "Remove",
link: a!dynamicLink(
value: fv!index,
saveInto: {
a!save(
ri!timeline,
remove(
ri!timeline,
save!value
)
)
}
)

)
)


}
)
),


/*selectionvalue: ri!selectedRowIndex,*/
/*selectionsaveinto: ri!selectedRowIndex,*/
/*selectable: true,*/
selectionrequired: false,
addRowLink: a!dynamicLink(
label: "Add Timesheet",
saveInto: {
a!save(
target: ri!timeline,
value: append(
ri!timeline,
'type!{urn:com:appian:types:DSR}DSR_TimeSheetLineItem'(
employerName: loggedInUser(),

)
)
)
}
),
height: "AUTO",
spacing: "DENSE",
borderstyle: "STANDARD",
rowHeader: 1



),

a!columnsLayout(
columns: {
a!columnLayout(
contents: {}
),
a!columnLayout(
contents: {}
),
a!columnLayout(
contents: {
a!textField(
label: "Total Hours ",
labelPosition :"ADJACENT",
value: sum(ri!timeline.noofhours),
saveInto: {ri!timeline.Totalhours, a!save(ri!timeline.Totalhours, save!value)},
readOnly: true
),

}
)
}
),



a!buttonLayout(
primaryButtons: {
a!buttonWidgetSubmit(
label: "Submit",
value: ri!timeline,
/*saveInto: {a!save(ri!timeline.timesheetid,ri!pid),*/
/*ri!submitbutton,*/
/*a!writeToDataStoreEntity(*/
/*dataStoreEntity: cons!CROCHETDSR_GET_TIMESHEET,*/
/*valueToStore: ri!timeline,*/
/*)*/
/**/
/*},*/
showWhen: if(
rule!APN_isEmpty1(
ri!timeline
),
false(),
true()
),
style: "PRIMARY",
confirmHeader: {
if(
rule!APN_isEmpty1(
ri!timeline
),
"Please add at least one row",
{}
)
},
confirmMessage: {
if(
rule!APN_isEmpty1(
ri!timeline
),
"Please add at least one row",
{}
)
}
)
},
secondaryButtons: {
a!buttonWidget(
label: "Cancel",
value: true,
saveInto: ri!cancel,
submit: true,
style: "NORMAL",
validate: false
)
}


)

}


),

}

)

  Discussion posts and replies are publicly visible

Parents Reply
  • 0
    Appian Employee
    in reply to swethasri

    Ok I think the issue then is that it seems you are trying to directly save a single value into an empty list. In general, you should try to save values one-to-one - if you have a single field where you enter data, it should also save into a single field.

    However, what you're doing is saving a single item into a list, so the error is essentially telling you that you can't save it that way.

    In general I'm a bit confused as to how your data is set up here. Your date field and the sum fields are both single values, but the other items in the grid are saving multiple values. How do you plan to resolve this? For instance, if you have 3 rows in your grid, what do you expect to be saved for the taskdate and noofhours fields? Would you duplicate the same value for all 3 rows? Or should you have a separate variable that contains only these values?

    If your plan is to duplicate the taskdate and noofhours across all rows, I'd suggest a different strategy. You can set up a local variable to initially save the single value for each of those fields. Then, on submission of the form, you can set up a save in the saveInto button that performs a save for each of those fields.

Children