Populating a repeating table from two sources

  • 19 February 2008
  • 3 replies
  • 0 views

Badge +2

My dataset from the smartObject returns some user-facing data and also some IDs of related records in other tables.  For example, the following is returned by the Invoice SmartObject:


 InvoiceID       UserID        Invoice Amount           Invoice Date


Instead of displaying the UserID, I'd like to display the UserName from the User SmartObject.  So, each row would look like:


Invoice ID       User Name    Invoice Amount    Invoice Date


How do I do that?  There doesn't seem to be anyplace in the repeating table to insert a rule that can do this. 


Maybe I should be doing this off a SmartObject that combines the data BEFORE it gets to the InfoPath form, but I'm not sure how to do that the K2 way.  The simple way would be to write a denormalized View that combines this information and then base a SmartObject on the view instead of on the table, but what's the right (K2/SmartObject-style) way of doing it? 


 -alex


3 replies

Badge +4

Hi Alex,


I assume you have 2 Smart Objects - Invoice and User.


What we need to achieve is an inner joint of the Invoice.GetList() and the User.GetList() tables upon the UserID column. 


First, create a new property called "UserName" in the Invoice Smart Object. 


In the GetList() method of the Invoice, switch to Adavnced Mode and edit the GetList() method.


Make sure you are in advanced mode of the wizard, then in the service object method screen ADD another SmartBox GetList method of  the "User" Service Object from the K2 object browser. Make sure you map the User Name from the Svc Object to the Smart Object Property "UserName".


After this screen, you will see the Service Link page. Enter the Join type and specify which is the primary key and secondary key.


Recompile and deploy, you should be able to see the UserName in your invoice object.


Hope this helps.


(note you may need a hotfix 201 from your local K2 rep)


Marco 


 

Badge +9

There is a detailed example on how to do what Alex suggests here:


 http://k2underground.com/blogs/fromthebench/archive/2008/02/13/composite-smartobject-basics.aspx


Download the attachment.  It contains a Word documen.

Badge +4

That is right.


You should be able to find more advanced samples of Smart Object in the K2 [blackpearl] SDK.


It will be available in our Portal Site soon as the older SDK version is under construction.


 Cheers,

Reply