Wrong date Updation in webservices
Ashish_Gupta
Member Posts: 56
I am using webservices to create a record in NAV Customized table having a primary key and couple of text fields and couple of dates. The primary key and the text fields are getting created correctly but the date field is getting intialized to 01/01/01. When I am modifying the record the date is correctly updated. I have written the same code in both the functions but ](*,)
My code is as follow
Create Code:
Any help will be greatly appreciated.
My code is as follow
Create Code:
protected void Btn_InsertStream_Click(object sender, EventArgs e)
{
StreamList_Service stream = new StreamList_Service();
stream.UseDefaultCredentials = true;
StreamList newstream = new StreamList();
newstream.Code = txt_code.Text;
newstream.Description = Txt_Description.Text;
newstream.Description_2 = Txt_Description2.Text;
newstream.Start_Date = Convert.ToDateTime(Txt_startdate.Text);
newstream.End_Date = Convert.ToDateTime(Txt_Enddate.Text);
stream.Create(ref newstream);
Response.Redirect("Streams.aspx");
}
update codeprotected void btn_Update_Click(object sender, EventArgs e)
{
StreamList_Service stream = new StreamList_Service();
stream.UseDefaultCredentials = true;
StreamList newstream = new StreamList();
newstream.Code = txt_code.Text;
newstream = stream.Read(newstream.Code);
newstream.Description = Txt_Description.Text;
newstream.Description_2 = Txt_Description2.Text;
newstream.End_Date = Convert.ToDateTime(Txt_Enddate.Text);
newstream.Start_Date = Convert.ToDateTime(Txt_startdate.Text);
stream.Update(ref newstream);
Response.Redirect("Streams.aspx");
}
Any help will be greatly appreciated.
Ashish Gupta
Navision Technical Consultant
Navision Technical Consultant
0
Answers
-
You need to set
newstream.Start_DateSpecified = true;
newstream.End_DateSpecified = true;
when creating the record.
These variables tells Visual studio which values it should include when sending data over the wire to NAV.
Reason why your update works is, that when you get the record back you get all fields (and all xxxSpecified = true).
xxxSpecified does not exist for string fields - these fields can be set to NULL in order to specify that you don't want it send over the wire.Freddy Kristiansen
Group Program Manager, Client
Microsoft Dynamics NAV
http://blogs.msdn.com/freddyk
The information in this post is provided "AS IS" with no warranties, and confers no rights. This post does not represent the thoughts, intentions, plans or strategies of my employer. It is solely my opinion.0 -
freddy.dk wrote:You need to set
newstream.Start_DateSpecified = true;
newstream.End_DateSpecified = true;
when creating the record.
These variables tells Visual studio which values it should include when sending data over the wire to NAV.
Reason why your update works is, that when you get the record back you get all fields (and all xxxSpecified = true).
xxxSpecified does not exist for string fields - these fields can be set to NULL in order to specify that you don't want it send over the wire.
Very insteresting... is this described somewhere in the documentation? ;-)0 -
Probably in the Visual Studio documentation as these variables determines what will be send over the wire to Web Services from your C# app.Freddy Kristiansen
Group Program Manager, Client
Microsoft Dynamics NAV
http://blogs.msdn.com/freddyk
The information in this post is provided "AS IS" with no warranties, and confers no rights. This post does not represent the thoughts, intentions, plans or strategies of my employer. It is solely my opinion.0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.7K Microsoft Dynamics NAV
- 18.8K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 328 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions
