how to send bunch of records in codeunit by navwebservice

Ashish_GuptaAshish_Gupta Member Posts: 56
edited 2010-04-21 in NAV Three Tier
I made codeunit which is using record type field and use this codeunit on website by nav web services how to send bunch of filter records in codeunit. :(
Ashish Gupta
Navision Technical Consultant

Comments

  • tlarsontlarson Member Posts: 27
    It sounds like you want to insert multiple records into a table using Nav 2009 web services. Unfortunately, you can't pass record type variables as parameters to a CodeUnit-based web service. You'll need to create a web service based on a Page to do this. Then you can do CRUD (Create, Read, Update, Delete) operations on the table by calling the appropriate functions on the web service.

    Visit the documentation at http://msdn.microsoft.com/en-us/library/dd355316.aspx to see how to surface a Page-based web service.

    Tim Larson
  • mbjmbj Member Posts: 63
    Send the records in a xmldocument to the codeunit with the datatype bigtext. In C# you can easily transform the dt into xml.

    You can also use arrays parameters in the codeunit.
  • ChielChiel Member Posts: 32
    Use an XMLPort.
    This allows you to describe how the scructure needs te be uploaded to the server.
  • AdrianAkersAdrianAkers Member Posts: 137
    Your best bet is to use Pages.

    You can use Arrays, but this is really not a desired solution for passing records around. It is much more overhead and you will have problems if you try to use multi-dimensional arrays over the web services. Also you constantly have to code around the fact that NAV indexes at '1' and in nearly all other languages indexing is at '0'. Also in C# sharp you need to declare your Array with the correct number of elements, unlike VB.net where you can re-dimension your array... so if using an array in C# you need to know how big the array is that you are receiving back to declare it and get the contents.

    XMLDocument into BigText would work, but again you have the overhead handling your BigText on the NAV side, which you don't have with Pages. Transposing your dt->XML (and vice versa) is really easy in .NET however it is just as easy to create a generic function which takes your returned Page read Object and converts it to a data table or a data set (data table is quicker than data set).

    So use Pages from your project and then translate your returned page object to a data set or data table using a generic C# class.
  • HanenHanen Member Posts: 281
    Hi,

    I'm using navision customer webservice and calling the Create, Read, Update, Delete methods in a C# project (WCF Technology), I have a little problem calling the update and the delete methods :oops:
    How can I update the appropriate customer record? What's the right instruction to use to update and to delete a customer record?

    Thanks for your Help. :thumbsup:
    Regards

    Hanen TALBI
  • AdrianAkersAdrianAkers Member Posts: 137
    This is quite simple.

    Firstly Read the customer you want to update.

    Such as

    Customer myCustomer = ws.Read(pCustomerNo);

    Then set the fields you want to update such as

    myCustomer.Name = 'Joe Bloggs'

    then call

    ws.Update(ref myCustomer);

    Good Luck!
  • HanenHanen Member Posts: 281
    Thank you for your help but one more question the "pCustomerNo" is a key that I will choose how will I tell the WS that my key in this case is the customer No knowing That I have more than one key in my table :oops:
    Regards

    Hanen TALBI
  • AdrianAkersAdrianAkers Member Posts: 137
    Read will always be used when you are reading in one record. Similar to a GET in NAV. If you want to read in multiple records then you must use ReadMultiple passing in an array of filter values. You will then be returned a collection of records to work with.

    Hope that helps

    Adrian
  • HanenHanen Member Posts: 281
    Thank you so much for your help, I'm using that
     NAVCustomerServices.Customer NavClient = new HanenWcfServiceLibrary.NAVCustomerServices.Customer();
                
                //Creating Filter
                List<Customer_Filter> FilterArray = new List<Customer_Filter>();
                Customer_Filter FilterCompteFact = new Customer_Filter();
                FilterCompteFact.Field = Customer_Fields.No_Customer_Extranet;
                FilterCompteFact.Criteria = Customer_Extranet.RefCustomerNo;
                FilterArray.Add(FilterCompteFact);
    
                //Fields to Update
                NavClient.Address = Customer_Extranet.Rue;
                NavClient.City = Customer_Extranet.Ville;
                NavClient.E_Mail = Customer_Extranet.email;
                //.....................................
               NavCustomerService.Update(ref NavClient);
    
    
    Regards

    Hanen TALBI
  • AdrianAkersAdrianAkers Member Posts: 137
    But that code above can not be working properly right?

    You have applied some filters and called the update but you do not have the actual Customer record filters applied...

    Are you not getting problems with this code...?
  • HanenHanen Member Posts: 281
    No I'm getting the actual customer by parameter, it's passed with the method.
    :wink:
    Regards

    Hanen TALBI
  • AdrianAkersAdrianAkers Member Posts: 137
    So you are doing a Read on the Customer No. and then doing an update. So why do you have the code in the middle building the FilterArray as from what I can see you are not using this...
  • HanenHanen Member Posts: 281
    I'm Updating the Navision record customer related to the customer record coming from the extranet by parameter, so I have to read the customer form nav filtring on the Nav.No_Customer_Extranet= Customer_Extranet.RefCustomerNo
    Regards

    Hanen TALBI
  • AdrianAkersAdrianAkers Member Posts: 137
    Ok... so you are using code that is different to what you actually posted?

    Because I can't see that the code you posted will work as there is no Read or ReadMultiple.
Sign In or Register to comment.