MobileCRM.UI.FormManager.showNewDialog - Resconet/JSBridge GitHub Wiki

Shows a new entity dialog.

Arguments

Argument Type Description
entityName String The entity name.
relationship MobileCRM.RelationShip The optional relationship with a parent entity.
options Object A JSON object containing a form-specific properties like pre-defined field values, peer iFrame options or document options.

This example demonstrates how to append the new associated contact from Account form. This code opens the new Contact form and pre-fills the parent customer field to currently edited Account.

function addAssociatedContact() {
	// Request entity form (currently edited Account form).
	MobileCRM.UI.EntityForm.requestObject(function (entityForm) {
		/// <param name="entityForm" type="MobileCRM.UI.EntityForm"/>
		var editedAcount = entityForm.entity;
		var target = new MobileCRM.Reference(editedAcount.entityName, editedAcount.id);
		var relationShip = new MobileCRM.Relationship("parentcustomerid", target, null, null);
		MobileCRM.UI.FormManager.showNewDialog("contact", relationShip, {
			"@initialize": {
				// force the form to pre-fill certain fields
				telephone1: editedAcount.properties.telephone1, // new contact will have the same phone as account
				address1_line1: editedAcount.properties.address1_line1, // ... and address too
				address1_city: editedAcount.properties.address1_city,
			},
			// These props will be passed to all iFrames on the contact form which is being opened
			iFrameOptions: {
				doNotRequirePhone: true,
			},
		});
	}, MobileCRM.bridge.alert);
}