Announcements
I have seen many posts regarding this issue.
1. That this is not supported
2. That some have gotten it to work
I have tried this with no success. The system function I was trying to call, takes a CRM Parameter (Primary Control).
I guess the question is what is the alternative, if this functionality is not supported?
The useful scenario is to add a 'JS Confirm' functionality before the system action is executed.
Here is the Command Definition:
<CommandDefinition Id="Override.Account.SavePrimary">
<EnableRules>
<EnableRule Id="Mscrm.AvailableOnForm" />
<EnableRule Id="Mscrm.CanSavePrimary" />
<EnableRule Id="Mscrm.ReadPrimaryPermission" />
<EnableRule Id="Mscrm.IsAutoSaveDisable" />
</EnableRules>
<DisplayRules>
<DisplayRule Id="Mscrm.CanSavePrimaryEntityType" />
</DisplayRules>
<Actions>
<JavaScriptFunction FunctionName="testsave" Library="$webresource:newab_testscirpt">
<CrmParameter Value="PrimaryControl" />
</JavaScriptFunction>
</Actions>
</CommandDefinition>
And the JS:
function testsave(PrimayControl) {
if (confirm("Are you sure?"))
Mscrm.RibbonActions.saveForm(PrimayControl);
}
*This post is locked for comments
scratch my last post. I can apply your suggestion to the 'Submit Order' scenario as well.
Alex, I'll give this shot. looks promising. The reason I wanted to do this through the button action was that on a separate project, I need to tie this sort of functionality to the 'Submit Order' button, which does not have a unique Save Action status. That's why I had to tied it to the button itself.
This would be a purely unsupported nonsense (we are not supposed to do these things), but, if you just added the script below as a web resource to your form (no need for the ribbon buttons/handlers), it would work. It's relatively harmless from the upgrade standpoint and can be easily removed.
var originalSaveForm = window.parent.Mscrm.RibbonActions.saveForm; var inSave = false; function overridenSaveForm(param) { if (!inSave) { inSave = true; try { if(confirm("Are you sure?")) originalSaveForm(param); } finally { inSave = false; } } } window.parent.Mscrm.RibbonActions.saveForm = overridenSaveForm;
"delete post" does not work - see correct one below.
I don't want to re-write the ProcessOrder functionality. I merely want to make a few validations, when the user clicks the 'Submit Order' button and if passed, call the OOB ProcessOrder function.
You would need to implement your own custom server side process to do this and call from JavaScript.
Scott,
And what if I am overriding the 'Submit Order' which calls the Mscrm.SalesOrder.ProcessOrder() JS functionality? What would be the equivalent of that in Xrm.Page.entity object model?
Do Xrm.Page.entity.save and Mscrm.RibbonActions.saveForm(PrimayControl) offer the same functionality?
Hi
It isn't supported to call OOTB ribbon functions in this way - you will need to use the Xrm.Page.entity.save - msdn.microsoft.com/.../gg334720.aspx
Hope this helps
I cloned the OOB button and attached the command to the new button (using workbench). I have tested this with other commands that do not pass a parameter to the script, and it works fine. It is only when there is a parameter being passed to the script, that the standard call doesn't get executed. I do get the 'Confirm' prompt.
André Arnaud de Cal...
294,157
Super User 2025 Season 1
Martin Dráb
232,930
Most Valuable Professional
nmaenpaa
101,158
Moderator