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 CRM (Archived)

C# code to make field mandatory when particular values are selected on other field.

(0) ShareShare
ReportReport
Posted on by 342

when say x,y values are opted on A field than B field should be required.

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Shahbaaz Ansari Profile Picture
    6,211 on at

    I don't think that is possible with c#,  instead you can use Business rule which is OOB functionlity of CRM.

    If you find it helpful, Please mark as Verified.

    Thanks,

    Shahbaaz

  • Suggested answer
    Shahbaaz Ansari Profile Picture
    6,211 on at

    Please check below link for making field mandatory

    community.dynamics.com/.../using-business-rules-to-hide-fields-and-make-them-required-as-needed

    If you find it helpful, Please mark as Verified.

    Thanks,

    Shahbaaz

  • Verified answer
    Alex Fun Wei Jie Profile Picture
    33,628 on at

    Hi,

    would you mind to elaborate? Why you need to use c# code.

    You can easily to achieve this using business rule or JS.

  • Suggested answer
    Community Member Profile Picture
    on at

    You can easily make business required field by Using Business rules. Why C# code if CRM providing you a best way without writing piece of Code

  • Verified answer
    gdas Profile Picture
    50,091 Moderator on at

    Hi Sandy,

    I understand your requirement but dynamics CRM does not support server side code to attached in the page level. Plugins we have but its not like so flexible use in page level , I mean if you did any operation in the page lets say "on change" you are setting some value using C#  , you need to refresh the page to get reflect in UI  and its depends on some events , operation to get trigger the business logic.

    So there is easy way you can achieve your requirement using business rules , you can compare with same entity field and based on value you can set other field value , requirement level , show ,hide in client side  and server side  as well without writing single line of code . Here is msdn reference for business rules.

    technet.microsoft.com/.../dn531086(v=crm.6).aspx

    Now yo may ask if you want to validate with other entity ,then also you can achieve using java script simply fetch the data usnig Xrm.WebAPI and depending on that you can set your field value or business requirement in your form field.

    You dont need to refresh your page . Here is the reference how to retrieve the data using JavaScript.

    community.dynamics.com/.../ms-crm-2016-web-api-operations-retrieve-single-or-multiple-records

    Hope this helps you to achieve your requirements.

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
JS-09031509-0 Profile Picture

JS-09031509-0 3

#2
AS-17030037-0 Profile Picture

AS-17030037-0 2

#2
Mark Eckert Profile Picture

Mark Eckert 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans