現在のエンティティに関連付けられているすべてのノートのガイドのリスト(またはコレクションなど)を取得するにはどうすればよいですか?ノートのリストを取得
私はそれが何らかの形で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すべて罰金が、これを見ることができ、クエリでそれを書くのか?アーリーバインド
:
var notes =
service.AnnotationSet.Where(annotation => annotation.Opportunity_Annotation.Id == entity.Id)
.Select(annotation => annotation.Id)
.ToList();
FetchXml: PasteBin
あなたが共有するためのいくつかのコードを持っていますか?あなたは何を試していますか?どこに間違っていますか? – Marcus
@Marcus、はい私はコードを投稿しました。私は何を私がservice.Retreiveに入れるべきか分からない。 また、私はクエリーを構築することによってこれを行う方法を見た。 –
プラグインは、あるエンティティから別のエンティティへのすべてのメモをコピーすることに関するものです。 –