Skip to main content

Greetings Everyone, I have a simple smart object, this smart object saves following info to smart box.

1) SerialNumber

2)ProcessName

3)StartDateTime

etc. etc. 

Now,  is it possible to provide initial value to a property in smartobject. Eg. I would like to insert current date time while calling smart object through smart object event?

As far as I know, with the current functionality there is no way to set a default value for simple smart objects. 


What you can do is to go into advanced mode and add a srvice object method that will give you the current date and time.  You can then place this before your  smartbox service method called create. 


To do this, go into your smart object and chnage the mode to advanced.


Make sure you check run this wizard in advanced mode.


Go to the service object and click add.  At this stage you will need a service object method that returns the current date and time (you can find one in the black market part of this site).  Assign the return value of your service object method, to your StartDateTime property.


I have not tested this, so I hope this helps you.


You can always open up the SmartBox table for the SmartObject you created and modify the table schema to incorporate a default value there. Keep in mind the caveat to this is you may lose those default values if you repeatedly publish your SmartObject to the SmartBox.


Another option would be to 'hard-code' some kind of value in the artifact calling the SmO event. Are you trying to write this from a custom event, or from inside a K2 process?


Thanks guys for the response,

EndpointSys, first thing i did was changed the table schema with getdate() as default value, works great but then it is overwritten whenever smartobject is published.

I am using this smart object inside k2 service, only solution i can think of is to assign current date time to a datafield in a server event in the first step of process. Then assign this datafield to smartobject event while calling save method.

It should work just fine, but i wanted to bypass this one extra step coz now i need to add this extra step in all the processes in project.

Do let me know of any other ideas, folks

Thanks a lot to all for replies.... 

 


Reply