How to insert a new record in a table after the last record at run time in microsoft nav through code and transfer the all the fileds of the existing record to the new inserted fields
If you want to generate Autonumber for new record, you can use No. Series or get last record and increase number by INCSTR function. To copy data from other record you can use TRANSFERFILEDS function.
Yes, euekim is right, If you explain your requirement in details members can help you easily.
If you want to generate Autonumber for new record, you can use No. Series or get last record and increase number by INCSTR function. To copy data from other record you can use TRANSFERFILEDS function.
Yes, euekim is right, If you explain your requirement in details members can help you easily.
I have a table GL Entry.. it has a field Tax amount. This tax amount field is zero for some record and noon zero for some.. i have to insert a new record if i found a tax amount field non zero and transfer its content to new record dat is added in last
Its not advisable to enter records in G/L entry table by customized code, but if its necessory, you can do like this,
GLEntry.RESET;
IF GLEntry.FIND('+') THEN BEGIN
GLEntryNew.INIT;
GLEntryNew."Entry No." := GLEntry."Entry No.";
GLEntryNew.TRANSFERFIELDS(GLEntry,FALSE);
//You can change some field values here, if you want
IF NOT GLEntryNew.INSERT THEN
ERROR('Error Message');
END;
I have a table GL Entry.. it has a field Tax amount. This tax amount field is zero for some record and noon zero for some.. i have to insert a new record if i found a tax amount field non zero and transfer its content to new record dat is added in last
If you need to make any corrections in the GL accounts, you can use your procedure to generate lines in the General Journal, which afterwards to post. I think this is a better approach.
Further on, I would ask you what is the "non-technical" part of your requirement, why you want to interfere into the GL entries? If it is for correcting a wrong posting, then I strongly advice you to do it through a General Journal.
Boris
*
Please, do not frighten the ostrich,
the floor is concrete.
Its not advisable to enter records in G/L entry table by customized code, but if its necessory, you can do like this,
GLEntry.RESET;
IF GLEntry.FIND('+') THEN BEGIN
GLEntryNew.INIT;
GLEntryNew."Entry No." := GLEntry."Entry No.";
GLEntryNew.TRANSFERFIELDS(GLEntry,FALSE);
//You can change some field values here, if you want
IF NOT GLEntryNew.INSERT THEN
ERROR('Error Message');
END;
This must be the worst advise ever. ](*,) ](*,) ](*,) ](*,) ](*,)
Hi David Singleton, I agree that my advise is wrong thats why in beginning I mentioned "Its not advisable to enter records in G/L entry table by customized code, but if its necessory"
dynamicsha, don't do it as per my advise, All experts also telling not to add record G/L Entry table by this way.
Hi David Singleton, I agree that my advise is wrong thats why in beginning I mentioned "Its not advisable to enter records in G/L entry table by customized code, but if its necessory"
dynamicsha, don't do it as per my advise, All experts also telling not to add record G/L Entry table by this way.
if someone asks you how to set their head on fire, the correct advise is to tell them NOT to set their head on fire, you don't suggest it as a bad idea and then show them how to do it*.
There is nothing random with this code, it will always error out, so it is mostly harmless \:D/
Yes , but with a slight alteration it could be quite harmful. There are NSC's where you will get fired instantly for code like this that writes directly to a ledger table without using the proper posting routine. [-X
There are NSC's where you will get fired instantly for code like this that writes directly to a ledger table without using the proper posting routine. [-X
In Germany maybe in some other countries maybe not.
Comments
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!
Yes, euekim is right, If you explain your requirement in details members can help you easily.
Navision Developer
Yes, euekim is right, If you explain your requirement in details members can help you easily.
GLEntry.RESET;
IF GLEntry.FIND('+') THEN BEGIN
GLEntryNew.INIT;
GLEntryNew."Entry No." := GLEntry."Entry No.";
GLEntryNew.TRANSFERFIELDS(GLEntry,FALSE);
//You can change some field values here, if you want
IF NOT GLEntryNew.INSERT THEN
ERROR('Error Message');
END;
Navision Developer
[-X [-X [-X [-X [-X [-X [-X [-X [-X
ABSOLUTELY DO NOT DO THIS.
Further on, I would ask you what is the "non-technical" part of your requirement, why you want to interfere into the GL entries? If it is for correcting a wrong posting, then I strongly advice you to do it through a General Journal.
*
Please, do not frighten the ostrich,
the floor is concrete.
This must be the worst advise ever. ](*,) ](*,) ](*,) ](*,) ](*,)
RIS Plus, LLC
dynamicsha, don't do it as per my advise, All experts also telling not to add record G/L Entry table by this way.
Navision Developer
if someone asks you how to set their head on fire, the correct advise is to tell them NOT to set their head on fire, you don't suggest it as a bad idea and then show them how to do it*.
* OH wait I did that didn't I
There is nothing random with this code, it will always error out, so it is mostly harmless \:D/
Well spotted, I didn't even read it in detail. But yes the ERROR('Error Message") will pop up every time.
In Germany maybe in some other countries maybe not.