Creating an instance of an option field when using Webservic

marvinqvist
Member Posts: 53
Hi,
I am programming a C# application which uses Webservices to perform som Nav logics remotely.
I have a problem when I want to create e.g. new jobs in Nav from the client if the object contains option-fields (e.g. status). The webservice wants an instance of the option-field. But how can I create such an instance??
At the moment I write to a codeunit via webservice, an asks the codeunit to validate an integer into the option-field. It works, but it is an annoying workaround.
Anyone got a hint on how to solve this problem smoothly.!?
Thanks in advance.
/MQ
I am programming a C# application which uses Webservices to perform som Nav logics remotely.
I have a problem when I want to create e.g. new jobs in Nav from the client if the object contains option-fields (e.g. status). The webservice wants an instance of the option-field. But how can I create such an instance??
At the moment I write to a codeunit via webservice, an asks the codeunit to validate an integer into the option-field. It works, but it is an annoying workaround.
Anyone got a hint on how to solve this problem smoothly.!?
Thanks in advance.
/MQ
0
Comments
-
Here is an example.
MyVendor.Vendor_Service VendWS = new WebServiceApp.MyVendor.Vendor_Service(); VendWS.UseDefaultCredentials = true; MyVendor.Vendor MyVend = new WebServiceApp.MyVendor.Vendor(); MyVend = VendWS.Read("10000"); MyVend.Blocked = MyVendor.Blocked.Ship; VendWS.Update(ref MyVend);
0 -
Hi ara3n,
The syntax is a little different from what I am using. Just to make it clear.. What is MyVendor and WebServiceApp in your code example?
/MHQ0 -
MyVendor is the name of web service reference.
It's the name of the I gave to the web service reference when I selected the Vendor Page from published Nav services.0 -
Aaah...
Now I get it... I was doing it the right way... I did not know that the options were trigged with the dot.
e.g. ".Ship". I thought it was something like Blocked(Ship).
Thanks a lot.!0 -
You are welcome. :P0
-
Hi ,
Please who can tell me how can I fill out a dropdown list in C# with the values of an option field.
I'm using web services.
Thanks0 -
Hi sbilly,
Try with this method.public static void SetEnumSalesLineTypeCombo(DropDownList ctlDropDownList) { if (ctlDropDownList != null) { ArrayList _EnumList = new ArrayList(); foreach (string _EnumName in Enum.GetNames(typeof(wsSalesQuoteWeb.Type))) _EnumList.Add(new global_fun.AddEnumValue(global_fun.CultureTextFormats.ToTitleCase(_EnumName.Replace("_", " ")), _EnumName));//Replacing "_" to Blank. ctlDropDownList.DataTextField = "Display"; ctlDropDownList.DataValueField = "Value"; ctlDropDownList.DataSource = _EnumList.ToArray(); ctlDropDownList.DataBind(); } //wsSalesQuoteWeb is your WebService Sales Quote, Sales Order etc,... } public class CultureTextFormats { public static string ToTitleCase(String Text) { System.Globalization.CultureInfo cultureInfo = System.Threading.Thread.CurrentThread.CurrentCulture; System.Globalization.TextInfo textInfo = cultureInfo.TextInfo; return textInfo.ToTitleCase(Text.ToLower()); } public CultureTextFormats() { //Do Something } }
Hope this help.
Best Regards,
YukonMake Simple & Easy0 -
hai all,
i found this thread is very useful. 2 questions though:
1. do we need to translate the "_" to its relevant caption in the option field ("G_L_Account" => "G/L Account", "_blank_" => " ")? or is there any way to retrieve the actual caption string in the option field?
2. say user using the combo box and choose a value (e.g.: "G_L_Account"), what value I must use to create / update the records using webservice?
Regards,
Philipus0 -
Hi philipuskd,1. do we need to translate the "_" to its relevant caption in the option field ("G_L_Account" => "G/L Account", "_blank_" => " ")? or is there any way to retrieve the actual caption string in the option field?
Specially, we no need to change it. But i changed the option caption because of i want to show like "NAV" option style.
We can't directly get caption from WS. Other way you can be use other method.2. say user using the combo box and choose a value (e.g.: "G_L_Account"), what value I must use to create / update the records using webservice?
You can get value from value from your combo follow this way.wsSalesLine.Type typItemType = ((wsSalesLine.Type)Enum.Parse(typeof(wsSalesLine.Type), _cboItemType.SelectedValue.ToString()));
Regards,
YukonMake Simple & Easy0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K 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
- 320 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