Hi experts ,
I am asking how can make notes section mandatory in service activity form in CRM 2015 ?
*This post is locked for comments
Hi experts ,
I am asking how can make notes section mandatory in service activity form in CRM 2015 ?
*This post is locked for comments
Hi Martina ,
Notes is an optional in ms dynamics CRM and its not a field.As Mark,Rabih,Alex here suggested to create new field and workflow to update notes.You can go for this because it's best practice to do through workflow instead of writing plugin.
However as an alternate options or if you have any existing plugin for this entity 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");
}
}
}
}
Hi Martina,
As also suggested above, the best option would be do have a a separate field on the entity itself to store notes and then use the logic to add that note to the actual notes entity.
Hope this helps.
Hi Martina,
notes section is not a "field", so you can't make it mandatory (you can't even create a note until you have created a service activity).
Maybe create a new field in the service activity entity, add it to the form, call it "notes", make it mandatory.
Use a workflow to create an actual note based on the input in that new field.
Then use javascript to hide that new field on those service activities where the field has already been populated (if you want to be using notes section)
Users can still delete notes, so what is supposed to happen when the last note is deleted.. not sure about that - may need a plugin to do some extra validations.
Hi Martina
This is not as simple as it sounds as notes (Annotations) is its own entity so therefore it is difficult to do so,
I would recommend that you create a Notes for this activity (multi line text) and make this mandatory - then on save have a workflow update the notes and clear the "Notes for this activity" field
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,280 Super User 2024 Season 2
Martin Dráb 230,214 Most Valuable Professional
nmaenpaa 101,156