1

我正在使用 Otganizational Data 服务在 CRM 2011 中创建 Silverlight 4 Web 资源。我能够创建活动、营销列表和打印活动,以及将列表链接到活动。但是,当我使用 CampaignActivityItem 将营销列表链接到打印活动时,我收到 403 Forbidden 错误。下面是我正在使用的代码。

        Models.CampaignActivityItem activityItem = new CampaignActivityItem()
        {
            CampaignActivityItemId = Guid.NewGuid(),
            ItemId = EmailMarketingList.ListId, //Id of my marketing list I have 
                                                //already created
            CampaignActivityId = new Models.EntityReference()
            {
                Id = MyCampaignPrintActivity.ActivityId, //Id of the print activity
                                                         //I have already created
                LogicalName = "CampaignActivity",
                Name = "CampaignActivity"
            }
        };

        context.AddObject("CampaignActivityItemSet", activityItem);

        context.BeginSaveChanges(System.Data.Services.Client.SaveChangesOptions.ContinueOnError, OnChangesSaved, context);

    private void OnChangesSaved(IAsyncResult result)
    {
        // Use the Dispatcher to ensure that the 
        // asynchronous call returns in the correct thread.
        OnUiThread(() =>
        {
            try
            {
               DataServiceResponse response = context.EndSaveChanges(result);
            }
            catch (DataServiceRequestException ex) // Errors with code=403       
                                                   // message=Forbidden
            {
                WriteOperationResponse(ex.Response, "ListLink");
            }
            catch (InvalidOperationException ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
            }
        }
        );
    }

任何关于我做错了什么的方向都将不胜感激。使用上下文,我可以对其他对象执行操作,但不能对 CampaignActivityItemSet 执行操作。

4

0 回答 0