Retrieves a single bank object based on the bank key value supplied.
Parameter |
Type |
Description |
---|---|---|
key |
The bank key object that specifies the bank to retrieve. |
|
context |
Specifies information about how the method will be called. |
Value |
Type |
Description |
---|---|---|
GetBankByKeyResult |
A bank object. |
The following C# example retrieves the bank object with the key value “TEST BANK”. This example requires a bank named “TEST BANK” to be manually created. A message box displays the bank name.
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; BankKey bankKey; Bank bank; // 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 bank key object to specify the bank bankKey = new BankKey(); bankKey.Id = "TEST BANK"; // Retrieve the bank object bank = wsDynamicsGP.GetBankByKey(bankKey, context); // Display the name property from the bank object MessageBox.Show("Bank name: " + bank.Name); } } }
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; BankKey bankKey; Bank bank; // 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 bank key object to specify the bank bankKey = new BankKey(); bankKey.Id = "TEST BANK"; // Retrieve the bank object bank = wsDynamicsGP.GetBankByKey(bankKey, context); // Display the name property from the bank object MessageBox.Show("Bank name: " + bank.Name); // Close the service if(wsDynamicsGP.State != CommunicationState.Faulted) { wsDynamicsGP.Close(); } } } }