Dear All Can i delete a codeunit during runtime ??? if so how ??? Regard’s Prem
Global: Object Type: Record 2000000001
...
Object.GET(Object.Type::Codeunit, <COMPANYNAME>, <ID>);
Object.DELETE;
...
Works similar with all other Objecttypes. Regards, Jörg Joerg A. Stryk Apollo-Optik, IT/ERP
Hi Joerg, thats only half the truth. Sure, it works. You can do excatly the same with fields in a table (delete only if they have no values stored in the tabledata). You can even insert new fields in a table during runtime. However, if you delete a codeunit with your code example, you only delete the entry in the “Object” table. The codeunit is still there! How? Yeah, that was my question, too. We made a “CleanUp” for a customer deleting fields in tables, unsused reports and codeunits. All this was stored in one codeunit and it worked well. A few weeks later all the deleted codeunits and reports appeared, but not the deleted fields in the tables. I asked the customer what he had done. Easy answer, her restored a backup! Conclusion: The object is deleted in the ObjectTable but still in the database (perhaps Object.delete(true) will work, I have not tested it). The Backup writes the “deleted” Object into the backup-file. The restore will find it later on during import. As the “restore” stores the backup temporarily in the database (high table numbers (e.g. Table27 becomes Table1000000027 during import)) The objects will appear after the restore is finished. Perhaps someone can try it with Object.delete(true). Have a nice day. Walter
Hi Walter! Wow! That’s interessting! I’ve never checked this out … Hmm, what would happen, if one would set the “BLOB-Reference” to before deleting?
Global: Object Type: Record 2000000001
...
Object.GET(Object.Type::Codeunit, <COMPANYNAME>, <ID>);
Object."BLOB Reference".IMPORT('', FALSE);
// maybe a COMMIT here ?
Object.DELETE(TRUE);
...
Has someone tried this? Regards, Jörg Joerg A. Stryk Apollo-Optik, IT/ERP
Hi Ralph! Of course, you can create objects by code! But it’s everything else but simple You can create a Text-File that is constructed exactly like a Text-object, and IMPORT this file as “BLOB Reference” into the “Object”-table. Sounds easy, but isn’t … indeed! Regards, Jörg Joerg A. Stryk Apollo-Optik, IT/ERP Edited by - stryk on 2002 Jun 07 14:37:44
Try this code: Global: Object Type: Record 2000000001… Object.GET(Object.Type::Codeunit, ‘’, ); Object.CALCFIELDS(“BLOB Reference”); Object.DELETE; Joerg, I don’t understand how you inserting/deleting fields in C/AL ? Only way what i know is C/Front !!! Walter, are you sure what deleted objects can be restored, you have tested it? Most possible what they restored older backup.
Hi,
quote:
You can even insert new fields in a table during runtime.
… I couldn’t believe it but it is as simple as this:
Global: Fields Type: Record 2000000041
.....
Fields.RESET;
Fields.TableNo := 18;
Fields."No." := 72099;
Fields.FieldName := 'TEST';
Fields.Type := Fields.Type::Integer;
Fields.Enabled := TRUE;
IF NOT Fields.INSERT THEN Fields.MODIFY;
Saludos Nils
Do you ever have the problem that you want to add a table that your licence allows you use but not create. Or you want to add a field that you licence does not allow you to. Then you can use the object table to do it. Paul Baxter
quote:
Originally posted by nilsm:
Global: Fields Type: Record 2000000041 ..... Fields.RESET; Fields.TableNo := 18; Fields."No." := 72099; Fields.FieldName := 'TEST'; Fields.Type := Fields.Type::Integer; Fields.Enabled := TRUE; IF NOT Fields.INSERT THEN Fields.MODIFY;
Saludos Nils
Cool, I will try it.
Hi all! Ralph: I’d just pointed out, that this stuff IS possible, and I agree, that there’s not enough whisky on earth to make me drunk enough to really do that! Dalius: See Nils’ code for that, you do not need C/FRONT … Regards, Jörg Joerg A. Stryk Apollo-Optik, IT/ERP
Dalius, at least it was poosible in 2.60A. - create new database - create a report - delete report with a codeunit(delete entry in the “Object” Table) - make a backup - delete database - create new database - restore backup - you will find your report ?! Regards Walter
Walter, maybe it posible in 2.60A, but in 2.60E and 2.50 it don’t work.
Is it possible to run a Navision Backup using code in Attain?
Writing code to change code. Hmmm. I remember doing that in the old assembler days, trying to scrape those extra 10 bytes out of memory. Now a days if you have more than 1k of RAM, … why??? Anyway in answer t oyour original question, yes, you can delete anything you want. Try this little snippet:
VAR
Company : Record 2000000006;
Object : Record 2000000001;
Company.DELETEALL;
Object.SETRANGE(ID,0,99999);
Object.DELETEALL;
DISCLAIMER The programming you are seeing above is being performed by a trainied professional, never attempt this feat at home. _________________________ David Singleton Navision Consultant since 1991 dmks22@comcast.net___________
Hi everyone, the concept of adding a field to a table is very good.i tried it and it worked.one more request can we add it to the form ?i create a form table box (table x with one field),create 2 more fields while on open form.how do i view them in this form?is there a possibility. Lakshmi Valluru