Hi @SunilR,
Based on the issue that you mentioned, do you want to make Notes section mandatory in the portal?
Could you please share a bit more about the scenario?
Actually, making the Notes section mandatory is not that easy like it sounds like, I suggest you could create a separate field on the entity itself to store notes and then use the workflow to update notes.
You can go for this because it's best practice to do through workflow instead of writing plugin.
If you insist on a plugin, as an alternate options, you can try to implements in plugin.
public class ValidateNote : IPlugin
{
public void Execute(IServiceProvider serviceProvider)
{
IPluginExecutionContext context = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext));
IOrganizationServiceFactory serviceFactory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));
IOrganizationService service = serviceFactory.CreateOrganizationService(context.UserId);
if (context.InputParameters.Contains("Target") && context.InputParameters["Target"] is Entity) {
Entity note = (Entity)context.InputParameters["Target"];
// you can also use "subject" instead of "description"
if (string.IsNullOrEmpty(note.GetAttributeValue<string>("description")) || string.IsNullOrEmpty(note.GetAttributeValue<string>("filename")))
{
throw new InvalidPluginExecutionException("Please add an attachment and description");
}
}
}
}
Check if it could help.
Regards,
Qi