Skip to main content

I am creating a smartobject  using the AD service. I created one input parameter (manager) and one property (director). When I assign the input parameter there is no problem. But then when I try to assign the return value it is forcing me to use the inputs I used for the input parameter, If I try to change them it then changes them for both input and return. Has anyone else seen this and is there a solution, or am I going about this incorrectly?

Never had this issue.


 I created a simple AD helper object.



  1. New SmartObject
  2. Go to Advanced Mode
  3. Remove All SmartObject Methods
  4. Add a SmartObject Method
  5. Add a method name called GetManager
  6. Select a service method.  In this example I used the Active Directory Service -> Active Directory User -> User Manager.
  7. I didn't create the SmartObject properties manually so I just did a Create All.
  8. Note that my input and output parameters are all binded to difference SmartObject property values.

Perhaps if you have your steps to reproduce your issue, that might help.


Maybe I don't quite understand the smartobject. I followed the same procedure so now I have a smart object that seems to represent a manger. How do I hand it the parameter of a user to get their manager. Shouldn't the GetManager method take a parameter that is a user? I'm just used to seeing sometyhing like


 User _user = new User


           UsersManager = _user.GetManager(SomeUser)


Am I way off base in my thinking?


 


The SmartObject methods are normally methods where we use to execute some data access function (i.e. Get a record, Update a record, Create a record or Get a list of records).  So the SmartObject is an entity which has a bunch of properties.  So for example a data retrieval method could be putting in some filter criteria (e.g. The person's AD name) and then returning a result (e.g. The manager's AD name or the list of managed users).  This is essentially taking input parameters from specific properties in the SO and then returning data in different properties.


 This will allow you to map the SmartObject properties later to different things like as fields in email body text, updating to Process data fields to be used in line rules, etc.


So it's not really the standard concept of a function call where you put in a param and then have a return value.


Hi Johny,


i have a different issue here. my SO is working fine with methods. but when i getlist of records from custom sql database and trying to update them back to the update is not happening to all records returned by getlist method.


i tried a line rule which is self-redirecting and configured the rule to run this getlist and updates events as many times as the no of records as per getlist method. but all the times only first & ONE row only is getting updated in database.


Any clue? appreciate your responce.


I think the issue here is that you are probably looping back and selecting back the same set of records.  So if you use a SmartObject event wizard, it only updates  the first record.


I think if you want to use a looping pattern, you need to store a counter as a process data field.  You should then create a Load method that can select the relevant record based on the counter (maybe a custom stored procedure).


However, thinking it through.  Wouldn't executing a custom stored proc to select the records and insert it via T-SQL be more efficient?


The other possible option is that you can use the destination rules to execute an event for each record instance (but you can only pass in the ID field so you probably need to combine this with a Load method for each slot).


You might want to take a look at this article.


http://k2underground.com/blogs/johnny/archive/2010/05/06/k2-4-5-tip-of-the-day-executing-a-specific-event-for-each-piece-of-data-in-a-list-array.aspx


Reply