how to set Annotation (notes) on a form as required - javascript

I have a customized form of a customized entity, on my form I have crm annotation (notes), I need to set the notes part as required (according to a rule) how do I do that? when I clicked on the notes field I couldn't see the field name, Is it possible ?
The question reffers to dynamics crm annotation mechanism

We cannot achieve this straight forward, as we know Notes (annotation) is a separate entity which may have many records for a parent entity record. This is not a simple field in form, cannot be accessed in business rule. Instead of showing in subgrid, Platform giving different UI/UX for notes only like Timeline etc.
You can write script to validate/prompt user to create a child note on need basis. But not before creating a parent record itself.
This was already discussed in community, maybe you can have a custom mandatory multiline field to capture notes & rollup to annotation, can handle different scenarios/validations in code.

Related

How can make I fields mandatory during Formio editing?

I'm building a form editing page using the Formio editor and renderer.
I'd like to make specific form fields mandatory in the form editor. [different than making the field entry mandatory during submission]
There are two roles in the application -
Editor - Modifies the formio definition.
User - Submits the form data.
I'm specifically interested in making several 'meta-data' fields mandatory for the Editor. The Editor should not be able to remove certain fields from the formio component list.
A couple options I'm considering for implementation -
When the form is saved, inspect the form components and ensure the mandatory fields exist, and if they dont, create them.
Set a flag in the UI for specific components so they are 'disabled' and cannot be removed in the formio editor.
Has anyone implemented this?
You seem to be going in the right direction.
You can definitely do (as you suggested):
When the form is saved, inspect the form components and ensure the mandatory fields exist, and if they dont, create them or throw an error
Along with this, you can also extend the form builder and remove the "remove" icon that appears in the builder next to these mandatory components.
To do this,
Add a custom property to all the components, something like "customIsMandatory"
Modify the options.templates of the WebformBuilder to show a different template (one with "remove" icon removed) if the "customIsMandatory" is true for this component.
You can pre-populate these mandatory components in the builder and make sure that this property is set to true for them.

get notes input control from timeline via javascript

I would like to be able to hook an onChange event for the default text input box for Notes in a Dynamics CRM timeline (activity feed). However, I am not allowed to manually pull it from the DOM incase breaking changes occur in the future so I was hoping I could find it as a control with fixed name, such as fsdyn_notesinput for example.
However I have been unable to retrieve the specific control I am after. I can find "Timeline" which I believe contains the text control I want but have failed to find a way to enumerate the timeline's children or anything like that.
The intention is for me to be able to live check what is being typed into the box to look for special terms such as tags and provide additional functionality. I am very new to Dynamics development so it may be I am approaching this all wrong!
Currently I have nothing to share other than the typescript timeline fetch, which works:
let test2 = executionContext.getFormContext().getControl("Timeline");
We are using the new unified interface in the cloud.
You cannot hook an event handler to Notes control events in a supported way.
Instead, you can keep a multiline textbox in the entity form & onChange can be triggered on that field - you can provide additional functionality from here. You can create a Note (annotation) record with the content in this multiline field on record save.
In case of Notes creation from activity feed anywhere outside the entity form like dashboard, you should try C# Plugin on Notes record creation.

Write to CRM footer with JavaScript

I've noticed that when a mandatory field is not completed and a user attempts to save it adds a message to the form footer
Is it possible to do the same with JavaScript? For example, if I have a custom validation logic that fails (e.g. Start Date must occur within 6 months), is it possible and how would I add a validation message in the same location?
This (MSDN link) is the supported way of displaying custom notifications, similar to the ones that come up for required fields.
The linked MSDN is too long to copy-paste here, essentially we're looking at these functions:
Xrm.Page.getControl(arg).setNotification
Xrm.Page.getControl(arg).addNotification
Xrm.Page.getControl(arg).clearNotification
Business rule can help.
But you may need one more calculated field to achieve your need.

How to add custom field to dhtmlxScheduler?

I want to add multiple custom fields to the lightbox in dhtmlScheduler. I realize that this is a dup of a prior question but that answer is incomplete/incorrect.
My application correctly stores and recalls data from a MySQL database using dhtmlxDataProcessor on the client and dhtmlxConnector via PHP on the server side. I have carefully read, re-read, and parsed documentation on Custom "details" form. I've worked with the code in the 05_custom_editor.html sample.
The problem is that those examples do not work - they silently fail to store the second field, "Details", in the Description section. This is not surprising since nowhere is the field mapped to a database column.
What changes are needed so the "Details" field of the example form stored in the database and recalled with the event?
What changes are needed to support read-only data in the Details field that is populate based on the "Text" field? What I'm thinking of is a name that has an address associated with it.
How to invoke a custom windows with a form from the lightbox to populate the address?
I would prefer to be able to do this by extending the default lightbox, but that is not a requirement.
Any guidance is appreciated.
There are 3 required fields when using dhtmlScheduler. They are the first 3 in your PHP connector:
$scheduler->render_table("my_table","id","start_date,end_date,name,details,....
Your connector may use any column names as long as the order is preserved. But because it's required and used all over the place the dhtmlScheduler must refer to the name of the event. It is called "text".
The lightbox section maps description on to "text". I think that there is no
scheduler.locale.labels.section_description
for the same reason.
1) Update the PHP connector to pull in the required fields.
2) You can use sched.formSection('myfield') to get components from inside the lightbox, then you can add javascript to blur on focus.
3) Normal javascript
You can use one of the custom events alter any form items before you display the lightbox.
My dhtmlScheduler seems very vocal when it fails! What does the console say? Have you stepped through to see where it's failing?

Django Admin disable field dynamically based on other selections

I've built a django model where the required fields change based upon the user's selection on other previous fields. Specifically, it is an event scheduling application where the options change based on choices the user makes.
Some combinations of fields are simply invalid, and I have the model set to check for those and not allow them. However, it is a bit confusing in the UI to figure out the right combinations. I would like the admin UI to help with this by hiding or disabling invalid fields as the user changes other fields.
For example, if the user chooses to make the event repeat weekly, I need to disable (or ideally remove) all of the daily and monthly fields and only show the weekly ones, such as day of week.
Also, if they go back and change it to daily, then the fields that are shown or enabled need to change to reflect that selection.
How would I set up the admin form so that this happens? I know this is doable through the DOM and javascript, but I am trying to determine if there is a mechanism for this built in to Django. I've been searching the Django docs, but I can't seem to find it.
Does anyone have an example showing how you have done similar things?
There's no build in solution.
Simple solution is to add custom JavaScript code to your admin. See the reference here. Simply add the js and css files to the Admin class and script the form in your custom js.
class ReportAdmin(admin.ModelAdmin):
class Media:
js = (
'frontend/js/jquery-1.6.1.min.js',
'frontend/js/jquery-ui.min.js',
'frontend/js/custom_js.js',
)

Categories