How to insert Option datatype field by using webservices?

Ashish_GuptaAshish_Gupta Member Posts: 56
edited 2009-09-30 in NAV Three Tier
I have made webservice and also create object to create record in navision database but my table contain option datatype field?
how to insert the value form asp.net with c#.net using webservice. ](*,)
Ashish Gupta
Navision Technical Consultant

Answers

  • matttraxmatttrax Member Posts: 2,309
    An option is just an integer. You'll need to map your options to their integer values and insert them.
  • ara3nara3n Member Posts: 9,255
    line1.Type = SalesOrderRef.Type.Item;


    You can look on this post as example

    http://blogs.msdn.com/freddyk/archive/2 ... d-rtm.aspx
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • Ashish_GuptaAshish_Gupta Member Posts: 56
    i want to fill gender field which is option datatype in navision table through the drop down list in asp.net with c#,net .
    contact.Gender =ddl_gender.SelectedValue.ToString()

    i got error
    Cannot implicitly convert type 'string' to 'ContactCardservice.Gender'

    help me ](*,)
    Ashish Gupta
    Navision Technical Consultant
  • ara3nara3n Member Posts: 9,255
    here is an example on how to create a customer record. I'm assuming the values for Option to be Male Female.
    MyContact.Contact_Service ContWS = new WebServiceApp.MyContact.Contact_Service();
    ContWS.UseDefaultCredentials = true;
    MyContact.Contact MyCont = new WebServiceApp.MyContact.Contact();
    MyCont = ContWS.Read("10000");
    MyCont.Name = "New Name";
    MyCont.Gender  = MyContact.Gender.Male;
    ContWS.Update(ref MyCont);
    

    Since in your app the option are string, you need to compare string and then assign it.

    if MyContact.Gender.Male.toString = ddl_gender.SelectedValue.ToString then
    MyCont.Gender = MyContact.Gender.Male
    else
    MyCont.Gender = MyContact.Gender.Female


    I don't have VS in front of me to confirm this.
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
Sign In or Register to comment.