Skip to main content

Notifications

Microsoft Dynamics GP (Archived)

Dex Challenge: Programmatically Get From Field to Drop-List DataType to Static Text Values

Posted on by 1,582

I am seeking whether it is possible to programmatically:

  1. Begin with a field name : say "Misc Taxable"
  2. Detect the datatype of that field : I can do this with the built-in function datatype()
  3. Then if the datatype is a drop-down-list, go to the datatype definition and retrieve the field's Static Text Values

You might be asking why I do not simply use itemname() but I am in a situation where I need a get one of these text values and I have no window open to pass that function a window field. Is there no other method of achieving this besides itemname()?

2018_2D00_01_2D00_25_5F00_1401.png

*This post is locked for comments

  • Suggested answer
    David Musgrave MVP GPUG All Star Legend Moderator Profile Picture
    David Musgrave MVP ... 13,909 Most Valuable Professional on at
    RE: Dex Challenge: Programmatically Get From Field to Drop-List DataType to Static Text Values

    Hi Chad

    I have this functionality in GP Power Tools with the exception of displaying the static values. The next build already has this feature using my own window.

    The current versions can show the information by drilling down on the Field Technical Name prompt to open the Additional Field Information window.

    To get the static values you need the following.

    system SYS_OLFD_SET_DICT,l_DictID;

    system SYS_OLFD_CONTROL_TYPE,l_dtypeid,l_fieldtype,<List Field>;

    NB: You will need a hidden window to hold the List Field.

    Disclaimer: Many fields dynamically build or change static values so these are only a guide.

    David

  • Mariano Gomez Profile Picture
    Mariano Gomez 26,225 on at
    RE: Dex Challenge: Programmatically Get From Field to Drop-List DataType to Static Text Values

    Yup, lot's of maintenance involved there and you would have to check every release to make sure no new options were added to the DDLs.

  • chadbruels Profile Picture
    chadbruels 1,582 on at
    RE: Dex Challenge: Programmatically Get From Field to Drop-List DataType to Static Text Values

    Did I commit a forum faux pas? Forgive me; I did not wish to lead you by providing my own conclusions from the start. Since there are going to be DDLs loaded dynamically, I feel like the most accurate solution is building out a collection of functions, however, that is also the solution with the most up front and maintenance effort.

  • Mariano Gomez Profile Picture
    Mariano Gomez 26,225 on at
    RE: Dex Challenge: Programmatically Get From Field to Drop-List DataType to Static Text Values

    Clearly not under the scenario you just described, since your initial request was very specific.

    The other method that can be used is to call the Dex.dic functions that do this. I used to have source code for the Dex.dic, so let me check how it's done there, i.e., Resource Information window. However, as I mentioned before, the downside to this method is, a great deal of DDLs are loaded dynamically.

  • chadbruels Profile Picture
    chadbruels 1,582 on at
    RE: Dex Challenge: Programmatically Get From Field to Drop-List DataType to Static Text Values

    Thanks for your time, Mariano.

    If you were faced with needing to implement a solution for finding the string representation for a given integer value for any drop-down field across the transaction tables for all the main modules of GP (SOP_HDR_WORK, SOP_LINE_WORK, IVC_HDR_WORK, POP_Receipt, etc), would this still be your approach? I had considered this approach but was not sure if the window would flash open and give users concern. I think it would also require working out which windows to use per field and there is the potential shortcoming you pointed out.

    The other approach I have considered is to build out a collection of functions for each drop-down-list (grouping some where possible, e.g. Freight Taxable and Misc Taxable).

    function returns string returnValue;
    
    in integer intValue;
    
    pragma(disable warning LiteralStringUsed); 
    
    case intValue
    in [1]
    	returnValue = "Taxable";
    in [2]
    	returnValue = "Nontaxable";
    in [3]
    	returnValue = "Base on customers";
    else
    	returnValue = str(intValue);
    end case;
    
    pragma(enable warning LiteralStringUsed); 
    


    In some cases there are report writer functions which can be used, such as rw_GetWFApprovalStatusStr or rw_GetSOPTypeString.

  • Verified answer
    Mariano Gomez Profile Picture
    Mariano Gomez 26,225 on at
    RE: Dex Challenge: Programmatically Get From Field to Drop-List DataType to Static Text Values

    Try this:

    local integer Indx;
    local integer ItemCount;
    local string  ItemText;
    
    
    open form xyz;
    close window xyz of form xyz;
    
    ItemCount = countitems(field 'Misc Taxable' of window xyz of form xyz);
    
    for Indx = 1 to ItemCount do
      ItemText = itemname(field 'Misc Taxable' of window xyz of form xyz, Indx);
      warning ItemText;
    end for;
    close form xyz;


    As you can see, I am simply opening the form and close the window(s) whose AutoOpen property is set to true. Also, even if you know the datatype is a DDL, they could be loading the field dynamically with the add item statement, which would render your suggested method ineffective.

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

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Complete!

🔔 Be sure to subscribe to the new forums you are interested in to stay up to date! 🔔

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 229,918 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans