web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics GP (Archived)

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

(0) ShareShare
ReportReport
Posted on by 1,588

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
    MG-16101311-0 Profile Picture
    26,225 on at

    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.

  • chadbruels Profile Picture
    1,588 on at

    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.

  • MG-16101311-0 Profile Picture
    26,225 on at

    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
    1,588 on at

    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.

  • MG-16101311-0 Profile Picture
    26,225 on at

    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.

  • Suggested answer
    David Musgrave MVP GPUG All Star Legend Moderator Profile Picture
    14,157 Most Valuable Professional on at

    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

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Leaderboard > 🔒一 Microsoft Dynamics GP (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans