Lookup Problem

KSP_NAV
KSP_NAV Member Posts: 68
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 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

Comments

  • manlue
    manlue Member Posts: 30
    Hi,

    first impression to me is that a "MODIFY" is missing to save the new value in the table...
  • KSP_NAV
    KSP_NAV Member Posts: 68
    Hi,

    Thanks for your reply.

    I have already tried with MODIFY and the new value is not updated
  • lyot
    lyot Member Posts: 202
    For as far as I know code written in LookUp trigger only works when used in forms...
  • KSP_NAV
    KSP_NAV Member Posts: 68
    Nope, have a look in the "Applies-to Doc. No." etc... fields in table 36
  • KSP_NAV
    KSP_NAV Member Posts: 68
    Is there any possibilities for my query? As i am running out of time, can anyone help me in this regard?
  • Albertvh
    Albertvh Member Posts: 516
    Hi,

    What is "Rec. Journal Batch" is this a record variable or a field name of the table you are trying to update?

    maybe it should be "Rec. Journal Batch".Name := LGenJnlBatch.Name;

    Hope this helps
  • KSP_NAV
    KSP_NAV Member Posts: 68
    "Rec. Journal Batch" is a field in which i need to update the General Journal Batch Name.

    After the field assignment, if i message the "Rec. Journal Batch" field, it is displaying the desired output. The problem is that the value is not updated in the table.
    "Rec. Journal Batch" := LGenJnlBatch.Name;
    MESSAGE("Rec. Journal Batch");
  • manlue
    manlue Member Posts: 30
    What kind of type is your field "Rec. Journal Batch"?
  • KSP_NAV
    KSP_NAV Member Posts: 68
    It is Code 10
  • manlue
    manlue Member Posts: 30
    So this should be updated if modified. As I first replyed I think a modify-command must be to save the modified value in table. Only idea is to check if there's any other following code which will rollback your modification after having displayed it. Is the code you provided us the whole code in that trigger? Did you debug it to check step by step when field value changes?

    If there's more code which is done you may provide it... maybe anyone in this forum then has a good idea...
  • daros
    daros Member Posts: 1
    How have you tried? Run the table? If so try to use any form. NAV has a problem with written lookup in the field when use run table.
    Do not use modify in lookup.
  • KSP_NAV
    KSP_NAV Member Posts: 68
    Thanks Daros, as you said i have been trying this only at the table level and now i created a Form and performed the lookup and it works as expected.

    Thank you everyone for your timely help.