I'd like to create a contact using the Web Service exposed by the contact card.
In NAV we have set automatic contact ID creation.
What do I need to pass as contact.no_ to the web service?
contact.no_ = "" is bad, because the primary key is missing
contact.no_ = "99999" is bad, because I must not pass a contact number
Is there another property I need to set?
Thanks in advanced
Since the C/AL code is handling that, try to not pass the contact.no_ field at all, just comment that line out and set the other fields you want. The C/AL code should handle getting the key then to create a new record, at least in my testing that worked out just fine if just creating a single record.
I do not know of a perfect way to know all required fields programatically. You have to look at key fields (even then like in your above example it may not be required based on setups), or look at code to see if any C/AL is requiring. In the end just going through the GUI if using a Page is probably the easiest or if a Codeunit, then just looking at code. Unless someone has come up with a better way, I do not know of a way to know for all possibilities. In the Table Designer if you export the tables, there is the NotBlank property you can look at, but again, that doesn't cover every scenario.
thanks for the answer. Is there a way to find out the required fields that I need to pass to the Web Service? I tried just to pass in the contact type "company" and a name but I got an error saying that at least one field was missing.
Thanks for your help
I'm going to have a look at the table designer. Well, I can always try to add one field after the other, or first fill in the fields I want to fill in anyways and then go ahead and fill fields until NAV is satisfied.
Other Microsoft Sites
I'm a Customer
I'm a Partner
Use the official Twitter tags:
#MSDYNCOMM | #CONV13