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 510

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

  • Verified answer
    Sergei Minozhenko Profile Picture
    23,091 on at
    RE: How to hide Enum Element for EP.

    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.

  • Siddhant Singh Profile Picture
    510 on at
    RE: How to hide Enum Element for EP.

    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

  • Sergei Minozhenko Profile Picture
    23,091 on at
    RE: How to hide Enum Element for EP.

    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
    510 on at
    RE: How to hide Enum Element for EP.

    Hi Sirgei,

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

    Thanks and regards

    Siddhant Singh

  • Sergei Minozhenko Profile Picture
    23,091 on at
    RE: How to hide Enum Element for EP.

    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
    510 on at
    RE: How to hide Enum Element for EP.

    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

  • Suggested answer
    Sergei Minozhenko Profile Picture
    23,091 on at
    RE: How to hide Enum Element for EP.

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

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

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 293,278 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 232,002 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156 Moderator

Leaderboard

Product updates

Dynamics 365 release plans