-
Notifications
You must be signed in to change notification settings - Fork 53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Explanation of Xrm.ExecutionContext<any, any> #259
Comments
TSource and TArgs allows specification of the return types of Since we usually don't use either However, when the functions are needed they should be properly typed. However, the typings depend on where you register your functions. Typed namespace entity_name_form_name {
var Form: Form.entity_name.Main.form_name;
export function onLoad(executionContext: Xrm.ExecutionContext<
Xrm.UiModule<Form.entity_name.Main.form_name.Tabs, Form.entity_name.Main.form_name.Controls>,
Xrm.LoadEventArgs>) {
Form = <Form.entity_name.Main.form_name>executionContext.getFormContext();
... run some logic...
} Typed function onSelectedRecordChanged(ectx: Xrm.ExecutionContext<Xrm.PageEntity<Xrm.AttributeCollection>, undefined>) {
var source = ectx.getEventSource();
if (source.attributes.get("field_logical_name").getValue() !== null) {
source.attributes.get('other_field_logical_name').controls.get()[0].setDisabled(true);
}
} The example uses the generic Note that I've made a few changes in order to use supported functions (which are the only ones we generate typings for):
They should all behave identically but the functions I've used are documented and have typings. |
Thanks for your reply. I appreciate it. |
That seems like a reasonable conclusion, though I would just go with the Typings offer a lot, but if a column is removed from your editable grid the typings are not going to detect it (unless the column is removed from the form as well). The typings can of course still be helpful during development, but won't offer the usual compile time error if columns used in your code are removed from your grid. Additionally, I would like to update my code for the
|
Hello everyone,
I would like to ask if someone could explain what can be TSource or TArgs when passing executionContext.
This is how I manage to do it now but I think it can be better way but I don't know what type can I use here and when.
Another problem for me is that I have editable subgrid and I would like to write function to be triggered when user selects record
(this is the event I would like to catch on.
And in my old way I was doing it by
and now my question is, if it is even possible to take advantage of TypeScript in this case?
This is what Xrm provides, but I do not know what to choose if any.
I must say that I am quite new in TypeScript, but it is awesome!
Best regards!
The text was updated successfully, but these errors were encountered: