ResetFields property

EmailReportButton.ResetFields — Logical

Special value available in formulas:

Item

EmailReportButton

The button this property is part of, enabling multiple checked items in the app designer to share the same formula and be updated all at once.

Consider the fields Field1 and Field2, which should only be considered to be valid if their values are greater than 4. Without using the Item value, the Valid property of Field1 would need to use the formula Field1 > 4Field1 > 4 and the Valid property of Field2 would need to use the formula Field2 > 4Field2 > 4.

Using Item, both formulas can read Item > 4Item > 4. This is useful if you have many fields and you want to be able to update their formulas all at once. To do so, click their check boxes in Calcapp Creator and make sure that a checked field is selected. Then, when you update a formula for one checked field, you update all the other checked fields too, which is a great timesaver.

Use Item in exactly the same way you'd use the regular name. Button1.VisibleButton1,Visible and Item.VisibleItem,Visible are equivalent, for instance.

Whether the fields sent in the report are reset after the report has been successfully sent. When a field is reset, its value is set to the initial value.

If this property is not set, FALSE is assumed.

Assigning a blank value to a field

Out of the box, email report buttons can only reset field values to their initial values, and not to a blank value. To do so, you need to use a formula button, which runs custom formulas you associate with its OnPress property.

This OnPress formula sends a report to test@example.com, which includes Field1 and Field2:

EMAILREPORT({ Field1, Field2 }, "test@example.com")EMAILREPORT({ Field1; Field2 }; "test@example.com")

The RESET function is used to reset fields to their initial values, whereas RESET.BLANK sets field values to a blank value. This formula sends a report and then immediately sets the field values to blank values:

EMAILREPORT({ Field1, Field2 }, "test@example.com"); RESET.BLANK({ Field1, Field2 })EMAILREPORT({ Field1; Field2 }; "test@example.com");; RESET.BLANK({ Field1; Field2 })

(;;; in the formula above is used to separate different parts of the formula that is run.)

With the formula above, field values are reset immediately after the report is sent. If the report can't be sent successfully, which can happen if there is a network problem, the fields are reset regardless.

To wait for EMAILREPORT to successfully send its report before resetting the field values, use the AWAIT function:

AWAIT(EMAILREPORT({ Field1, Field2 }, "test@example.com"), RESET.BLANK({ Field1, Field2 }))AWAIT(EMAILREPORT({ Field1; Field2 }; "test@example.com"); RESET.BLANK({ Field1; Field2 }))

The formula fragment given as the second parameter to AWAIT is run when the action given as the first parameter has run to completion, that is, when EMAILREPORT has successfully sent the report.

There's just one more thing we can do to improve the formula. The first parameter to EMAILREPORT specifies what fields to include, and this entire parameter needs to be repeated verbatim when provided to RESET.BLANK. If you need to include many fields, that makes the formula unnecessarily long and hard to read.

The LET function allows us to assign names to values. Here is the formula above, rewritten to use LET:

LET(Fields := { Field1, Field2 }, AWAIT(EMAILREPORT(Fields, "test@example.com"), RESET.BLANK(Fields)))LET(Fields := { Field1; Field2 }; AWAIT(EMAILREPORT(Fields; "test@example.com"); RESET.BLANK(Fields)))

Above, the { Field1, Field2 }{ Field1; Field2 } formula fragment has been given the name Fields, and can be referenced by simply typing this name in the formula.

Examples

ResetSwitchFieldResetSwitchField

Makes an email report button reset the fields sent in a report when the report has been sent, only if ResetSwitchField is toggled to its "on" position.

EMAILREPORT({ App }, "test@example.com", ResetFields: ResetSwitchField)EMAILREPORT({ App }; "test@example.com"; ResetFields: ResetSwitchField)

This formula is associated with the OnPress property of a formula button, and causes a report to be sent when the button is pressed. All fields of the app are considered, courtesy of the { App }{ App } parameter. The sent fields are reset when the report has been successfully sent, but only if ResetSwitchField is toggled to its "on" position.

EMAILREPORT({ App }, "test@example.com"); RESET({ App })EMAILREPORT({ App }; "test@example.com");; RESET({ App })

This formula is associated with the OnPress property of a formula button, and causes a report to be sent when the button is pressed, immediately followed by all fields being reset. All fields of the app are considered, courtesy of the { App }{ App } parameter.

AWAIT(EMAILREPORT({ App }, "test@example.com"), RESET({ App }))AWAIT(EMAILREPORT({ App }; "test@example.com"); RESET({ App }))

This formula is associated with the OnPress property of a formula button, and causes a report to be sent when the button is pressed. All fields are also reset, but only once the report has been successfully sent. All fields of the app are considered, courtesy of the { App }{ App } parameter.

LET(Fields := { Field1, Field2 }, AWAIT(EMAILREPORT(Fields, "test@example.com"), RESET(Fields)))LET(Fields := { Field1; Field2 }; AWAIT(EMAILREPORT(Fields; "test@example.com"); RESET(Fields)))

This formula is associated with the OnPress property of a formula button, and causes a report to be sent when the button is pressed. All fields are also reset, but only once the report has been successfully sent. Only the fields Field1 and Field2 are considered. LET is used to assign a temporary name to { Field1, Field2 }{ Field1; Field2 }, saving us from having to repeat these field names elsewhere in the formula.