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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

How to hide Enum Element for EP.

(0) ShareShare
ReportReport
Posted on by 518

Hi all,

Can we hide enum element on dataset. 

I want to hide enum element for specific company on EP which is working on dataset. 

How can i achieve this.

Thanks and regards

Siddhant Singh

I have the same question (0)
  • Suggested answer
    Sergei Minozhenko Profile Picture
    23,093 on at

    Hi Siddhant Singh,

    You can utilize ControlHelper.GetCurrentSessionCompany method in WebControl code and based on company hide certain UI elements on the web page (for example Page_Load method can be the place where to write this logic on WebControl)

    using Microsoft.Dynamics.Framework.Portal.CommonControls;
    ...
    string company = ControlHelper.GetCurrentSessionCompany(AxBaseWebPart.GetWebpart(this).Session);

  • Siddhant Singh Profile Picture
    518 on at

    Hi Sergei,

    Below code is there in Web page, and company is also getting in the code. 

    Can you please tell what line of code can be written to hide the specific Enum element which is in AX.

    protected void Page_Load(object sender, EventArgs e)
        {
            string comp = Microsoft.Dynamics.Framework.Portal.SessionHelper.Instance.GetSession().SessionInfo.Company;
            // Sets the form mode based on the managed content enum parameter
            this.SetupMode();
    
            bool hoursVisibility = (bool)this.dsAbsenceRequestEdit.GetDataSet().DataSetRun.AxaptaObjectAdapter.Call("hoursVisibility");
            this.grpDescription.Fields[2].Visible = hoursVisibility;
            this.dsAbsenceRequestEdit.GetDataSet().DataSetRun.AxaptaObjectAdapter.Call("checkLeaveBalance");
            if(comp != "UK")
            {
                HyperLink1.Visible = false;
            }
        }

    Thanks and regards

    Siddhant Singh

  • Sergei Minozhenko Profile Picture
    23,093 on at

    Hi Siddhant,

    Could you, please, clarify do you want to hide element based on enum or you want to hide value in enum?

  • Siddhant Singh Profile Picture
    518 on at

    Hi Sirgei,

    I want to hide value of Enum, based on company check.

    Thanks and regards

    Siddhant Singh

  • Sergei Minozhenko Profile Picture
    23,093 on at

    Hi Siddhant,

    I guess in this case you can create method on DataSet which will return list (or array) of avaiable enum values and you will populate custom combobox control with these value.

  • Siddhant Singh Profile Picture
    518 on at

    Hi Sergei,

    The Enum is attached with the AxDropDownBoundField.

    Enum has 3 values, Full, half and short.

    I have to hide short from this enum.

    Can you please tell what may be the code to do so.

    Thanks and reagards

    Siddhant Singh

  • Verified answer
    Sergei Minozhenko Profile Picture
    23,093 on at

    Hi Siddhant,

    As I mentioned before you could try to use the unbound drop-down control (asp:DropDownList) and fill it dynamically with needed elements. The list of elements can be returned from DataSet via method call.

    DropDownList1.Items.Add(...

    Another option you can try is to create new enum (without short value) and add a new field to the backend table with SaveContent = false and use new enum as type.

    On PostLoad you can fill value to the new field from original field and use it in EP in AxDropDownBoundField. On insert\update you can copy value back from new field to original.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 449 Super User 2025 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 422 Most Valuable Professional

#3
BillurSamdancioglu Profile Picture

BillurSamdancioglu 239 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans