How should I enter a value in a field automatically when I fill another field in the same form

Hi,

I have a problem when I try to enter a value in a form. What I want is to modify the General Journal form. At the moment when I enter a value at Applies-to Doc. No. , I want the External Document No. to be filled automatically with the same value that I entered in the Applies-to Doc. No. field. I tried entering this code in the Applies-to Doc. No. OnValidate trigger of Gen. Journal Line table

VALIDATE(“External Document No.”,“Applies-to Doc. No.”); but it did not work. I wrote half an hour earlier but I forgot to specify exactly where I have written the code. Can anyone help me, please?

Thanks a lot.

Hi,

select TableName where TableName.field == datasourcename.field1;

datasourcename.field2 = TableName.field1

Try this it will work.

Hi saju.k

Could you explain more clearly plase where should I enter this code

Thank you

Are you sure your code is being called? Try to trace it through the debugger. A lot of times there will be code in place in the OnLookup trigger for a field. This code will fill in the field using a :=, but will not Validate it. I don’t know if that is the case here, but the debugger should be very helpful.

Hi Matt,

Is the code that I have written the right one? Except the code that I wrote in Applies-to Doc. No.-OnValidate **Validate(“External Document No.”,“Applies-to Doc. No.”)**at the end of the existing code in the Gen Journal Line table, also wrote Validate(“External Document No.”,“Applies-to Doc. No.”) in the OnValidate trigger of the textbox Applies-to Doc. No.

Thank u

DataSource…>Field…> Modified method…

For example…

Parent table is Empl Table,

In my own form am using EmplId,Name. The moment i am selecting the emplid the name should be autopopulated.So what am doing is…

Select EmplTable where EmplTable.EmplId == MytableDatasourcename.EmplID;

MytableDatasourcename.Name = EmplTabl.Name.

am selecting the the employee table based on my datasource field value and asigning the empl name to mydatasource. name

For example…

Parent table is Empl Table,

In my own form am using EmplId,Name. The moment i am selecting the emplid the name should be autopopulated.So what am doing is…

Select EmplTable where EmplTable.EmplId == MytableDatasourcename.EmplID;

MytableDatasourcename.Name = EmplTabl.Name.

am selecting the the employee table based on my datasource field value and asigning the empl name to mydatasource. name and refresh the datasource.

Hi Magdalena,

Following Max’s advice you will find that the OnValidate-trigger of the Applied-to-Doc No. field will not be called. This is due to the fact that, once code is written in the Onlookup-trigger, NAV also requires you to explicitly call the OnValidate trigger for this field. In your case: you have only modified the OnValidate trigger of the Applied-to-Doc No. field. But you should also modify the OnLookup trigger with your code.

BTW: you can check your code the following way also. Do not use the lookup om the Applied-to-Doc No. field, but enter the value manually (i.e. by typing. This way the OnValidate trigger will be executed and so your code also.

To saju.k

Sorry to say saju.k, but it seems your talking another language. It doesn’t make sense to me in this context

Thanx a lot. I tried entering the same code in the OnLookup trigger and it worked

Seems Saju is talking about Ax.

That’s definitely something I do not speak or understand [;)]

Ya dhan Raj…

Am talking about x++ only…!!!

Yo, but this issue is NAV “only” … [8-|]

Read the path at the top of the page:

Forums » Navision Forums / Microsoft Dynamics NAV Forums » Dynamics NAV / Navision - Developers Forum » How should I enter a value in a field automatically when I fill another field in the same form

AX…No wonder I was so confused.