Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Description
Retrieves a list of company objects for which the current user is assigned to at least one security role, allowing them to run service methods.
Parameters
Parameter |
Type |
Description |
|---|---|---|
context |
Specifies information about how the method will be called. |
Return Value:
Value |
Type |
Description |
|---|---|---|
GetWSEnabledCompanyForUserListResult |
The collection of company objects for which the user is able to run methods. |
Interfaces
- Dynamics GP
- Common
- Field Service
- Financials
- Human Resources/Payroll
- Inventory
- Manufacturing
- Project Accounting
- Purchasing
- Sales
Examples
The following C# example displays a list of all companies the current user can run web methods in.
** 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)
{
Context context;
Company[] companies;
// 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();
// Set up the context object
context.OrganizationKey = null;
// Retieve the list of companies enabled for the current user
companies = wsDynamicsGP.GetWSEnabledCompanyForUserList(context);
// Display the list of companies
StringBuilder companyList = new StringBuilder();
foreach (Company c in companies)
{
companyList.AppendLine(c.Name);
}
MessageBox.Show(companyList.ToString());
}
}
}
** Native endpoint **
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;
using System.Windows.Forms;
using DynamicsGPWebServiceSample.DynamicsGPService;
namespace DynamicsGPWebServiceSample
{
class Program
{
static void Main(string[] args)
{
Context context;
Company[] companies;
// Create an instance of the service
DynamicsGPClient wsDynamicsGP = new DynamicsGPClient();
// Create a context with which to call the service
context = new Context();
// Set up the context object
context.OrganizationKey = null;
// Retieve the list of companies enabled for the current user
companies = wsDynamicsGP.GetWSEnabledCompanyForUserList(context);
// Display the list of companies
StringBuilder companyList = new StringBuilder();
foreach (Company c in companies)
{
companyList.AppendLine(c.Name);
}
MessageBox.Show(companyList.ToString());
// Close the service
if(wsDynamicsGP.State != CommunicationState.Faulted)
{
wsDynamicsGP.Close();
}
}
}
}