Saved Filter error

Periodically I have a problem where the user tries to access the Purchase Invoice or Purchase Credit Memo screen and they receive the error:

"The Purchase Header does not exist. Identification fields and values: " and then it indicates a document.

The client has a customization whereby one user is not allowed to post an invoice/CM that they have made changes to. Another user has to post the document. I was able to reproduce this by logging in as one user, putting a filter on the No. field, log in as another user, post that document, log in as the first user and go to the purchase document screen. The filter had been saved but the record no longer exists. Makes sense.

So I set the SaveTableView property to No. That eliminated the ability for the user to save a filter and the problem went away. However, the problem is still cropping up. The only way around it is to delete the .zup file or re-compile the form.

Since I don’t seem to be able to re-produce it I’m wondering if, in the form, I can use a trigger to wipe out any filters before they are applied?

Hi.

First of all to control who does what on a document, I would recommend you develop a proper solution as opposed to setting filters.

Now, to remove filters I would put a CLEARALL on the “OnQueryCloseForm()” trigger of the form.

Hope this helps

I’m not sure if I should take offense to your suggestion that I should develop a proper solution. [:^)]

It appears to be at a higher level than what I’m doing. Create a sales document. Don’t post. Log into the database specifing a different ZUP file. Go to the same document and post it. Close the DB and log back in with the original ZUP. Click on the Navigation Pane entry to go back to your sales document and you get the error.

I know there is somewhere to tell the Navigation Pane not to remember. And now that I know it is a UI issue I can try search for other solutions.

CLEARALL didn’t work unfortunately. But thanks for the suggestion.

Watching in the debugger I saw that in OnOpenForm after:

IF UserMgt.GetPurchasesFilter <> ‘’ THEN BEGIN
FILTERGROUP(2);
SETRANGE(“Responsibility Center”,UserMgt.GetPurchasesFilter);
FILTERGROUP(0);
END;

The Rec variable was no longer uninitialized. There was no filter but the Document Type and No. fields were referencing the posted document! At then end of that trigger the error appeared and the form closed due to the error.

But the problem only occurred when there were no more records in the purchase header table. If there was another record of the correct document type then the user was shown that document instead of the error.

So I made an adjustment to C90 so that after the document was posted I check the purchase header table. If the purchase header table has no records of the appropriate type (invoice/cm) then I add a blank one.

SQL Client, MSSQL 2005, problem surfaced with 5.0 and 5.0SP1 client.

Hi Django,

Sound to me like the order saved on the Zup file is being filtered out by the filtergroup. Try puting in a findfirst after the filter to see if it solves your problem.

Hi Dave,

Sorry - I should have been more clear. The code above doesn’t get run because the IF UserMgt.GetPurchasesFilter <>’’ returns FALSE - there are no purchases filters. I’ve never seen this happen before but at least I was able to get around it without too much trouble.

Cheers,

Django