Lookup Problem

Hi,

The below coding is written in the “OnLookup” trigger of the table X. The problem is the value is not getting updated in the field (even using MODIFY) but it is displayed in the message.

LGenJnlTemplate.RESET;
LGenJnlTemplate.SETRANGE(LGenJnlTemplate.Recurring,TRUE);
CASE LGenJnlTemplate.COUNT OF
1: BEGIN
LGenJnlTemplate.FINDFIRST;
LGenJnlBatch.RESET;
LGenJnlBatch.SETRANGE(LGenJnlBatch.“Journal Template Name”,LGenJnlTemplate.Name);
LFrmGenJnlBatches.SETTABLEVIEW(LGenJnlBatch);
LFrmGenJnlBatches.SETRECORD(LGenJnlBatch);
LFrmGenJnlBatches.LOOKUPMODE(TRUE);
IF LFrmGenJnlBatches.RUNMODAL IN [ACTION::OK, ACTION::LookupOK] THEN BEGIN
LFrmGenJnlBatches.GETRECORD(LGenJnlBatch);
“Rec. Journal Batch” := LGenJnlBatch.Name;
MESSAGE(LGenJnlBatch.Name);
END;
END;
2:
.
.
END;
CLEAR(LFrmGenJnlBatches);

The same set of codes works fine in the Form but in my case it should work in table.

Can anyone help me to sort this problem?

Thanks in advance

Place a message at the end of your function to show you the value.

Then place a message directly after your function call in your codeunit (or wherever you call this function from).

If the value changes then it is not getting saved to the database and you do need a modify. If it does not change then there is some other code that executes later that is changing it, since no code should be executed between your two messages.

CONFIRM is actually better because it stops execution of the code and waits on you. I find it more useful anyway.

The result is same when i place the message at the end of my code. Also, the field “Rec. Journal Batch” is updated with the desired output but it is not updated in the table.

“Rec. Journal Batch” := LGenJnlBatch.Name;
MESSAGE(“Rec. Journal Batch”);

I have tried with COMMIT but no change in the o/p.