GetWSEnabledCompanyForUserList
TOC
Collapse the table of content
Expand the table of content

GetWSEnabledCompanyForUserList

Dynamics

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

Context

Specifies information about how the method will be called.


Return Value:

Value

Type

Description

GetWSEnabledCompanyForUserListResult

ArrayOfCompany

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.

Cc508667.LegacyEndpoint(en-us,MSDN.10).gif 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());
        }
    }
}

Cc508667.NativeEndpoint(en-us,MSDN.10).gif 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();
            }
        }
    }
}
Show:
© 2016 Microsoft