Options

How to Get Key field through Nav Web Service

smic1983smic1983 Member Posts: 27
edited 2013-11-16 in NAV Three Tier
Hi this is Michael, I am developing one web application using Nav Web services, while updating the records through web service its throwing error like, the given key is not well formed, How can i get the correct key value of the specified record. Please do the needfull!!!!!!!!!!

Comments

  • Options
    ara3nara3n Member Posts: 9,255
    could you paste your code in here?
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • Options
    smic1983smic1983 Member Posts: 27
    Hi Rashed, thank u very much. I have solved that issue.I got the key value from reading the record through web service.
  • Options
    ara3nara3n Member Posts: 9,255
    that great. It would be nice to still put the code in here for other people to look if the run into the problem.
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • Options
    G8torG8tor Member Posts: 29
    I have this same problem in my c# program. Im consuming Nav webservice and trying to delete customer with my custom function. This is just test program.

    This is the c# code:
    Customer_Service custservice = new Customer_Service();
    custservice.UseDefaultCredentials = true;
    Customer Bolt = custservice.Read("9999999998");
    custservice.DeleteCustomer(Bolt.No); // this function was made by me in codeunit

    This is the codeunit code:
    DeleteCustomer(CustomerID : Record Customer)

    Cust.GET(CustomerID);
    Cust.DELETE;

    I get an error "Key '9999999998' is not well formed" in the c# program. Any ideas of why this happens?
  • Options
    SogSog Member Posts: 1,023
    That's because you set the parameter as a record in the codeunit (customerID of type record customer), however the parameter you send to the function is code20 (Bolt.No)
    |Pressing F1 is so much faster than opening your browser|
    |To-Increase|
  • Options
    G8torG8tor Member Posts: 29
    Ok. I see.

    But in the c# code. What do I pass in for the record parameter in the Nav fuction?

    The reason for this test project is to try how to extend page web service with custom codeunit functions.
    For me to do that I have to have same record on the first parameter in the codeunit as for the page source and name it the same as published page in form 810 "Web service". I dont neccessary want to use this first parameter but to extend the page I have to.

    So how can I use this record parameter in c# code?

    Hope you understand what im trying to do.
  • Options
    G8torG8tor Member Posts: 29
    I found out the solution how to pass into the record parameter in the c# code.
    I have to use Customer.Key in the parameter.

    This is the correct c# code:

    Customer_Service custservice = new Customer_Service();
    custservice.UseDefaultCredentials = true;
    Customer Bolt = custservice.Read("9999999998");
    custservice.DeleteCustomer(Bolt.Key); // this function was made by me in codeunit


    Thanks Sog for your help. :thumbsup:
  • Options
    G8torG8tor Member Posts: 29
    I see that smic1983 had probably answered this in previous post. But I didnt get it then.
  • Options
    DRBDRB Member Posts: 105
    Hi,
    I am facing similar issue "Key is not well formed" while updating Item record using web-services.
    Please help me in resolving it.
    -Dhan Raj Bansal
    Linkedin Profile: http://in.linkedin.com/in/dhanrajbansal
Sign In or Register to comment.