Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8106237
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T00:24:23+00:00 2026-06-06T00:24:23+00:00

When we create a new field in Microsoft Dynamics CRM, it will create it

  • 0

When we create a new field in Microsoft Dynamics CRM, it will create it in the database as NULL allowed. How can you create a field in CRM that is NON-NULL in the backing database, like they do use for some of their own fields?

Selecting the Mandatory flag doesn’t make it NON-NULL.

Reason for asking: when programming against CRM using LINQ, many queries become relatively difficult when you have to take care of nullables, and some even become impossible, like aggregate queries (try Max(), it will give a InvalidCastException when the underlying db type is nullable).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T00:24:25+00:00Added an answer on June 6, 2026 at 12:24 am

    Though not exactly what you’re asking for, you can achieve a similar effect via the API. Write a plugin against the Create and Update in the pre-validation stage (to catch the null value before the database transaction). If the non-nullable attribute is ever null, throw an exception, which will cancel the transaction altogether.

    If you register the plugin after records have already been created, then you’d just have to make sure to populate those pre-existing records with values.

    public void Execute(IServiceProvider serviceProvider)
    {
        IPluginExecutionContext context = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext));
    
        if (context.InputParameters.Contains("Target") && context.InputParameters["Target"] is Entity)
        {
            var target = ((Entity)context.InputParameters["Target"]);
            if (target.LogicalName == Appointment.EntityLogicalName)
            {
                IOrganizationServiceFactory serviceFactory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));
                IOrganizationService service = serviceFactory.CreateOrganizationService(context.UserId);
                var entity = target.ToEntity<Xrm.Appointment>();
    
                if (entity.Description == null && entity.Attributes.Contains("description"))
                {
                    throw new Microsoft.Xrm.Sdk.SaveChangesException("Fill in the field, buddy.");
                }
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My table 'Post' has field: id, name, content, post_id When i create new post,
I'm trying to create a new div each time a text field contained in
I can't create New Project on my Visual Web Developer 2008 Express with SP1.
I am trying to create new Event objects to be persisted in the database
can someone confirm that microsoft changed path length related behaviour of some classe from
What I am trying to do is create a map generator that will create
I have Microsoft Access database (.mdb) that contains too much data. When i delete
i created report in iReport, where is text field with format: new DecimalFormat(#,##0.00).format($F{NUMBER}) +
I create new desktop with CreateDesktop and want to get it's DC & RC.
I create new blank solution. Add exist web site. Structure: Solution E:...\projectname Folders: bin

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.