private void textBox1_TextChanged(object sender, EventArgs e) { Sales_Order_Service ss1 = new Sales_Order_Service(); Sales_Order so1 = new Sales_Order(); ss1.Url = "http://isplserver:7047/DynamicsNAV/WS/CRONUS_India_Ltd/Page/Sales_Order"; ss1.UseDefaultCredentials = true; so1.No = textBox1.Text; so1 = ss1.Read("Order", so1.No); textBox3.Text = so1.Sell_to_Customer_No; textBox2.Text = so1.Sell_to_Post_Code; textBox4.Text = so1.Sell_to_City; } private void textBox2_TextChanged(object sender, EventArgs e) { Sales_Order_Service ss1 = new Sales_Order_Service(); Sales_Order so1 = new Sales_Order(); ss1.Url = "http://isplserver:7047/DynamicsNAV/WS/CRONUS_India_Ltd/Page/Sales_Order"; ss1.UseDefaultCredentials = true; so1.No = textBox1.Text; so1 = ss1.Read("Order", so1.No); so1.Sell_to_Post_Code = textBox2.Text; ss1.Update(ref so1); textBox3.Text = so1.Sell_to_Customer_No; textBox2.Text = so1.Sell_to_Post_Code; textBox4.Text = so1.Sell_to_City; }
Comments
I have just tried the following code:
SalesOrder_Service service = new SalesOrder_Service();
service.UseDefaultCredentials = true;
SalesOrder so = service.Read("1017");
so.Sell_to_Post_Code = "B68 5TT";
service.Update(ref so);
MessageBox.Show(so.Sell_to_City);
and that works as expected - the city is updated.
The confusing thing for me is your Read which takes two parameters? ("Order", so1.no)
What is that?
I just exposed page 42 to web services and then the above code runs.
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.
In this case
so1.Sell_to_Post_Code = textBox2.Text;
so1.Sell_to_City = null ;
ss1.Update(ref so1);
Yes, I was running a pre-release of NAV2009 SP1 and I didn't know that anything was fixed in this area at all.
I tested on my RTM server and you are right:
so1.Sell_to_Post_Code = textBox2.Text;
so1.Sell_to_City = null ;
ss1.Update(ref so1);
will work (and I tested that this will work in SP1 as well).
The null'ing of the city field shouldn't be necessary in SP1 though.
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.
Thank you all for your replies.
I got your point. I also thought the same.
But, It is not a feasible sollution.
For e.g.
I open Sales Order having No. = 100 ,Sell-To Customer No. = 123, Sell-To Post Code = 123456.
Now, If I want to update Customer No. then I will require to null all other fields except Sell-To Customer No.
Now, I want to update Post Code then again I will have to do the same except for Sell-To Post Code.
And such process would be very time consuming, and infeasible.
If Any other sollution is there then please suggest.
Thanks.
Ahmedabad, Gujarat, India
E Mail : ravi.thakkar@hotmail.com
Ahmedabad, Gujarat, India
E Mail : ravi.thakkar@hotmail.com
Will this work?
Is there any other option?
Ahmedabad, Gujarat, India
E Mail : ravi.thakkar@hotmail.com
http://blogs.msdn.com/freddyk/archive/2009/05/28/handling-sales-orders-from-page-based-web-services-in-nav-2009sp1-and-rtm.aspx
That should explain how you can overcome this
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.
we are big fan of your blogs here in australia.The code to run in NAV 2009 RTM (which i copied from your blog directly)would give me two types of errors
1.Sell to Customer No cannot be Blank is sales header as the PrepareforUpdate method also nulls the "Sell to Customer No ".Therefor iam calling PrepareforUpdate() and then Sellto Customer No="10000"; and then service.update(ref neworder) as shown in modified code below
2.After Modifying the code as shown below i am able to create the Sales Orders in NAV 2009 successully.However it doesnt update the Quantity=3; part of the code.I even tried to make it Quantity=3.0m; as quantiy is decimal not integer but why doesnt it update the Quantity even then?
static void Main(string[] args)
{
//create service references
SalesOrder_Service service = new SalesOrder_Service();
service.UseDefaultCredentials = true;
service.Url = "http://ac-dc:7047/DynamicsNAV/WS/CRONUS_Australia_Pty_Ltd/Page/SalesOrder";
SalesOrder newOrder = new SalesOrder();
service.Create(ref newOrder);
//*
SalesOrder copy = (SalesOrder)(newOrder);
PrepareForUpdate(newOrder, copy);
newOrder.Sell_to_Customer_No = "10000";
service.Update(ref newOrder);
copy = (SalesOrder)GetCopy(newOrder);
PrepareForUpdate(newOrder, copy);
newOrder.SalesLines = new Sales_Order_Line[2];
for (int idx = 0; idx < 2; idx++)
{
newOrder.SalesLines[idx] = new Sales_Order_Line();
}
Sales_Order_Line line1 = newOrder.SalesLines[0];
line1.Type = SO.WebService.Type.Item;
line1.No = "1900-S";
line1.Quantity = 3;
line1.Description = "GD ITEM1 SSSS";
Sales_Order_Line line2 = newOrder.SalesLines[1];
line2.Type = SO.WebService.Type.Item;
line2.No = "1000";
line2.Description = "GD ITEM2S UIJJJK";
line2.Quantity =3;
service.Update(ref newOrder);
Console.WriteLine("Created Sales Orders");
Console.ReadKey();
}
}
}
GD
Thanks for your response. Yes, I have already read your well prepared Blogs.
But, I think you have written about some UPDATE functionality related to NAV 2009 SP1.
And I think SP1 is not released yet. Am I right here????? :?: :?:
Can I use the same update functionality for NAV 2009 ?
Ahmedabad, Gujarat, India
E Mail : ravi.thakkar@hotmail.com
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.
I have applied your technique and have succeded to certain extent and these are my findings.please comment
GD
I do not have a RTM installation right now, so I cannot test it - but it seems like you have removed some lines.
Basically for every time you call service.update - you need to call prepareforupdate before service.update and getcopy after - and then use whatever you got from getcopy to work with.
That should work....
(note the very political: should!)
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.
Thanks for your reply.
Really a great job done in Blog and Logic for Updating the Values. Great. =D> =D> =D>
Whether the Concurrency in updating the Fields by the Method specified by you in Blog, handled by System automatically or need to be handled Manually?
Ahmedabad, Gujarat, India
E Mail : ravi.thakkar@hotmail.com
Ahmedabad, Gujarat, India
E Mail : ravi.thakkar@hotmail.com