27

There are no function on RecordRef that corresponds to Record.SetAutoCalcFields()


If we want to loop a RecordRef with a FlowField or Blob field that we need the value for each record, we have to call FieldRef.CalcField() for each record, which is very bad for performance.


Current way:

        FldRef := RecRef.Field(MyFieldNo);
        FldRef2 := RecRef.Field(MyFieldNo2);
        if RecRef.FindSet() then
            repeat
                FldRef.CalcField();
                FldRef2.CalcField();
                // Do something with FldRef.Value() and FldRef2.Value()
            until RecRef.Next() = 0;


I would like a SetAutoCalcField() function that could be used like this:

        FldRef := RecRef.Field(MyFieldNo);
        FldRef2 := RecRef.Field(MyFieldNo2);
        RecRef.SetAutoCalcField(MyFieldNo);
        RecRef.SetAutoCalcField(MyFieldNo2);
        if RecRef.FindSet() then
            repeat
                // Do something with FldRef.Value() and FldRef2.Value()
            until RecRef.Next() = 0;


The syntax could be like this:

[Ok := ] RecordRef.SetAutoCalcField(FieldNo: Integer)

And the function needs to be called once for each field to auto calculate.

Category: Development
STATUS DETAILS
Needs Votes
Ideas Administrator

Thank you for this suggestion! Currently this is not on our roadmap. We are tracking this idea and if it gathers more votes and comments we will consider it in the future. Best regards, Business Central Team

Comments

J

The reason I suggested the signature as I did, in contrast to the suggestion by Lourens Vlaanderen, is that the number of fields that should be auto calculated is probably dynamic and set by some kind of data in the database and thus cannot be added as parameters to the same function call. Looping the fields and calling RecRef.SetAutoCalcField() for each field would be more useful, IMO.

Category: Development

J

Agree that this should be implement on RecordRef the same as it works on a Record variable

Category: Development

J

It would match better with current functionality for records (Record.SetAutoCalcFields()) if it wasOk := RecRef,SetAutoCalcFields([FieldNo,FiendNo, ..])This way you can also remove or change the auto calc fields in the same way.Alternatively it could be set on the FieldRef, but that seems less intuitive.

Category: Development