Druhá časť zo série Microsoft Dynamics CRM – Javascript API zaoberajúca sa prácou s prvkami formulára. Táto téma by po správnosti mala predchádzať prvej kapitole o práci s kontrolkami, pretože ide o náhľad na metody pracujúce s celkovo formulárom resp. entitou – of course in english as previous post.
The CRM javascript API for manipulation with the entity’s form (ribbon) is represented by namespace called Xrm.Page.ui. It contains properties and methods to retrieve information about the user interface as well as collections for several subcomponents of the form. Here is top 5 usefull methods (full specification you can find on msdn network) :
1. Close - Method to close the form.
Xrm.Page.ui.close()
2. Current Control - Method to get the control object that currently has focus on the form. Web Resource and IFRAME controls are not returned by this method.
Xrm.Page.ui.getCurrentControl()
3. Form Type - Method to get the form context for the record.
Xrm.Page.ui.getFormType()
Method returns the number value from following table lists:
Value |
Form Type |
0 |
Undefined |
1 |
Create |
2 |
Update |
3 |
Read Only |
4 |
Disabled |
5 |
Quick Create (Deprecated) |
6 |
Bulk Edit |
11 |
Read Optimized (Deprecated) |
4. Form Notification - Use setFormNotification to display form level notifications and clearFormNotification to remove notifications.
Xrm.Page.ui.clearFormNotification(messageId)
Use this method to display form level notifications. You can display any number of notifications and they will be displayed until they are removed using clearFormNotification. The height of the notification area is limited so each new message will be added to the top. Users can scroll down to view older messages that have not yet been removed.
Xrm.Page.ui.setFormNotification(message, level, messageId);
Level is string variable with following values :
ERROR
: Notification will use the system error icon.
WARNING
: Notification will use the system warning icon.
INFO
: Notification will use the system info icon.
5. Refresh Ribbon - Method to cause the ribbon to re-evaluate data that controls what is displayed in it.
Xrm.Page.ui.refreshRibbon()
Little tip to the end: Specify constants to your code (in base or common Javascript library) for the Form Types. Example: FormType_Create = 1.