QuestionQ393

Extend the platform

A company is developing a Microsoft Dataverse plug-in.

The plug-in must create a follow-up task for a newly created account.

You add code that receives context (IPluginExecutionContext) and service (IOrganizationService).

You need to add the remaining code that inserts the follow-up task.

Which three code blocks should be used, in sequence?

Drag & Drop
Entity followuptask = new Entity("task"); followuptask["subject"] = "Send e-mail to the new customer"; followuptask["regardingobjectid"] = account;
Entity followuptask = new Entity("task"); followuptask["subject"] = "Send e-mail to the new customer"; followuptask["regardingobjectid"] = account.ToEntityReference();
Entity account = (Entity)context.InputParameters["Target"];
service.Create(followuptask);
Entity account = (Entity)context.PreEntityImages["Target"];
service.Update(followuptask);




Explanation

For a Create operation, the input parameter named Target contains the account Entity. The task’s regardingobjectid is a lookup column, so it must receive an EntityReference, obtained with account.ToEntityReference(). service.Create(followuptask) persists the new task.

Learn more

Community Discussion

No comments yet. Be the first to start the discussion!