Options

Problems inserting Job Task through Page Webservice

nf81nf81 Member Posts: 2
edited 2012-04-16 in NAV Three Tier
Hi everyone,

I have exposed Page 1002 as a web service and want to read (works like a charm) but also insert Job Tasks through an ASP.NET application.

This is the code snippet I'm using:
                try
                {
                    Job_Planning_Line_Line line = new Job_Planning_Line_Line();
                    line.Description = description;
                    line.Job_Task_No = lineNo;
                    line.Job_No = projectNo;
                    line.Planning_DateSpecified = true;
                    line.Planning_Date = DateTime.Now;
                    //line.No = "MARLIES";
                    //line.Quantity = hours;
                    
                    
                    List <Job_Planning_Line_Line> lines = new List<Job_Planning_Line_Line>();
                    lines.Add(line);

                    ProjectLines pl = new ProjectLines();
                    pl.Job_No = projectNo;
                    pl.Job_Planning_Line_Line = lines.ToArray();
                    pl.Description = description;
                    pl.Job_Task_No = lineNo;
                    pl.Job_Task_Type = Job_Task_Type.Posting;

                    service.Create(ref pl);

                    pl.Job_Planning_Line_Line[0].No = "MARLIES";                 
                    pl.Job_Planning_Line_Line[0].Quantity = hours;

                    service.Update(ref pl);
                }
                catch (Exception ex)
                {
                    System.Diagnostics.Debug.WriteLine(ex.ToString());
                    //throw ex;
                }

Inserting the Job Task alone works great. I also want to insert a Job Planning Line at the same time, but as soon as i try to set the "(Resource)No." i get this error:
System.Web.Services.Protocols.SoapException: Property "Editable" for Job Planning Line Subform is invalid!

It makes no difference if i set it before the "Create" or afterwards and then call "Update". When i check the properties of the "No." Field in the subform mentioned the value of Editable is the global "No.Editable" which is set to True in OnInit of the page. So i guess OnInit is not called when operating with page webservices?

What possibilities do i have to work around this? Setting "Editable" to True is not an option and i wan't avoid creating Codeunit Webservices as much as possible (actually i'm no Dynamics NAV developer at all :)).

Comments

  • Options
    Fred_CleverFred_Clever Member Posts: 11
    Hi.

    The field is not editable in the page!!!
    Set the page Editable=true.

    Also other fields.
  • Options
    kinekine Member Posts: 12,562
    Or, use new page for the webservices. It is much better. In this way, when somebody change the page because he need to add/remove field for the user, it will crash your app. Keeping the Webservice pages as separate pages from the RTC used one, youhave much better control over the WS interface...
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
Sign In or Register to comment.