Skip to content

MobileCRM.UI.ViewController.createCommand

rescocrm edited this page May 15, 2023 · 9 revisions

Overrides the form's primary/secondary command button.

Arguments

Argument Type Description
primary Boolean true, for primary button; false, for secondary button.
labels Array/String An array of labels or single label.
callback Function A callback which is called when command is launched.
scope Object A scope, in which the callback has to be called.

This example demonstrates how to set the command buttons for a WebController. It will set two commands on primary command button for switching to previous/next tab on a form.

// Create primary command on form with two options
MobileCRM.UI.ViewController.createCommand(true, ['Previous', 'Next'], function (command) {
	MobileCRM.UI.EntityForm.requestObject(function (entityForm) {
		// Handle command and select previous/next tab on the form
		if (command == 'Previous')
			entityForm.form.selectedViewIndex--;
		else
			entityForm.form.selectedViewIndex++;
		return true;
	});
}, null);
Clone this wiki locally