CFront.Net – Searching for records - Error 1246279

Lulu00Lulu00 Member Posts: 7
There is a post on the forum with a similar problem but it hasn’t been asnswered so I have created another topic.

I am using the Cfront.Net Api within an Asp.net aaplication.
I get the error 1246279 with no descripttive message when searching for records in some tables :
cFront.SetFilter(table, 3, "=37615");
cFront.FindRecord(table, record, false, false);

It’s the only set filter.
The record exists. I tried to allow all Navision errors but it doesn’t change anything.


Now, if I change the number to:
cFront.SetFilter(table, 3, "=2889");
cFront.FindRecord(table, record, false, false);

It works. But number 1001 makes an error.

I once had an error message:
1246279 - Error Message: There is no Purchase Line within the filter. Filters: Document No.: =2889

Which is a false statement.

If anyone has experienced the same issue and dealt with it I would appreciate any help given.

Answers

  • kinekine Member Posts: 12,562
    for me it seems like the C/Front takes whole string as the document no.

    Try to use just
    cFront.SetFilter(table, 3, "37615");
    cFront.FindRecord(table, record, false, false); 
    

    or try to add aphostrophe
    cFront.SetFilter(table, 3, "='37615'");
    cFront.FindRecord(table, record, false, false); 
    
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • Lulu00Lulu00 Member Posts: 7
    Sorry! I forgot to mention that have already been trying different syntaxes (including the one you give):
    cFront.SetFilter(table, 3, "='37615'");
    cFront.SetFilter(table, 3, "=37615");
    cFront.SetFilter(table, 3, "'37615'");
    

    I tried using the SetRange method too.
  • kinekine Member Posts: 12,562
    And still same result or some differences? Have you tried the version with just:
    cFront.SetFilter(table, 3, "37615");
    
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • Lulu00Lulu00 Member Posts: 7
    edited 2006-08-29
    Double post.
  • Lulu00Lulu00 Member Posts: 7
    Yes I tried that one too (the first one I tried in fact, forgot to mention it).

    And I get the same error message each time.When I restart the asp.net test server, the first time I run the code the message is more detailed (like the one in the first post):
    Error Code: 1246279 - Error Message: There is no Purch. Inv. Line within the filter. Filters: Document No.: 37615
    
  • kinekine Member Posts: 12,562
    1) To be sure... please check, on which DB you are connected.
    2) In your first message you are working with the table "Purchase Line". In your last message you are talking about table "Purch. Inv. Line". Which table you checked for existency of this record??? Open the DB through Navision client and check the correct table for correct record once again...
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • Lulu00Lulu00 Member Posts: 7
    1) Triple checked at least!

    2) I have been playing with different tables, and the last error message is correct actually there is no such record. I got mixed up somewhere.

    I have redone my testing again and know it seems to work !
    //Purchase header table
    int table = cFront.OpenTable(38);
    int record = cFront.AllocRecord(table);            
    cFront.SetFilter(table, 3, "='37615'");
    cFront.FindSet(table, record, false, false);
    

    I can use any of the following syntax :
    cFront.SetFilter(table, 3, "='37615'");
    cFront.SetFilter(table, 3, "'37615'");
    cFront.SetFilter(table, 3, "37615");
    cFront.SetFilter(table, 3, "=37615");
    

    Now the error message I mentioned:
    1246279 - Error Message: There is no Purchase Line within the filter. Filters: Document No.: =2889
    

    Is actually valid (am I mad?). I think I’ve been making up all this (maybe I need some rest ?).Thanks for asking me to redo everything !

    I noticed a strange behaviour from the Api where I got error messages related to tables I wasn’t trying to access (but I had just before). In fact the error message was the last I had regardless of the new parameters.
    Restarting the asp.net test server seemed to solve the problem.

    Actually I just trapped this behaviour !
    //39 = Purchase Line
    int table = cFront.OpenTable(39);            
    cFront.SetFilter(table, 3, "2889");
    

    Throws an error: it’s valid.
    //38 = Purchase header
    int table = cFront.OpenTable(38);            
    cFront.SetFilter(table, 3, "2889");
    

    Throws the same error but the table is different (there should be an error though) !
    Error Code: 1246279 - Error Message: There is no Purchase Line within the filter. Filters: Document No.: 2889
    

    I restart the Asp.net test server, run the code and I get:
    Error Code: 1246279 - Error Message: There is no Purchase Header within the filter. Filters: No.: 2889
    

    Which is valid. The only thing I can say is that I don’t call the CloseTable or CloseTable methods yet (debugging stage). The test server even get’s unstable and crashes after a while (tries to write in protected memory).

    Also, I don’t understand why an error is raised with the following code :
    //Purchase header table
    int table = cFront.OpenTable(38);//123            
    int record = cFront.AllocRecord(table);            
    cFront.SetFilter(table, 3, "2889");
    cFront.Allow(NavisionAllowedError.RecordNotFound);
    cFront.Allow(NavisionAllowedError.RecordExists);
    cFront.Allow(NavisionAllowedError.TableNotFound);
    cFront.Allow(NavisionAllowedError.KeyNotFound);
    cFront.FindFirstRecord(table, record);
    cFront.FindSet(table, record, false, false);
    

    Gets the following error :
    Error Code: 1246279 - Error Message: There is no Purchase Line within the filter. Filters: Document No.: 2889
    

    Why is the error raised (or the Allow method is unclear for me) ?

    Thanks again for you answers to what was obviously only wrong in my poor mind.
  • kinekine Member Posts: 12,562
    Check the documentation for the CFront. If you want to suppress the error, you need to use the return value from the function... something like:
    Cf.AllowRecordNotFound
    Ret = Cf.FunctionThatSearchesForRecord
    If Ret <> TRUE Then
      ' handle error
    
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • Lulu00Lulu00 Member Posts: 7
    Thanks a lot !
    Not a very constructive topic but I really spent a lot of time lost in my false errors before posting here.
    :oops:

    Not to be cheeky but the 85132272 error code allowed by the Allow method is not really the same as the 1246279 raised error code.
  • kinekine Member Posts: 12,562
    Take it easy... :-)

    It is common, that if you do not know where is the problem, after "look from outside" you find it... (I am asking my co-workers nearly each day for help and right after the question, I see the error clearly...).

    I am not using C/Front, I do not know the error nos. or their meanings. But for me it seems like if you are not using the return value, you will have error although you set to allow the error... 8)
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
Sign In or Register to comment.