ResetFields property

OpenReportButton.ResetFields — Logical

Special value available in formulas:

Item

OpenReportButton

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 that are part of an opened report are reset after the report has been successfully opened. 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, open 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 opens a report which includes Field1 and Field2:

OPENREPORT({ Field1, Field2 })OPENREPORT({ Field1; Field2 })

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

OPENREPORT({ Field1, Field2 }); RESET.BLANK({ Field1, Field2 })OPENREPORT({ Field1; Field2 });; 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 opened. If the report can't be opened successfully, which can happen if there is a network problem, the fields are reset regardless.

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

AWAIT(OPENREPORT({ Field1, Field2 }), RESET.BLANK({ Field1, Field2 }))AWAIT(OPENREPORT({ Field1; Field2 }); 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 OPENREPORT has successfully opened the report.

There's just one more thing we can do to improve the formula. The first parameter to OPENREPORT 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(OPENREPORT(Fields), RESET.BLANK(Fields)))LET(Fields := { Field1; Field2 }; AWAIT(OPENREPORT(Fields); 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 open report button reset the fields that are part of a report when the report has been opened, only if ResetSwitchField is toggled to its "on" position.

OPENREPORT({ App }, ResetFields: ResetSwitchField)OPENREPORT({ App }; ResetFields: ResetSwitchField)

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

OPENREPORT({ App }); RESET({ App })OPENREPORT({ App });; RESET({ App })

This formula is associated with the OnPress property of a formula button, and causes a report to be opened 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(OPENREPORT({ App }), RESET({ App }))AWAIT(OPENREPORT({ App }); RESET({ App }))

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

LET(Fields := { Field1, Field2 }, AWAIT(OPENREPORT(Fields), RESET(Fields)))LET(Fields := { Field1; Field2 }; AWAIT(OPENREPORT(Fields); RESET(Fields)))

This formula is associated with the OnPress property of a formula button, and causes a report to be opened when the button is pressed. All sent fields are also reset, but only once the report has been successfully opened. 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.