Adding Items in a Grid

I created a grid in SAIL. I have managed to add and delete rows and capture the values. One of the columns in my grid calculates the difference in days between two dates. I need to have a field called Summary of Total Days contain the total of all those differences. I created an integer field on my interface but am having difficulties making that calculation. This is the code I have in my add a row rule to calculate the difference:

a!integerField(
label: "Total Days" & ri!index,
value: todate(ri!items[ri!index].endDate)-todate(ri!items[ri!index].startDate),
saveInto: ri!items[ri!index].amount,
validations: {}
),

Is my saveInto statement at fault. I am trying to bring back the value back into my interface that calls it. I have attached a screen shot of the interface that the customer would see.

OriginalPostID-271614



  Discussion posts and replies are publicly visible

Parents
  • Hi tonyc,
    From my understanding you want to calculate the difference automatically when user enters both dates. If this is the scenario you want then you have to Place these save function in both start date field and end date fields saveinto, so it will store difference into the target variable when he enters/modifies the start/end date. check null values as below code.

    if(
    or(
    isnull(ri!items[ri!index].endDate),
    isnull(ri!items[ri!index].startDate)
    ),
    {},
    a!save(
    ri!items[ri!index].amount,
    todate(ri!items[ri!index].endDate)-todate(ri!items[ri!index].startDate),
    )
    )

    Hope this may help you... Correct me if i am wrong..
Reply
  • Hi tonyc,
    From my understanding you want to calculate the difference automatically when user enters both dates. If this is the scenario you want then you have to Place these save function in both start date field and end date fields saveinto, so it will store difference into the target variable when he enters/modifies the start/end date. check null values as below code.

    if(
    or(
    isnull(ri!items[ri!index].endDate),
    isnull(ri!items[ri!index].startDate)
    ),
    {},
    a!save(
    ri!items[ri!index].amount,
    todate(ri!items[ri!index].endDate)-todate(ri!items[ri!index].startDate),
    )
    )

    Hope this may help you... Correct me if i am wrong..
Children
No Data