I have been learning about the CRM system for the past two days. And use a simple JSCodeTo operate the form to meet a constraint. In general, it is easier for some form users to expand.
CRM (Customer Relationship Management) was first proposed by Gartner Group, and entered China along with the tide of Internet and e-commerce. Currently, there is no unified definition of CRM. However, in terms of its functions, CRM is a management software system that enables enterprise marketing, sales management, customer service, support, and other business processes to realize the effective use of customer resources by using information technology. The core idea is to "customer-centric" to improve customer satisfaction, improve customer relationships, and thus improve the competitiveness of enterprises.
- Requirements for CRM modification (this document is used as an example)
Requirement 1: After CRM data is built, how can we constrain data? For example, tpye is one of the attributes of a form in an entity. In general, my type is a drop-down list. If one of them is "stock", another property is called "Booking, it becomes unusable for users. If other types are selected, they can still be used.
Requirement 2: Another example is type. If it is "scheduled", if another property is "internal", the value of this property is null, and we cannot let the user save it successfully.
Requirement 3: When loading a page, you need to display the type of the loaded form.
- Introduction to CRM form user Extension
There are three types of event:
Onload event
OnloadThe event is executed after the form is loaded. This event is used to pre-process some data for the user. Some other applications include:
- Computing Based on changes.
- The format of the prompt.
- Disable some areas that cannot be updated.
- Set a target in Form Based on the Data IFRAME.
Onsave event
OnsaveThe onsubmit method in the event and standard HTML is different. This event was clicked by the user.SaveOrSave and closeButton. Or the form is saved as if it were saved by a user's behavior. This event often occurs, even if the data is not changed in the form.
Onchange event
OnchangeEvents are valid in any region.OnchangeTo trigger an event, two conditions are required to be true:
- Data in this region must change.
- This region must be out of attention. (It is understood that the cursor leaves the focus position)
After this event is triggered, the data domain will re-verify the validity. This means that it is impossible to enter an invalid data.
OnchangeEvent example:
- When a region is changed, changes in other regions are displayed.
- Change the format of a region, such as a phone number.
- Implements dynamic picklists, that is, the drop-down list.
The above are some of the SDK content that I have reorganized and re-processed. To sum up, there are only three types, which are very clear. The trigger of these three events is also very clear.
Onchange event: triggered when the cursor is moved after the data changes.
Onsave event: triggered when a user attempts to save the modification.
Onload event: triggered when the form is loaded.
After the above analysis and learning, we can come up with solutions to the three requirements.
Requirement 1 solution: Add JS Code to onchange.
As we can see, CRM provides the onchange () method for us to directly hook the event in the event detail attribute, and then write the code we want to write in it. Of course, the specifics are different from those of standard Js. Detailed operations should be well learned in the SDK.
VaR O = Event. srcelement;
VaR Resource = Crmform. All. bookableresourceid;
Switch (O. selectedtext)
{
Case " Stock " :
Resource. Disabled = True ;
Resource. datavalue = "" ;
Break ;
Default :
Resource. Disabled = False ;
Resource. datavalue = Resource. defaultvalue;
Break ;
}
Alert (O. selectedtext );
Requirement 2 solution: add it to onsave.
Code
VaR Interval = Crmform. All. interval;
VaR Duration = Crmform. All. duration;
VaR Type = Crmform. All. type;
VaRCrm_form_save_mode_save= 1;
VaRCrm_form_save_mode_saveandclose= 2;
// Validate only if the user clicked "save ".
Switch (Event. Mode)
{
Case Crm_form_save_mode_save:
Case Crm_form_save_mode_saveandclose:
If (Type. selectedtext = " Scheduled " )
{
If (Interval. datavalue = Null | Duration. datavalue = Null )
{
// Tell the user what is wrong.
Alert ( " Interval or duration can not be empty " );
// Give the control focus.
If (Duration. datavalue = Null )
Duration. setfocus ();
Else
Interval. setfocus ();
// Cancel the save operation.
Event. returnvalue = False ;
Return False ;
}
}
Break ;
}
Requirement 3 solution: add the corresponding code in onload.
Code
VaR Crm_form_type_create = 1 ;
VaR Crm_form_type_update = 2 ;
VaR Readonly = 3 ;
VaR Disable = 4 ;
Switch (Crmform. formtype)
{
Case Crm_form_type_create:
Alert ( " This is a create form, the ID is " + Crmform. objectid );
Break ;
Case Crm_form_type_update:
Alert ( " This is an update form, the ID is " + Crmform. objectid );
Break ;
Case Readonly:
Alert ( " This is a readonly form, the ID is " + Crmform. objectid );
Break ;
Case Disable:
Alert ( " This is a disable form, the ID is " + Crmform. objectid );
Break ;
Default :
Alert ( " This is a default message " );
Break ;
}
VaR Resource = Crmform. All. bookableresourceid;
VaR Type = Crmform. All. type;
If (Type. selectedtext = " Stock " )
{
Resource. Disabled = True ;
Resource. datavalue = "" ;
}