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)

How to handle crmerrors in add of case through c# in dynamics crm?

(0) ShareShare
ReportReport
Posted on by

I am adding case's fields data through c#. but when I am adding particular contract look up field.It gives me below error for this field. otherwise for other look up field it works fine.

I also found that this is crmerror. but how to solve that I can't find. below link displays that it is crm error.

http://www.mohamedibrahim.net/blog/2013/07/01/microsoft-dynamics-crm-2011-and-online-error-codes-full-list-api-web-service-sdk/


Error:

IncidentMissingContractDetail -2147204095 The contract detail id is missing.

*This post is locked for comments

I have the same question (0)
  • Aiden Kaskela Profile Picture
    19,696 on at

    Hi,

    Would you mind sharing your code that's setting the field?

    Thanks,

     Aiden

  • Community Member Profile Picture
    on at

    Hi Aiden,

    Below is some part of my code.I had been try to explain.

    //data in postdata for add pass in service using ajax
    var requestData = 
    {
    	"ModuleCode": "incident",
    	"PostData": [{ "Key": "customerid", "Value": "a624c9dc-cc83-e611-80dc-fc15b428cc94", "Datatype": "lookup", "Entityname": "contact" }, { "Key": "title", "Value": "cq", "Datatype": "String" }, { "Key": "contractid", "Value": "d1f0f5cb-9c84-e611-80dc-fc15b428cc94", "Datatype": "Lookup", "Entityname": "contract" }, { "Key": "prioritycode", "Value": "3", "Datatype": "Picklist" }, { "Key": "description", "Value": "qqqq", "Datatype": "Memo" }, { "Key": "ticketnumber", "Value": "", "Datatype": "String" }, { "Key": "productid", "Value": "072d9a60-e9c2-e411-80e5-c4346bad2660", "Datatype": "Lookup", "Entityname": "product" }],
    }
    //below is the code that call addorupdate function from other function.
    Entity moduledata = new Entity(modulename);
    moduledata = addorupdate(moduledata, PostData, modulename);
    newmoduledataid = _serviceProxy.Create(moduledata);
    public Entity addorupdate(Entity moduledata, List<PostData> PostData, string modulename)
    {
    	for (var i = 0; i < PostData.Count(); i++)
    	{
    		bool flag = true;
    		if (PostData[i].Datatype != null && PostData[i].Datatype != "")
    		{
    			if (flag)
    			{
    				if (PostData[i].Datatype.ToLower() == "picklist" || PostData[i].Datatype.ToLower() == "optionset" || PostData[i].Datatype.ToLower() == "dropDown")
    				{
    					if (PostData[i].Value != null && PostData[i].Value != "")
    						moduledata[PostData[i].Key] = new OptionSetValue((Convert.ToInt32(PostData[i].Value)));                          
    				}
    				if (PostData[i].Datatype.ToLower() == "string" || PostData[i].Datatype.ToLower() == "memo" || PostData[i].Datatype.ToLower() == "multilinestext")
    				{
    					if (PostData[i].Value != null && PostData[i].Value != "")
    						moduledata[PostData[i].Key] = PostData[i].Value;
    				}
    				
    				else if (PostData[i].Datatype.ToLower() == "lookup")
    				{
    					if ((PostData[i].Value != null && PostData[i].Value != "") && (PostData[i].Entityname != null && PostData[i].Entityname != ""))
    						moduledata[PostData[i].Key] = new EntityReference(PostData[i].Entityname, Guid.Parse(PostData[i].Value));    
    				}
    				//like this for all datatype
    			}
    		}
    	}
    	return moduledata;
    }
  • Verified answer
    Yadnyesh Kuvalekar Profile Picture
    4,102 on at

    Hi Chhaya,

    Do you have contract lines added on the contract record? And is your contract in active state?

    If yes, the when you add contract on the case, you must add contract line as well on the case entity. So, in your code, add one more field to add contract line in contractdetailid field on case record.

  • Community Member Profile Picture
    on at

    Hi Yadnyesh,Is there any query or attribute which tell us dependency between 2 fields like this.that is contractlines and contractid is dependent on each other .

    If I can know then Add that field toghether.

  • Suggested answer
    Yadnyesh Kuvalekar Profile Picture
    4,102 on at

    Hi Chhaya,

    This is OOB functionality. On Case entity there are two fields (ContractId & ContractDetailId). On contract detail entity, there is a lookup to contract entity.

  • Yadnyesh Kuvalekar Profile Picture
    4,102 on at

    Feel free to make applicable answers as verified answers.

  • Community Member Profile Picture
    on at

    Hi chhaya, have you done your problem ?

    I get this problem once before, when we import/creating case record from C#. We did't includes value for look up field. And when we want to add look up field inside the cases we created from C#. It's show an error. We check on that "look up" field which give us an error. And we found that there is a filter inside the field that make the look up field show only related record(from other entity) for this record. In other word, when you create case from C#. She's unable to found related record from the look up field. The resoltion to turn off the filter inside the look up field. To turn off the filter, open you  field properties. And uncheck something that says related record (I  can't Remember the name of the subject"

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!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
Varsha deshpande Profile Picture

Varsha deshpande 5

#2
JS-09031509-0 Profile Picture

JS-09031509-0 3

#3
Ciprian  P Profile Picture

Ciprian P 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans