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
I don't think this has anything to do with the sum function. The error above says that it cannot index "taskdate" within the variable ri!timeline. What is the type of your rule input for timeline? Does it have a field called "taskdate"?
its displaying sum functions too
Well, one thing at a time.
ri!timeline is an array - but you're trying to add up all the total hours and save it to one(?) spot. This doesn't exactly line up.
yes i am using array for editable grid
I'm still not clear what your desired outcome is - are you expecting the calculated TotalHours value to be duplicated across all rows of ri!timeline?
Also: as has been explained in a few other threads here recently, the saveInto in a text field will not execute without some user interaction. So there is no reason to believe that having the text field's saveInto set this way would cause the total hours to be saved to any particular location.
actually i need to display in a record type as a how many hours that we spend on each task, so total hours will be must display recordtype.in that case do we need any other cdt?
If it were up to me, I would structure your CDTs differently. You have some values that correspond to the timesheet only, while other values correspond to a row within your grid. I'd suggest splitting up your data into multiple CDTs like this:
Timesheet
id
date
totalHours
TimesheetItem
timesheetId
projectName
taskName
description
status
This allows you to have a 1:M relationship where each timesheet has multiple timesheet items, and it will be easier to maintain the data and save the information correctly on your interface.
Thank you Peter ill work on this
Hi peter as per your answe i have divided into two tables but still the value is not saved into other CDT which in sum function.
As Mike mentioned above, read-only fields don't save results - users must interact with the field in order for the save to be triggered. In this case, I'd recommend setting your save on the button so that the value is saved when the user submits the form. For example, your submit button could look like this:
a!buttonWidget( label: "Submit", submit: true, style: "PRIMARY", saveInto: a!save( target: ri!DSR_Timesheet.totalhours, value: sum(property(ri!timeline, "noofhours", 0)) ) )
Thanks for the answer peter, issue resolved.