Passing parameter to the SmartObject

  • 13 April 2009
  • 3 replies
  • 2 views

Badge +6

Greetings,

The below mentioned code is throwing an exception."SmartObject property Role_Name is a required property for selected method Get_Role_Users. Value must be set"

Is this the right way to pass the parameter value to the SmartObject method ?

            SmartObject employee = serverName.GetSmartObject("UMUser");
            employee.MethodToExecute = "Get_Role_Users";
            employee.Properties[0].Value = "Preparer";
            SmartObjectList employees = serverName.ExecuteList(employee);

            foreach (SmartObject so in employees.SmartObjectsList)
            {
                string bar = so.Properties["Name"].Value.ToString().Trim();
                Console.WriteLine(bar);
            }

 

If I mention the property name as; exception is thrown as"Key could not be found in the collection ! "

            employee.Properties["Role_Name"].Value = "Preparer";

Can anyone let me know how to pass parameter to the smartObject? When I execute the same method through "SmartObject Service Tester.exe", it works fine.

Thanks,

Aman


3 replies

Badge +6

Eureka!

To pass the parameter to the method, I used the following syntax;

            SmartObject employee = serverName.GetSmartObject("UMUser");
            employee.MethodToExecute = "Get_Role_Users";
            employee.ListMethods["Get_Role_Users"].InputProperties["Role_Name"].Value = "Preparer";
            SmartObjectList employees = serverName.ExecuteList(employee);

            foreach (SmartObject data in employees.SmartObjectsList)
            {
                Console.WriteLine(data.Properties["Name"].Value);
            }

 

Cheers !

Badge +4

I am also getting the same error "Key could not be found" for above resolution.


string

smoName = "ProjectDetails";


string methodName = "Z_K2_GEN_PROJ_INFO";


SourceCode.SmartObjects.Client.

SmartObject smartObject = connSmO.GetSmartObject(smoName);


 


int projectNumber = 72;


smartObject.ListMethods[

"Z_K2_GEN_PROJ_INFO"].InputProperties["p_PROJ_RESP_NUM"].Value = projectNumber.ToString();


SmartObjectList projectList = connSmO.ExecuteList(smartObject);


Is anybody has resolution on this issue? 


 


 


 

Badge +3

fwiw, I just got this error as well...however I forgot to deploy my SOs before I tried to deploy my workflow.  It's always the little things!!

Reply