NAV 2009 webservices, create method and missing field values

Stefan_MStefan_M Member Posts: 6
edited 2009-04-24 in NAV Three Tier
Hi,
I'm fairly new to NAV 2009 and right now i'm having a problem.
Perhaps someone here has an idea how to solve it.

I exposed a NAV Page (Output Journal, ID 99000823) as a webservice.

Now i am trying to insert a line into the Output Journal via the create method of the webservice in a c# program.

Generally it works. A new line is created in the Output Journal and most of the fields are populated with the values I assigned in my program.

And here is my problem: There are some fields that are not updated at all, no matter what I do. Namely the fields for "Output_Quantity" and "Scrap_Quantity".
Their values remain 0, no matter what values I assigned in c#.

Here is a little bit of my c#-code to show what i am doing:
Output_Journal_Service ojs = new Output_Journal_Service();
            ojs.UseDefaultCredentials = true;
            Output_Journal oj = new Output_Journal();
            ...
            oj.Posting_Date = DateTime.Today;
            ...
            oj.Output_Quantity = 42; // no matter what value is assigned, in the database/NAV client it is always 0
            oj.Scrap_Quantity = 2;  // here the same
            ...
            ojs.Create("STANDARD", ref oj);

Any ideas? Am I missing a step or is it a bug?

Comments

  • kinekine Member Posts: 12,562
    I recommend the same way how you are inserting the line in C/AL:

    1) Fill the Primary key fields (excluding line no.)
    2) Insert the record into table
    3) Fill rest of the fields
    4) Modify the record
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • Stefan_MStefan_M Member Posts: 6
    Thanks kine, that did it. :D

    My code looks now something like this:
    Output_Journal_Service ojs = new Output_Journal_Service();
                ojs.UseDefaultCredentials = true;
                Output_Journal oj = new Output_Journal();
                ...
                oj.Posting_Date = DateTime.Today;
                ...
                ojs.Create("STANDARD", ref oj);
                ...
                oj.Output_Quantity = 42;
                oj.Scrap_Quantity = 2; 
                ...
                ojs.Update("STANDARD", ref oj); 
    

    It seems that some values can already be assigned before the create statement.
    But others require to be assigned after the create and then require an update statement.
Sign In or Register to comment.