About 1.5 ago I wrote post which describes how to work with additional parameters during save of form. I decided to go through all available standard forms and create extended list of available parameters.
Here is the list of supported save modes which can be found at following article – http://technet.microsoft.com/en-us/library/gg509060.aspx:
Here is my addition to this list:
Lead Qualification
ExecutionObj.getEventArgs().getSaveMode() equals to 16
Additional available fields:
Additional Field | Comment |
crmFormSubmit.qlShowNew.value | Equals to true if checkbox “Open newly created records” is checked, otherwise equals to false |
crmFormSubmit.qlCreateAccount.value | Equals to true is checkbox “Create Account” is checked |
crmFormSubmit.qlCreateContact.value | Equals to true is checkbox “Create Contact” is checked |
crmFormSubmit.qlCreateOpportunity.value | Equals to true is checkbox “Create Opportunity” is checked |
crmFormSubmit.ulNewStatus.value | Value of new status |
crmFormSubmit.qlOppCurrencyId.value | Filled in case checkbox “Create Opportunity” is checked, contains identifier of currency |
crmFormSubmit.qlOpportunityParentType.value | Filled in case checkbox “Create opportunity” is selected, both contact and account are unchecked, contains typecode of selected customer(1 – account, 2 – contact) |
crmFormSubmit.qlOpportunityParentId.value | Filled in case checkbox “Create opportunity” is checked, both contact and account are unchecked, contains identifier of selected customer |
Opportunity
When you are closing opportunity for both cases (Win and Lost) ExecutionObj.getEventArgs().getSaveMode() equals to 5
Additional Field | Comment |
crmFormSubmit.crActivityXml.value | Contains information about Opportunity Close activity that will be created. Sample for case when Opportunity is closed as Won: <opportunityclose> <actualrevenue>1875000</actualrevenue> <activityid>{E0158FD7-B25E-E111-8D38-08002742C360}</activityid> <opportunityid>{2D75634F-9973-E011-8720-00155DA5304E}</opportunityid> <description>Description</description> <actualend>2012-02-23T00:00:00</actualend> <subject>Subject for close task</subject> </opportunityclose>Sample for case when Opportunity is closed as Lost:<opportunityclose> <actualrevenue>0</actualrevenue> <activityid>{3FCCBBD8-B55E-E111-8D38-08002742C360}</activityid> <opportunityid>{2D75634F-9973-E011-8720-00155DA5304E}</opportunityid> <description>Description</description> <actualend>2012-02-23T00:00:00</actualend> <subject>Subject for close task</subject> <competitorid>{4C97A4EC-B55E-E111-8D38-08002742C360}</competitorid> </opportunityclose> |
crmFormSubmit.crNewStatus.value | Contains new status for Opportunity |
crmFormSubmit.crNewState.value | Contains new state for Opportunity |
Example how to work with activity field you can find at following post – http://butenko.pro/2010/06/extended-handling-of-save-event-in-forms-with-close-dialog-like-opportunitites/
Here are additional events that can be handled during work with Opportunity form:
Event Mode | ExecutionObj.getEventArgs().getSaveMode() equals to |
New Quote | 22 |
New Sales Order | 21 |
New Invoice | 23 |
Quote
When you create Create Order from Activated Quote ExecutionObj.getEventArgs().getSaveMode() equals to 17. Additional fields:
Additional Field | Comment |
crmFormSubmit.aqDescription.value | Contains description |
crmFormSubmit.aqActualRevenue.value | Contains actual revenue, available only when checkbox “Use Given Revenue” checkbox is checked |
crmFormSubmit.aqUseGivenRevenue.value | Contains true when “Use Given Revenue” checkbox is checked |
crmFormSubmit.aqCloseOpportunity.value | Contains true when “Close Opportunity” checkbox is checked |
crmFormSubmit.aqCloseDate.value | Contains Close Date |
crmFormSubmit.aqNewStatus.value | Contains new Status for Quote |
When you close Quote ExecutionObj.getEventArgs().getSaveMode() equals to 25. Additional fields for event:
Additional Field | Comment |
crmFormSubmit.cqDescription.value | Contains description |
crmFormSubmit.cqOppState.value | Contains new Opportunity state |
crmFormSubmit.cqOppStatus.value | Contains new Opportunity status |
crmFormSubmit.cqActivityXml.value | Contains close activity |
crmFormSubmit.cqCloseOpp.value | Contains true when checkbox “Close Opportunity” is checked |
crmFormSubmit.cqReviseQuote.value | Contains true when checkbox “Revise Quote” is checked |
crmFormSubmit.cqCloseDate.value | Contains Close date |
crmFormSubmit.cqNewStatus.value | Contains new Status for Quote |
Here are additional events that can be handled during work with Quote form:
Event Mode | ExecutionObj.getEventArgs().getSaveMode() equals to |
Get Products | 28 |
Activate | 29 |
Revise | 24 |
Sales Order
When you fulfill Sales Order ExecutionObj.getEventArgs().getSaveMode() equals to 56. Additional fields for event:
Additional Field | Comment |
crmFormSubmit.coDescription.value | Contains description |
crmFormSubmit.coCloseDate.value | Contains Close date |
crmFormSubmit.coNewStatus.value | Contains new Sales Order status |
When you cancel Sales Order ExecutionObj.getEventArgs().getSaveMode() equals to 26. Additional fields for event:
Additional Field | Comment |
crmFormSubmit.coDescription.value | Contains description |
crmFormSubmit.coCloseDate.value | Contains Close date |
crmFormSubmit.coNewStatus.value | Contains new Sales Order status |
Here are additional events that can be handled during work with Quote form:
Event Mode | ExecutionObj.getEventArgs().getSaveMode() equals to |
New Invoice | 19 |
Use Current Pricing | 51 |
Get Products | 43 |
Lock Pricing | 50 |
Invoice
Here are additional events that can be handled during work with Invoice form:
Event Mode | ExecutionObj.getEventArgs().getSaveMode() equals to |
Invoice Paid | 57 |
Invoice Canceled | 27 |
Get Products | 44 |
Lock Pricing | 52 |
Use Current Pricing | 53 |
Case (Incident)
When you Resolve Case ExecutionObj.getEventArgs().getSaveMode() equals to 5. Additional fields for event:
Additional Field | Comment |
crmFormSubmit.crNewStatus.value | Contains new Status |
crmFormSubmit.crActivityXml.value | Contains Close Case activity in XML format. Sample:
<incidentresolution> |
When you Cancel Case ExecutionObj.getEventArgs().getSaveMode() equals to 40.
Contact
Here are additional events that can be handled during work with Contract form:
Event Mode | ExecutionObj.getEventArgs().getSaveMode() equals to |
Invoice Contract | 38 |
Recalculate | 4 |
Cancel Contract | 33
crmFormSubmit.ccCancellationDate.value contains date of contract cancellation |
Copy Contract | 39 crmFormSubmit.ccIncludeCancelledLines.value equals to true if checkbox “Include cancelled lines” is checked |
Hold Contract | 31 |
Release Hold | 32 |
Renew Contract | 34 crmFormSubmit.rcIncludeCancelledLines.value equals to true if checkbox “Include cancelled lines” is checked |
Of course you should know that this approach is 100% unsupported.
Hi Andrii,
I have the problem to manage the Close Event in the Task entity, because I need to do some different action if the task close "Completed" or close "Canceled". I understood that I can use event.mode but how I can know the new status ?
I try to use this code
if (event.Mode == 5){
alert(crmFormSubmit.crNewStatus.value);
}
but it doesn't work, do you know why ?
Hello,
What CRM do you use? 2011 or 4.0?
Hi Andrii,
Want to know that would it help for CRM 2016 Online ?
i want to run a javascript when the Opportunity gets closed, but even though the opportunity form is getting disabled and status is changing the javascript is not getting triggered.
Any suggestion ??
Hello,
I’m not 100% sure. What code do you use?
function ABC(execObj) {
debugger;
try {
var status = execObj.getEventArgs();
if (status.getSaveMode()==5 || status.getSaveMode()==”5″) {
alert(“message”);
}
else if (saveMode == “6”) {
alert(“Opportunity ” + saveMode);
}
}
catch (ex) {
alert(“exception”);
}
}
Hi,
Above mentioned function is not getting triggered on close of opportunity ..the function is scheduled on form “OnSave”.
If you want to handle closing of window event I’m afraid you can’t. You can handle only handle only save events.