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
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).
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
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.
Comments
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
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
That's all folks... ;-)
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
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
Cheers,