SmartObject as the datasource for Custom Control


Badge +1

Is there a way to make a current SmartObject the datasource for a custom control?


3 replies

Badge +1

I've already completed this now. I wanted to create a table that has a checkbox in the first row to select multiple rows without having to use control key.

Badge +1

Hello There,

 

Could you please share the information and sample code with me, if you have already implemented a custom control with SmartObject as the datasource.

 

Thanks in advance.

 

Regards,

Sunil

Userlevel 1
Badge +4

First make sure you have the references to at least the following:

 

SourceCode.EnvironmentSettings.Client

SourceCode.Forms.Client

SourceCode.SmartObjects.Client

SourceCode.HostClientAPI

SourceCode.Framework

 

 

Then from within your Control Code use something like:

 

//Use this helper method to create the connection to the Smart Object Client directly from Control Code (either in a handler or the control class itself)

var x = SourceCode.Forms.Controls.Web.SDK.Utilities.ConnectionClass.GetSmartObjectClient();

try
{

//Provide name of the Smart Object
SmartObject smartObject = x.GetSmartObject("Workflow_Comment");

// specify which method will be called
smartObject.MethodToExecute = "AddComment";

// specify input parameters for the method
smartObject.Properties["ProcessInstanceID"].Value = procInst.ToString();
smartObject.Properties["Comment"].Value = context.Request["comment"];

//Then execut the method (note there are also list method etc.)
x.ExecuteScalar(smartObject);

}
finally
{
//BE SURE TO CLOSE AND DISPOSE!!!!
x.Connection.Close();
x.Connection.Dispose();

}

 

 

 

You can also call the method below to return a data table:

 

// Execute to return data table
dt = x.ExecuteListDataTable(smartObject);

 

 

Good luck!

 

Reply