如何通过动态crm中的c#添加大小写的错误?

时间:2016-10-13 13:19:59

标签: c# dynamics-crm dynamics-crm-2013 dynamics-crm-online

我通过c#添加了case的字段数据。 但是当我添加特定的合同查找字段时。它给出了我对此字段的误差。否则对于其他查找字段,它可以正常工作。

我也发现这是犯错误。但如何解决我无法找到的问题。 下面的链接显示它是crm错误。 http://www.mohamedibrahim.net/blog/2013/07/01/microsoft-dynamics-crm-2011-and-online-error-codes-full-list-api-web-service-sdk/

代码:

//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" }],
}
//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;
}

ERROR:

  

IncidentMissingContractDetail -2147204095合约详细信息ID为   丢失。

0 个答案:

没有答案