Skip to main content
Nintex Community Menu Bar

Passing parameter to the SmartObject

  • April 13, 2009
  • 3 replies
  • 22 views

amankazi1
Forum|alt.badge.img+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

amankazi1
Forum|alt.badge.img+6
  • Author
  • April 13, 2009

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 !


Forum|alt.badge.img+4
  • June 17, 2009

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? 


 


 


 


Forum|alt.badge.img+3
  • Rookie
  • September 18, 2013

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!!