Options

Help Needed

toshitaporitoshitapori Member Posts: 52
Hey Guys ,
I am new into navision Programming and i am trying to write a codeunit
where it shud turn the modified flag of all the objects whereever it is true to false .
Can anyone suggest me how to do it ?
Thanx In advance

Toshi

Comments

  • Options
    g_dreyerg_dreyer Member Posts: 123
    edited 2004-11-22
    Define a variabled called obj as type record = Object (this is one of those object with a very high ID).

    This could be your code....
    if obj.find('-') then repeat
    if modified = true then begin
    obj.modified := false;
    obj.modify;
    end;
    until obj.next = 0;


    I would suggest to do it through a report, as it is easier.

    Remember if you want to filter on obj where modified = true, and you are modifying the modified field, you should do it by using another variable called obj2 or something and only do obj2.modify.
    Reason for this is because you change the field that you are currently filtering on, then you are also stuffing up the filter.
    If you don't understand this last paragraph (because you are new), don't worry too much, you will run into that problem (then hopefully you will remember that I mentioned that you should not change the same field that you are filtering on, use a diff variable, set it to the same record then modify the diff variable).

    Cheers,
    Gus
  • Options
    g_dreyerg_dreyer Member Posts: 123
    Sorry, did not mean to post another reply... darn!! no delete button...
  • Options
    toshitaporitoshitapori Member Posts: 52
    Hi Gus ,
    I wrote Exactly the same code before and tried but it give the error that you cannot modify table data in Object table and now i have to manually remove the Flag or there is still any another way around
  • Options
    kinekine Member Posts: 12,562
    obj.setrange(Type,obj.Type::Table,obj.Type::Codeunit);
    obj.modifyall(Modified,false);
    

    That's all folks... ;-)
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • Options
    g_dreyerg_dreyer Member Posts: 123
    Thanks Kine,

    That is the correct way of doing it for this task. I though I'd make it a bit more complicated, but also talking about something that you will run into later (filtering on the field that you modify).

    I think you might not have enough permissions in the license file that you are using (or perhaps you picked up the wrong lines, which is why Kine added the filter that you should use).

    Let me know if you still have problems with this, but use Kine's code.

    Cheers,
    Gus
  • Options
    tguptatgupta Member Posts: 86
    It worked fine now .

    Cheers,
Sign In or Register to comment.