Hi there,
What's "Onchange", "Onsave" and "Onload" in CRM ?
Can you give me an example?
Thanks
*This post is locked for comments
Hi there,
What's "Onchange", "Onsave" and "Onload" in CRM ?
Can you give me an example?
Thanks
*This post is locked for comments
What's "Onchange", "Onsave" and "Onload" in CRM => These are events which get triggered against a control when the page is loaded on the client side.
is it possible to make certain fields required using the OnSave event and if so where could I find the code? => Yes. You'll need to write a event handler or simply said a javascript function to handle the onSave event when it fires with the logic to make the field you want as required. However, its important to understand when these events get fired as stated in Jason's response before deciding on whether you'd do it in the OnSave or Onchange events.
Hi Awebio,
On Load is when a form is loaded in CRM (i.e. the form view for that record is displayed). This occurs when you open a record, or when you save the record and what is shown on the screen is automatically refreshed.
On Field Change is when data is manually selected / input into a field.
On Save is when you have a record open in front of you and you save it.
These can allow fields to conditionally be displayed/made mandatory/locked/made read only (based on other field values) or data to be defaulted (e.g. today's date), whole sections or tabs to be displayed.
You can use business rules to do some of these actions e.g. to make fields mandatory (they trigger on-load of the form view and/or on field change, and will show the field as now being 'mandatory' - a red asterix appears on the form view). Prompts for any missing data then occur if you press 'Save' without having filled in these fields i.e. just before the on save event (you cannot save the record without these fields that are now 'business required' / mandatory).
The advantage of business rules is that they are configurable (i.e. no coding skills required, and fully supported). So you get on-load (when the selected record's form loads or refreshes after saving) and on-field-change changes (when a field is updated) in CRM's behaviour without needing to write code.
However, some things can only be achieved with Jscript e.g. hide/display whole sections or tabs (including their tab/section labels).
To make certain fields required, you can use Business required option for attribute..
You need to go to entity customization and click on fields, then all attributes in selected entity listed, then double click on attribute it will open new window, change field requirement to Business required.
Then this save attribute and publish. when this attribute is on form, CRM will throw error when it is blank.
This is easy option.
Another options are
JavaScript.. you need to add JavaScript code on form onSave and need to check attributes has value or not.
To add javaScript you need to create javaScript web resource add it to form libraray and add function on form Onsave
When you click on Add (4) then new window will come, need to add JavaScript function name.
which has your code..
Another option is Real time workflow or plugin-- for these options needs to write some .net code and need to register code to CRM.
For validation you need to use plugin or real time workflow.. when there is another source for data.. I mean data will be added to CRM other than CRM user interface.
Hope this will help..
Jason, is it possible to make certain fields required using the OnSave event and if so where could I find the code?
In order to customize CRM further, you can add JavaScript code to certain form events to extended the functionality beyond what comes out of the box.
These are a few of the events you can tie your custom code into.
OnChange - the event when a field value changes - ex. you change the account name from 'ABC' to'123'
OnLoad - the event the happens when the form loads and after the data is populated - ex. when the form opens you check the value of a certain field and pop up a message to the user to remind them to do something
OnSave - the event just prior to saving the data back to the database - ex. the perform some additional validation on the data before saving and cancel the save if the data does not meet your requirements
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,280 Super User 2024 Season 2
Martin Dráb 230,235 Most Valuable Professional
nmaenpaa 101,156