0

我试过这个:

function CreateCustomActivity(oDataPath, oDataSetName, subject, entityId, entityTypeCode) {    
    var customactivity = new Object();
    customactivity.subject = subject;
    customactivity.regardingobjectid = entityId;
    customactivity.activitytypecode = entityTypeCode;

    var jsonCustomActivity = JSON.stringify(customactivity);

    var req = new XMLHttpRequest();
    req.open("POST", oDataPath + "/" + oDataSetName, false);
    req.setRequestHeader("Accept", "application/json");
    req.setRequestHeader("Content-Type", "application/json; charset=utf-8");
    req.send(jsonCustomActivity);
}

但是,我收到以下错误:

处理请求流时出错。为类型“Microsoft.Crm.Sdk.Data.Services.new_customactivity”指定的属性名称“主题”无效。

我添加到customactivity对象的第一个属性在错误消息中被引用。我regardingobjectid第一次添加时收到相同的消息。

4

1 回答 1

1

尝试使用以下符号创建您的活动对象:

var customactivity = {
    Subject: subject,
    RegardingObjectId: {
        Id: entityId,
        LogicalName: entityLogicalName
    }        
};

另外,我不确定,但属性名称可能区分大小写。

于 2011-05-15T19:28:58.823 回答