We can perform JScript validation on Activation or Deactivation of a record in CRM 2011.
We can achieve this by reading event save mode from CRM context (i.e.,CRM returns unique Codes or Numbers for different actions; Example 5 for Deactivation button click & 6 for Activation click).
Note :- CRM 2011 JScript allows us to pass “Execution Context” as first parameter to Jscript function.
Below are the steps
1) Create a new Jscript file and place below JScript function
// Use the following function on Form Save Event,
// CRM will pass the execution context in function paramter prmContext
function FrmOnSave(prmContext) {
var wod_SaveMode;
if (prmContext != null && prmContext.getEventArgs() != null) {
// “getSaveMode()” returns event mode value (i.e., 5 on Deactivation button click etc…)
3 responses to “JScript validation on Activation/Deactivation of record in CRM 2011”
Oliver
When doing this, this code will only be executed if the activate/deactivate buttons are clicked from within the form.
The code is not executed from the record list – but there we also have the activate/deactivate buttons.
Any ideas?
Steps mentioned in above post works only if you open the record and perform Activate/Deactivate.
To validate the same from main grid, you can include ‘EnableRule’ or ‘CustomAction’ for the ribbon buttons on the grid and validate.
Leave a reply to CRM 4.0 Event.mode Syntax Killed at Some Point in CRM 2011 – Jamie Miley – Life and Technology – Microsoft Dynamics CRM – Microsoft Dynamics Community Cancel reply