Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

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

Posted on by Microsoft Employee

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

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: How to handle crmerrors in add of case through c# in dynamics crm?

    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"

  • Yadnyesh Kuvalekar Profile Picture
    Yadnyesh Kuvalekar 4,102 on at
    RE: How to handle crmerrors in add of case through c# in dynamics crm?

    Feel free to make applicable answers as verified answers.

  • Suggested answer
    Yadnyesh Kuvalekar Profile Picture
    Yadnyesh Kuvalekar 4,102 on at
    RE: How to handle crmerrors in add of case through c# in dynamics crm?

    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.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: How to handle crmerrors in add of case through c# in dynamics crm?

    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.

  • Verified answer
    Yadnyesh Kuvalekar Profile Picture
    Yadnyesh Kuvalekar 4,102 on at
    RE: How to handle crmerrors in add of case through c# in dynamics crm?

    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
    Community Member Microsoft Employee on at
    RE: How to handle crmerrors in add of case through c# in dynamics crm?

    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;
    }
  • Aiden Kaskela Profile Picture
    Aiden Kaskela 19,692 on at
    RE: How to handle crmerrors in add of case through c# in dynamics crm?

    Hi,

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

    Thanks,

     Aiden

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans