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

value cannot be null. parameter name : value

(0) ShareShare
ReportReport
Posted on by

Hi,

While i am inserting record in to account entity i am getting this error please help me out.

Account account = new Account
{
Name = dr.GetValue(dr.GetOrdinal("Name")).ToString().Trim(),
EMailAddress1 = dr.GetValue(dr.GetOrdinal("Email")).ToString().Trim(),

};

CreateRequest createRequest = new CreateRequest { Target = account };
DynamicsCommonClass.requestWithResults.Requests.Add(createRequest);

(ExecuteMultipleResponse)service.Execute(DynamicsCommonClass.requestWithResults)

For  creating service i am using this code

public static void SetServiceContent()
{
string organizationUri = string organizationUri = "https://"+ _domain +".api.crm.dynamics.com/XRMServices/2011/Organization.svc";//GetDynamicsURI();
if (!String.IsNullOrWhiteSpace(organizationUri))
{
IServiceManagement<IOrganizationService> orgServiceManagement = ServiceConfigurationFactory.CreateManagement<IOrganizationService>(new Uri(organizationUri));
AuthenticationCredentials credentials = GetCredentials(orgServiceManagement, endpointType);

// Get the organization service proxy.
using (OrganizationServiceProxy organizationProxy =
GetProxy<IOrganizationService, OrganizationServiceProxy>(orgServiceManagement, credentials))
{
service = (IOrganizationService)organizationProxy;
}
}
}

Let me know if you want more information 

Thanks

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Bruno Lucas Profile Picture
    5,421 on at

    check to see if this has any valid values

    dr.GetValue(dr.GetOrdinal("Name")).ToString().Trim(),

    few suggestions. wrap that code with a "if" statement that will let it proceed only if "dr" record count > 0

    add a try catch to capture more information

     try
            {
                if (dr.count() > 0)
                {
                    //your code here
    
                }
    
            }
            catch (SoapException sx)
            {
                SystemLog.LogError(string.Format("SoapError - btnOK_Clicked {0}", (sx.Detail.InnerText != null ? sx.Detail.InnerText.Replace('\n', ' ').Trim() : sx.Message)));
                    
            }
            catch (Exception ex)
            {
                SystemLog.LogError(string.Format("Error - btnOK_Clicked {0}", ex.Message));
            }        


            

  • Mithilesh Kumar Profile Picture
    10,047 on at

    Hi Parth,

    What is the error message are you receiving.

    However, you are using Account Entity, but I cannot see OOB Field called Emailaddress1 in Account but rather they are in Contact. Are you trying to creating record in Contact but mistakenly used Account Entity.

    My understanding may be wrong, please do correct me.

    Thanks

  • Community Member Profile Picture
    on at

    Hi,

    Bruno Lucas i already check that my name is not coming null or invalid value. i already tried by giving it fix string value but it give me the same Error.

    Mithilesh Kumar  no i nave to insert record into account entity i just want toinsert account name and its email address.

      

    I am getting this error.

  • Verified answer
    Bruno Lucas Profile Picture
    5,421 on at

    using (OrganizationServiceProxy organizationProxy =
    GetProxy<IOrganizationService, OrganizationServiceProxy>(orgServiceManagement, credentials))
    {

    organizationProxy.EnableProxyTypes();
    service = (IOrganizationService)organizationProxy;
    }
    }
    }

  • Bruno Lucas Profile Picture
    5,421 on at

    can you also share the details under innerexception (look like you can expand from the picture) and the remotestacktrace

  • Community Member Profile Picture
    on at

    Thanks Bruno Lucas  its working now.

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 > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans