Creating or Changing a SmartObject Return Value

  • 20 January 2011
  • 3 replies
  • 3 views

Badge +1

Hi All,


   I'm a developer, and very new to this smartobjects thing... here is the problem, at work we use a very simple smartobject (in smartbox DB) that is a simple counter... each time we run the "Create" method it  adds a number and returns it.



The smartobject "create" method cannot be changed because we have other things (processes) running that depend on that logic what we need is to be able to keep the counter running but have another method or associated smartobject ??? that returned a "improved" counter.


Current Logic (Method Create)


      Runs, adds 1 to the counter and returns the added value,   example: 3000



Logic being required (Method Create New / Another SmartObject associate ??)


    Runs, adds 1 to the counter and returns the added value with the current year, example


2011/3000


 


I have worked and played a bit with the smartobjects but francly i'm kind of lost here


How can this be done ?



Thanks in advanced


Miguel


3 replies

Badge +5

H Migas,


Please can you confirm what you are trying to do. K2 SmartObjects are a way of defining how to call an underlying service object. K2 provides a suite of these out of the box, SmartBox (CRUD opperations for SQL) SQL service to call SQL CRUD opperations on your defined sql tables, call views and stored procs. as well as a ton of others for SharePoint, ad. exchange ect. SmartObjects do not provide fucnctionality but declare what the underlying service does.


It sounds to me like you may need to define a sql stored proc that does what yuo want and then have a smart object tha exposes the stored proc, accepts your inputs and returns your result.


HTH

Badge +1

Hi HTH,


 HUmmmm so i am miss interperting SmartObjects right ? i had the idea that when i created a smartobject using the SmartBox DB, that it would create a table with similar structures.



But if that is not the case i can manually change the table and use a trigger or something like that to get a new collum that returns what i want right ?



SmartObject has 2 columns


   NumDoc  (autonumber)


   DateTime  (some date)


 


The corresponding table has also 2 columns


 


So the solution could be, added a column to the table


   NumDoc 


   DateTime


   SpecialNumDoc (VarChar   that would be something similar to 2011/3000  )



Then i would need to alter the smartobject to reflect this and add a new method to return that new column


 


Could this be a solution ?


 


Miguel

Badge +1

Hi HTH,


 


 I have now part of the solution, has a suspected if you change the smartobject (at least in smartbox DB) K2 deploy will change the DB table... all is fine with me about this.


Here is what i did so far.


   1. Change the smartobject to add a new column


  2. publish the project so the new column is added to the corresponding DB Table


  3. added a trigger that changed the insert so that the new column has the new data that i want..


 


Now i'm trying to create e new Create method that would return the value on that column,  but the K2 method wizard insists that it will only return the first property, that is a autonumber and a Primary Key



How can i fix this ?


Thanks in Advanced


Miguel

Reply