0
如何獲取與當前實體關聯的所有筆記的guid列表(或收集)?獲取筆記清單
我知道它在某種程度上與service.Retreive(...)連接,但無法生成工作代碼。
附1:
public void Execute(IServiceProvider serviceProvider)
{
Entity entity = null;
var context = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext));
if (entity.Contains("new_parentopportunity"))
{
try
{
IOrganizationServiceFactory factory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));
IOrganizationService service = factory.CreateOrganizationService(context.UserId);
Guid projectGuid = entity.Id;
Guid oppGuid = ((EntityReference)entity["new_parentopportunity"]).Id;
for (int i = 0; i < 100; i++) //Instead of 100, I'll place obtained collection.Length
{
Entity opp = service.Retrieve("", oppGuid, new Microsoft.Xrm.Sdk.Query.ColumnSet(true)); //RETREIVE ENTITY NOTE HERE
var temop = CreateNoteAttachment(opp);
service.Create(temp);
}
}
catch (Exception ex)
{
throw new InvalidPluginExecutionException("An error occurred in the plug-in.", ex);
}
}
}
private Entity CreateNoteAttachment(Entity oppNote)
{
//some code here
}
更新1:
我也把它寫在查詢中,你可以看看這個,whethere樣樣精呢? PasteBin
你有一些代碼分享?你有什麼嘗試,你哪裏錯了? – Marcus
@Marcus,是的,我發佈了代碼。我不明白我應該投入什麼服務.Retreive() 此外,我已經看到了通過構造查詢的方式做到這一點 –
該插件是關於從一個實體複製到另一個實體的所有筆記。 –