Hello,
I have a SmartObject that has two methods, however List is the only one of concern here. I have tested the SmartObject using the SmartObjects Services Tester and it returns items using a list, and it will even filter on a property (GUID) when provided.
I have a requirement that has me processing results from a SmartObject Query so long story short, I needed to call the query in code. I created the following snippet (from code event):
Normal
0
false
false
false
EN-US
X-NONE
X-NONE
MicrosoftInternetExplorer4
string soConnection = K2.StringTable["ServiceObject
Server"];
string soConnString = soConnection;
rptResult sample;
SmartObjectClientServer soServer = new SmartObjectClientServer();
try
{
// create smart object server client to query
smartobjects
soServer.CreateConnection();
soServer.Connection.Open(soConnString);
//Instantiate SmartObject
SmartObject soAR = soServer.GetSmartObject(soConstants.soCRMAnalyticalResults);
string wr = K2.ProcessInstance.DataFields["WorkRequestID"].Value.ToString();
if (!string.IsNullOrEmpty(K2.ProcessInstance.DataFields["WorkRequestID"].Value.ToString()))
{
SmartListMethod getList = soAR.ListMethods[soConstants.soMethodList];
soAR.MethodToExecute = getList.Name;
//setup Filter
Equals myfilter = new
Equals();
myfilter.Left = new PropertyExpression(soConstants.sysARWorkRequest, PropertyType.Guid);
myfilter.Right = new ValueExpression(wr,
PropertyType.Guid);
getList.Filter = myfilter;
SmartObjectList AnalyticalResults =
soServer.ExecuteList(soAR);
Essentially it checks for a work request, if its there, set a filter and pull the smartobjects. For some reason this wont return any objects. I tried the ADO query option the SmartObject Services Tester and had similar behavior there with this:
Select * from soCRMAnalyticalResults
Where lims_workrequest = '{guid}'
'{guid}' is the actual guid without the {}. It returns no objects either, even though the 'Execute SmartObject' option does. also 'lims_workrequest' is the system name of the property I am querying. Something I have painfully learned I need to do with SmartObjects (at least with the CRM entity service).
Has anyone seen this or know what I am doing wrong?
Thanks!