1

When we will i.e. data synchronization and we want to modify a record when it exists and insert when not.


A conceptual example, to add a translation for a caption:


Rec.SetRange(Caption, RelatedCaption);

Rec.SetRange(Language, LanguageCode);

if Rec.FindFirst() then begin

Rec.Validate(Translation, NewTranslation);

Rec.Modify(true);

end else begin

Rec.Validate(Caption, RelatedCaption);

Rec.Validate(Language, LanguageCode);

Rec.Validate(Translation, NewTranslation);

Rec.Insert(true);

end;


Suppose, there is a unique key on Caption and Language.

It could be much easier to do something like this:


Rec.Validate(Caption, RelatedCaption)

Rec.Validate(Language, LanguageCode);

Rec.Validate(Translation, NewTranslation);

Rec.InsertOrModify(Key3: TableKey, [UseTriggers: Boolean]);


So the idea is to add an action for a record variable which does a upsert based on an unique table key.


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