Retrieves a list of item currency objects that meet the specified criteria.
Parameter |
Type |
Description |
---|---|---|
criteria |
The item currency criteria object that specifies which item currency objects to retrieve. |
|
context |
Specifies information about how the method will be called. |
Value |
Type |
Description |
---|---|---|
GetItemCurrencyListResult |
A list of the item curency objects that match the specified criteria. |
The following C# example retrieves the list of item currency objects with an ItemId containing “SDRam”. A message box displays the item ID and the currency ISO code for each member of the list.
Legacy endpoint
using System; using System.Collections.Generic; using System.Text; using System.Windows.Forms; using DynamicsGPWebServiceSample.DynamicsGPService; namespace DynamicsGPWebServiceSample { class Program { static void Main(string[] args) { CompanyKey companyKey; Context context; LikeRestrictionOfString itemRestriction; ItemCurrencyCriteria itemCurrencyCriteria; ItemCurrency[] itemCurrencies; // Create an instance of the service DynamicsGP wsDynamicsGP = new DynamicsGP(); // Be sure the default credentials are used wsDynamicsGP.UseDefaultCredentials = true; // Create a context with which to call the service context = new Context(); // Specify which company to use (sample company) companyKey = new CompanyKey(); companyKey.Id = (-1); // Set up the context object context.OrganizationKey = (OrganizationKey)companyKey; // Create a restriction object // Retrieve items containing string 'SDRam' itemRestriction = new LikeRestrictionOfString(); itemRestriction.Like = "%SDRam%"; // Create an item currency criteria object itemCurrencyCriteria = new ItemCurrencyCriteria(); itemCurrencyCriteria.ItemId = itemRestriction; // Retrieve the list of item currency objects itemCurrencies = wsDynamicsGP.GetItemCurrencyList(itemCurrencyCriteria, context); // Display the item ID and currency ISO code for each member of the summary object list StringBuilder summaryList = new StringBuilder(); foreach (ItemCurrency a in itemCurrencies) { summaryList.AppendLine("Item: " + a.Key.ItemKey.Id + " Currency ISO code: " + a.Key.CurrencyKey.ISOCode.ToString()); } MessageBox.Show(summaryList.ToString()); } } }
Native endpoint
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Windows.Forms; using DynamicsGPWebServiceSample.DynamicsGPService; namespace DynamicsGPWebServiceSample { class Program { static void Main(string[] args) { CompanyKey companyKey; Context context; LikeRestrictionOfstring itemRestriction; ItemCurrencyCriteria itemCurrencyCriteria; ItemCurrency[] itemCurrencies; // Create an instance of the service DynamicsGPClient wsDynamicsGP = new DynamicsGPClient(); // Create a context with which to call the service context = new Context(); // Specify which company to use (sample company) companyKey = new CompanyKey(); companyKey.Id = (-1); // Set up the context object context.OrganizationKey = (OrganizationKey)companyKey; // Create a restriction object // Retrieve items containing string 'SDRam' itemRestriction = new LikeRestrictionOfstring(); itemRestriction.Like = "%SDRam%"; // Create an item currency criteria object itemCurrencyCriteria = new ItemCurrencyCriteria(); itemCurrencyCriteria.ItemId = itemRestriction; // Retrieve the list of item currency objects itemCurrencies = wsDynamicsGP.GetItemCurrencyList(itemCurrencyCriteria, context); // Display the item ID and currency ISO code for each member of the summary object list StringBuilder summaryList = new StringBuilder(); foreach (ItemCurrency a in itemCurrencies) { summaryList.AppendLine("Item: " + a.Key.ItemKey.Id + " Currency ISO code: " + a.Key.CurrencyKey.ISOCode.ToString()); } MessageBox.Show(summaryList.ToString()); // Close the service if(wsDynamicsGP.State != CommunicationState.Faulted) { wsDynamicsGP.Close(); } } } }