<CustomAction Id="IFCustomRibbon" Location="CommandUI.Ribbon">
Image16by16="/_layouts/$Resources:core,Language;/images/formatmap16x16.png" Image16by16Top="-48" Image16by16Left="-48"
Image32by32="/_layouts/$Resources:core,Language;/images/formatmap32x32.png" Image32by32Top="0" Image32by32Left="-96"
if(confirm('This will complete the form and send notification to interested party'))
var $command = $get('FormControl_V1_I1_B29');
With the mechanism we basically can execute any Infopath buttons from our ribbon’s custom commands, such as run a workflow, open a modal dialog, etc. Though there is a catch that the buttons id tend to change if we change the structure of the form, but if we put the hidden buttons on the very top of the form, we can avoid the changes of the ids when the form structure changes.
var a = IPFSRibbon_GetFocusedFormControlId();
IPFSRibbon_HandleButtonClick(a, 'submit'); //this will submit the form
IPFSRibbon_HandleButtonClick(a, 'close'); //this will close the form
var navigateUrl = CurrentFormData_UrlToNavigateToOnClose(a);
NOTE. You must delete the browser’s cache files every time deploying the changes of the ribbon definition (CustomAction).
Microsoft SharePoint 2010, Infopath 2010, .NET