NAV 2009 R2 Webservice Create problem

mihail_kolevmihail_kolev Member Posts: 379
edited 2012-12-28 in NAV Three Tier
Hello there,

I'm facing a problem when creating records in Navision. I create a contact like this:
Contacts Contact = new Contacts();
Contact.Name = String.Format("{0} {1}", FirstName, FamilyName);
Contact.Address_Floor = 2;
ContactsService.Create(ref Contact);

so far so good, but when I check the created contact, every integer field is left 0. Has anyone faced the problem (or am I doing it wrong :oops: )
-Mihail- [MCTS]

Answers

  • afarrafarr Member Posts: 287
    The integer fields in the Contact table are all flowfields. So you don't populate them in the Contact table itself - they are sums (or lookups, etc.) of fields from other tables.
    Alastair Farrugia
  • mihail_kolevmihail_kolev Member Posts: 379
    No, these are my custom fields. I'm pretty sure they are not flowfields ;) . The interesting thing is that the Text, Option, Code fields are updated with the Create method. But integer fields can be updated only by the Update method. Not a big pain for me, but this forces me to make two web service calls instead of just one.
    -Mihail- [MCTS]
  • yukonyukon Member Posts: 361
    Hi mihail_kolev,
    The interesting thing is that the Text, Option, Code fields are updated with the Create method. But integer fields can be updated only by the Update method. Not a big pain for me, but this forces me to make two web service calls instead of just one.

    You need to put below code in your code.
    Contact.Address_FloorSpecified = true;
    

    Example
    Contacts Contact = new Contacts();
    Contact.Name = String.Format("{0} {1}", FirstName, FamilyName);
    Contact.Address_FloorSpecified = true;
    Contact.Address_Floor = 2;
    ContactsService.Create(ref Contact);
    

    Best Regards,
    Yukon
    Make Simple & Easy
  • mihail_kolevmihail_kolev Member Posts: 379
    Didn't knew that, thank you very much =D>
    -Mihail- [MCTS]
Sign In or Register to comment.