2011-12-16 60 views
2

我已經創建了我在工作流中使用的自定義CRM活動。 我將此活動用作自定義工作流活動的InArgument。 在Execute()方法中,我嘗試將自定義CRM活動實例的OwnerId設置爲系統用戶,並對使用CrmSvcUtil生成的上下文對象調用UpdateObject(實體)。設置自定義活動的OwnerId

[Input("Some name")] 
[ReferenceEntity("mycustomactivity")] 
[Required] 
public InArgument<EntityReference> MyCustomActivity{get;set;} 


void Execute(CodeActivityContext context) 
{ 
IOrganizationService svc = context.GetExtension<IOrganizationService>(); 
var customActivityReference = MyCustomActivity.GetValue(MyCustomActivity); 

//MyServiceContext is an OrganizationServiceContext generated using CrmSvcUtil 
MyServiceContext servicecontext = new MyServiceContext(svc); 

//GetCutomActivityInstance uses the Id to get an instance of the custom activity) 
MyCustomCRMActivity activityInstance = GetCutomActivityInstance (servicecontext,customActivityReference.Id); 

activityInstance.OwnerId = new EntityReference("systemuser",<SomeGUID>); 
context.UpdateObject(activityInstance); 
context.SaveChanges(); 
} 

以上不工作,活動所有者默認爲我的CRM用戶帳戶,而不是更新,以反映我在activityInstance.OwnerId

設置所有者任何幫助將非常感激。

回答

6

所有者無法通過更新進行更改。你必須使用AssignRequest(或內置分配步,見截圖)

看到這個答案https://stackoverflow.com/a/7746205/315862

enter image description here

+0

感謝您response.Is的分配步只爲插件或也CRM工作流程中的定製活動?我將嘗試AssignRequest並在此處報告。另外,當收到工作流中的任務或任何自定義活動等「crm活動」時,InArgument 的類型參數應爲「EntityReference」正確嗎?即[ReferenceEntity(「mycustomactivity」)] [必需] public InArgument MyCustomActivity {get; set;} – 2011-12-16 16:18:01