This Knowledge Base article describes how to use a SmartObject Method Parameter that is generated from an Advanced SmartObject created using a Service Object Method in K2 smartforms.
SmartObject Method Parameters surface in Advanced SmartObjects. In this example we are using the ADService2 GetUserDetails Service Object Method to create an Advanced SmartObject that contains a SmartObject Method Parameter. The parameter “Username” will be required to execute the “GetUserDetails” method in runtime.
Follow the steps below to implement the scenario as described above:
- Create the Get User Details SmartObject and select Advanced SmartObject as shown below. Click Next.
- Expand the Active Directory Service2 ServiceObject instances in the ServiceObject Explorer on the left and expand AD User. Drag the GetUserDetails method onto the canvas as shown below:
- The Method details screen will open. Click Next.
- Note the parameter “UserName” that is added as the Input property name. Click Create All to create ServiceObject method bindings for the SmartObject. Click Next and Finish.
- Select the Methods tab. Note the GetUserDetails method that was added. Click Finish to create the SmartObject.
- Generate an Item View using the Generate a View function on the Finish screen of the SmartObject Designer.
- Edit the View and go to the Rules step to see how the parameter has been used in the rule. Edit the Rule When GetUserDetails Button is Clicked. The GetUserDetails method will execute when the GetUserDetails Button is clicked. This Rule is automatically added when generating the View. Click Finish to close the Rule Wizard and Finish to close the View.
- Now Run the View and click on the Get User Details Button at the bottom. A dialog box is displayed listing the Text Box required to be populated. This is the parameter that is required to execute the GetUserDetails method of the SmartObject created.
- Type a valid name in the User Name Text Box at the top and click the Get User Details Button again. The View is populated with the data retrieved using the SmartObject method.