Wednesday, October 26, 2011

CDC Software Pivotal CRM 6.0: How to open window of custom size.

To open forms in popup or modal window we usually use ShowForm method from Foundation Library:

Globals.ShoForm(formOrTableName, recordId, parameterList, actionTargetWindow);


But it opens forms with a default size.
To open forms with the custom size we need to define TargetWindowProperties of the action.

Here is an example:

// Get the instance of ActionService
IActionService actionService = ClientContext.ClientAPIService.GetService();

// Initialize form action target request
IFormActionTarget formActionTarget = actionService.CreateActionTarget();
formActionTarget.Form = "My Form";
formActionTarget.Table = "Support_Incident";            
formActionTarget.RecordId = recordId;
formActionTarget.ParameterList = parameterList;

// Set target window properties
ITargetWindowProperties windowProperties = actionService.CreateNewWindowProperties();
windowProperties.UseDefaultSize = false;
windowProperties.Resizable = true;

// Set the custom window size
windowProperties.Width = 600;
windowProperties.Height = 600;

// Create action to open a popup window
IAction action = actionService.CreateAction(string.Empty, ActionCommand.Show, ActionContent.Record, formActionTarget);
action.TargetWindow = ActionTargetWindow.Popup;
action.TargetWindowProperties = windowProperties;

// Execute action
actionService.ExecuteAction(action);


With the power of Pivotal CRM,
Max Shafranski
:)