get notes input control from timeline via javascript - 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.

Related

Ideas to change the price value using javascript on Trading View Order

I am working on order automation for Trading View.
Although I have been able to make some progress, changing the price for limit orders (as well as the quantity, any number) has been a challenge. I am able to change the value on the input but it doesn't really get updated in the app model (hence the buy button never reflects the change).
Any help will be highly appreciated.
Best
Sometimes the view of the value is not bidirectional connected to the hidden input field. Seems like the trading app is using some reactive framework, they usually integrate some UI components library, and those libraries hide the real input field in behind the beautiful mask of the ux oriented view on the front side.
Here you have 2 options
Try to set the value of hidden input field in behind the component and try to send the request to see if the new value is fetched, no matter if its visible on front or no
I think more user friendly option, to trigger the events on the HTML elements, this will require more research from your side to learn how to trigger events and check the results of those events step by steps. If you already know it then it will be fast.
For Example:
// Let's say pure js
// Keep in mind, id of element, not a hidden input field.
const dropdown = document.getElementById('idOfHTMLElement');
dropdown.click(); // After click the options of the dropdown should appear
const options = Array.from(document.getElementsByClassName('classNameOfDropDownOption'));
const desiredOption = options.find((option) => option.someConditionLikePriceOrSmthElse: boolean);
desiredOption.click();
// Something like this, not accurate code, please test and correct if you will use this

In Dynamics 365, is there a way to filter associated view results based on a record's field value and user permissions?

As the title states, I need to filter results of an associated view based on a record's field value and user permissions.
I've used some Javascript to achieve this whenever the iFrame loads, but if the user switches to a different view, my Javascript is not called and the filtered records come back. I've tried to implement an event listener for various changes within the iFrame, but haven't been able to get what I need. I've gotten onclick to call my function whenever the user opens the view dropdown, but I need it to call whenever they actually switch views.
Am I over complicating this and there's a native way to do this? Or does anyone know how to detect changes within an iFrame?
Unfortunately there’s no native config to do it by OOB. I recommend these.
Don’t rely on associated view, as the name suggests it’s for seeing all the associated records. Remove navigation item in Form editor to remove them if you don’t want your users to see it
Use Subgrid for all your different needs, but not with view switcher, as again you will get roadblock of view switch triggers, etc. also this is going to be unsupported approach to rig the FetchXml with your custom filters
Custom HTML with grid is better or even PCF control of your own to take query & filters
Plugin on RetrieveMultiple can be used in worst cases

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

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.

Dynamics CRM - Add/Remove events from a custom made settings page

Hi awesome developers,
Maybe someone can help or put me in the right direction. I want to create a settings page with a few yes/no options.
These settings need to enable or disable form events from different entities. First I was thinking about creating a new entity named foo_Settings with a few fields and yes/no options to trigger on change events. These events will then add or remove events from another entity.
After doing some research, I couldn't find any examples or cases or any info if this could be done through webservices.
I hope someone can help :)
Greets,
Yes, it is a common design pattern in CRM to have a settings/configuration-entity for storing settings such as this.
You can decide to either have one settings-record per organization, or maybe one settings-record per business unit if that suits your needs better. In this way you can have different configurations depending on the need of each business unit.
After creating the settings record and adding some boolean fields, you would write javascript that runs OnLoad of specific entities. This code would fetch the relevant settings-record, read the value of the relevant boolean-field and add a change listener depending on the value of the boolean by calling addOnChange().
After thinking about the settingspage and ways/solutions to create such functionality, there also was something that was itchy..
By creating a settings page and checking in the onload function of each entity with a fetch (odata call), this is not the most fastest or cleanest way. What if thousands of people are using a entity.. This will resulting that thousands of people will fetch.
So my solution will be:
Creating a settingspage (entity).. Onchange event of a setting will fire a odata call to set a record (true or false) on a hidden field in that entity..
In the onload of the entity I will check the value of that hidden field and do logic. This way I will prevent that there will be an Odata call every time the page loads..
Are there any other solutions?

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?

Categories