Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics GP (Archived)

How to get the list of account using account format (segment) and update it?

Posted on by 200

I want to retrieve the list of account based on account format/account segment using GP Web service. There is method which is returning the account but it is specific to accountnumber which is combination of all account formats.
e.g.: Suppose there are five account format
Format 1:    3 char    =    abc
Format2:    2 char    =    00
Format3:    5 char    =    12345
Format4:    3 char    =    987
Format5:    8 char    =    abc09876
Now the method which web service provides is to search with combination of 5 formats (abc-00-12345-987-abc09876).

But I would like to search with only format 5.

How to get such list or any other alternative for the same?

Thanks,
Krunal Panchal

*This post is locked for comments

  • Krunal Panchal Profile Picture
    Krunal Panchal 200 on at
    RE: How to get the list of account using account format (segment) and update it?

    Thanks Howard Swerdloff for writing on this.

    Yes, that I can do. But my purpose is to do it by using the GP Web Service. There is method called GetGLUnitAccountList but it is not working correctly for me. Because it is returning the data but for specific criteria.

    Following is example:

    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 accountIdRestriction;

              GLUnitAccountCriteria unitAccountCriteria;

              GLUnitAccountSummary[] unitAccountSummaries;

              // Create an instance of the web service

              DynamicsGP wsDynamicsGP = new DynamicsGP();

              // Be sure the default credentials are used

              wsDynamicsGP.UseDefaultCredentials = true;

              // Create a context with which to call the web 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;

              context.CultureName = "en-US";

              // Create a restriction object

              accountIdRestriction = new LikeRestrictionOfString();

              accountIdRestriction.Like = "%9010%";

              // Create a GL unit account criteria object

              unitAccountCriteria = new GLUnitAccountCriteria();

              unitAccountCriteria.GLAccountId = accountIdRestriction;

              // Retrieve the list of GL unit account summary objects

              unitAccountSummaries = wsDynamicsGP.GetGLUnitAccountList(unitAccountCriteria, context);

              // Display the account number and description of each member of the summary list

              StringBuilder summaryList = new StringBuilder();

              foreach (GLUnitAccountSummary a in unitAccountSummaries)

              {

                  summaryList.AppendLine("Account: " + a.Key.Id + "  Description: " + a.Description);

              }

              MessageBox.Show(summaryList.ToString());

          }

      }

    }

    Here it is retuning data for 9010 but if I am search for 4444 then it is not returning the data. I don’t know what is going wrong in it.

    I have doubt in LikeRestrictionOfString because it is searching on those parts which are not null. As I mentioned in above, I have five account formats and I am looking for the fifth format and for the fifth format there are some null value and because of that it is not returning data.

    Thanks

    Krunal Panchal

  • Krunal Panchal Profile Picture
    Krunal Panchal 200 on at
    RE: How to get the list of account using account format (segment) and update it?

    Thanks Howard Swerdloff for writing on this.

    Yes, that I can do. But my purpose is to do it by using the GP Web Service. There is method called GetGLUnitAccountList but it is not working correctly for me. Because it is returning the data but for specific criteria.

    Following is example:

    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 accountIdRestriction;

               GLUnitAccountCriteria unitAccountCriteria;

               GLUnitAccountSummary[] unitAccountSummaries;

               // Create an instance of the web service

               DynamicsGP wsDynamicsGP = new DynamicsGP();

               // Be sure the default credentials are used

               wsDynamicsGP.UseDefaultCredentials = true;

               // Create a context with which to call the web 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;

               context.CultureName = "en-US";

               // Create a restriction object

               accountIdRestriction = new LikeRestrictionOfString();

               accountIdRestriction.Like = "%9010%";

               // Create a GL unit account criteria object

               unitAccountCriteria = new GLUnitAccountCriteria();

               unitAccountCriteria.GLAccountId = accountIdRestriction;

               // Retrieve the list of GL unit account summary objects

               unitAccountSummaries = wsDynamicsGP.GetGLUnitAccountList(unitAccountCriteria, context);

               // Display the account number and description of each member of the summary list

               StringBuilder summaryList = new StringBuilder();

               foreach (GLUnitAccountSummary a in unitAccountSummaries)

               {

                   summaryList.AppendLine("Account: " + a.Key.Id + "  Description: " + a.Description);

               }

               MessageBox.Show(summaryList.ToString());

           }

       }

    }

    Here it is retuning data for 9010 but if I am search for 4444 then it is not returning the data. I don’t know what is going wrong in it.

    I have doubt in LikeRestrictionOfString because it is searching on those parts which are not null. As I mentioned in above, I have five account formats and I am looking for the fifth format and for the fifth format there are some null value and because of that it is not returning data.

    Thanks

    Krunal Panchal

  • Howard Swerdloff Profile Picture
    Howard Swerdloff 845 on at
    RE: How to get the list of account using account format (segment) and update it?

    Hi Krunal,

    There are alternative methods to get the account list besides web services. You can use SQL to retrieve a list based on the GL00100 table, which is the account master. Each segment is titled ACTNUMBR_x where x is the segment number. In your example, that would be ACTNUMBR_5.

    I hope this helps.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans