Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/variables/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用REST创建OpportunityProduct_Rest_Dynamics Crm_Crm_Dynamics Crm Online - Fatal编程技术网

使用REST创建OpportunityProduct

使用REST创建OpportunityProduct,rest,dynamics-crm,crm,dynamics-crm-online,Rest,Dynamics Crm,Crm,Dynamics Crm Online,我正在尝试使用此rest调用创建一个新的OpportunityProduct: XRMServices/2011/OrganizationData.svc/OpportunityProductSet {"ProductId":"ef71ce8e-1ef3-e211-b252-984be17c47e4","Quantity":123,"ProductDescription":"Added from code - TEST123","OpportunityId":"8bdb3525-7274-e3

我正在尝试使用此rest调用创建一个新的OpportunityProduct:

XRMServices/2011/OrganizationData.svc/OpportunityProductSet

{"ProductId":"ef71ce8e-1ef3-e211-b252-984be17c47e4","Quantity":123,"ProductDescription":"Added from code - TEST123","OpportunityId":"8bdb3525-7274-e311-a90b-6c3be5be5f78"}
呼叫返回:

请求应该是有效的顶级资源对象

这表明我的论点不正确。我了解可能的原因:

  • 我缺少一些必需的属性(我如何才能确定哪些是必需的?)
  • 使用rest是不可能的
  • (两个guid都是通过其他调用返回的,应该是正确的)

    任何帮助都会很好

    谢谢


    Larsi

    要查找对其他实体的引用,需要同时指定GUID和类型。在基于现有产品创建Opportunity产品时,还需要包括UOM。您的对象应该如下所示:

    var entity = {};
    entity.Quantity = parseFloat(4).toFixed(2);
    entity.OpportunityId = {
        Id: '69BB2236-B57F-E311-BB6D-6C3BE5A881A4',
        LogicalName: 'opportunity'
    };
    entity.ProductId = {
        Id: 'C8138483-DF81-E311-B542-6C3BE5A8362C',
        LogicalName: 'product'
    };
    entity.UoMId = {
        Id: 'BE0FB859-7E90-4B3E-B501-3AB3CD4DC8FC',
        LogicalName: 'uom'
    };
    

    太好了,谢谢!顺便说一句,添加产品后,产品线项目网格似乎没有更新。应该吗?或者我需要手动刷新整个页面吗?您需要手动刷新子网格-类似于Xrm.page.ui.controls.get(“SubGridName”).refresh();