SmartForm Validate list item selected before execute rule?

  • 31 March 2018
  • 2 replies
  • 69 views

Badge +8

Hi again. 

 

It seems like this should be possible...but I can't figure it out.

 

I have a smartform that when a button is clicked, it executes a stored procedure to update one or more work items that are selected from a list view in the form.  If an item is selected in the list view, it works perfectly, as it should.  However, when an item is NOT selected, of course you get an error because SQL is looking for an item ID which is a mandatory field in the stored procedure as it's doing an update.

 

So, if you just click the button with nothing selected, you get:

 

SmartObject property ItemID is a required property for selected method Execute. Value must be set.

 

 

As far as I can tell, there is no built in rule to validate if a list item is selected before a rule will fire...there's nothing in "If the form passes validation" etc. 

 

I'm sure that there is a way, though.  Any of you smart K2 folks have any suggestions?

 

Thanks,

 

Rob

 


2 replies

Badge +12

Hi,

The use of data labels might help you. Under the event when a list item is clicked, you can do a transfer data to the data label control so it holds the ID of the  row selected. When the button is clicked, you could add a condition to check whether that data label control is empty or not so that you will only have to call the stored proc when it has a value in it.

Badge +8

Ajo - Yea, I thought about that one.  It will probably work (sort of) but it seems as though I'd have to make sure that the data label gets cleared out every time the list is "unclicked' (such as when the list refreshes, etc.)  

 

But that's likely what i'll have to do.

Reply