Smartforms - field not updating


Badge +2

Hello,

I'm creating an Annual Leave process as my first proper foray into K2.

This currently consists of:

 

- A SmartObject for the data fields.

 

- A Request Form based on a Request (item) View for the current request, and a My Requests (list) View displaying the user's previous requests.

 

- An Authorisation Form for line managers, based on the submitted Request View and a Similar Requests (list) View that displays other requests that have been submitted by users in the same department, which overlap the current request.

 

- A workflow proj in K2 Studio.

 

What works so far:

User submits a request via the Request Form. User receives a confirmation email. Request status is updated to Requested.

An email is sent to the user's manager who can then click the link and open the Authorisation form.

The Authorisation form includes the "Workflow View" at the top, where they can select Approved, Declined or Rework from a drop-down. This updates the request status, date stamps it, and each outcome generates an email to the user worded accordingly.

 

What doesn't work:

I have a Comments field on the Request View, that is only visible to the authorising line manager. The idea is that the manager can leave an explanatory comment, particularly if asking the user to rework (change leave request dates) and then select the Request Status in the Workflow View.

However, I can't get it to retain this comment in the SmartObject. Whatever I try, the comment does not save. After entering a comment and saving, I should be able to go into the My Requests (list) View and see the comment next to the request, but it remains blank.

 

Using the "After the workflow action was submitted" Rule on the Authorisation form, I've tried executing the Save method on the view and on the smartobject. I've tried doing a "transfer data" to the smartobject, a "list refresh" on the My Requests view. I've also tried executing methods on the Control (the Comment field).

I've also tried moving these actions to a different rule, such as "When a control on a View raises an event" (On the Request form, when the comment field is Changed).

 

The Request form has a Submit button on it, and when the user clicks it, one of the actions is the Request view's Create method. This works (it creates a request), so I don't quite understand why the same view's Save method doesn't work when the manager enters a comment and either leaves the field, or submits their selected Request Status.

 

There are a couple of further issues related to this, but I guess I'll get onto those if and when I can get this bit resolved.

Thanks in advance for any help...

 

Gram


9 replies

Badge +7

Good Morning Gram,

 

A tool that I commonly use when I'm encountering issues is the SmartObject Service Tester: "C:Program Files (x86)K2 blackpearlBinSmartObject Service Tester.exe".  This will be on the servers that you've installed K2 on, and it is also available on your workstation if you've installed the client tools for K2.  You can go to the SmartOjbect explorer and right click on your smartojbect to test out its methods.

 

Where are you putting your data?  It looks like your probably going to SQL, but I just want to make sure.

 

The rule that will update your comments should be fired before you submit for any workflows.  It looks like this will be an update, so your form might look like Annual Leave and Process (unique id to the form), then you use that ID to fire an update.  So when the user clicks the button, you'd put in a rule that fires the update to the SmartObject (Execute a SmartOjbect method), then you can move into working with the workflow.

Badge +4

Hi Gram,


 


Below is a couple of thing to try to narrow down the issue:


 


What you can also have a look at is after running the “SmartObject tester tool” is to go to you SQL server and locate the table for that SmartObject, Right click and select “Select top 1000 rows”.


 


Once the table displays locate the row with the “ID” field you tested with and see if the comment is shown there, also see if the comment is shown for previous tests that have been done.


 


If the data is displayed in the SmartObject tester tool and in SQL then there could be something wrong with you view pulling the data or a rule that is not working as it is supposed to.


 


If the comments is now shown in SQL after the tests then it could be something wrong with you SmartObject.  You can test this by creating a test SmartObject with similar fields and test to see if it works or is it giving you the same issue.


 


Please let me know what the results was for you tests done.


 


Regards


Quintin

Badge +2

 

Hi Quintin.

I had a look usin the Tester Tool, executing a Create method for a new record, and a Save method on an existing record, both including comments in the Comment field.

Then I executed a Get List, and lo and behold, both records have the comments noted. When I go back to K2 Designer and run the form or view, I can see the comments for these 2 records.

 

Looking at the data in the Get List results in the Tester Tool, I can see that my early attempts to add comments clearly just failed.

At some point I must have changed some rules, which appeared to make no difference in K2 Designer, but actually did.

When I added the ID field to the (list) View in K2 Designer, I could see that the recent entries all had even numbered IDs.

 

In the Tester Tool's Get List, the more recent leave request tests have 2 records each - 1 containing the whole data as entered by the user making the request (sans comment), and the other containing just the ID, the required fields and the comment.

 

So in practice... the requestor opens the Request form. This includes the Request (item) View that has the Submit button on it. This Submit button is the only place where the Request View's Create method is fired. So it creates a record and starts the workflow.

The workflow sends the confirm email to the requestor, and the notification to the approver.

The approver clicks the link in his email, opening the Authorisation form. This form includes the same Request (item) View that the user filled in, but the Comment field is now enabled / visible, and the Submit button is disabled / not visible.

The Approver enters a Comment in the field, selects the Request Status in the Workflow View and clicks the Workflow View's Submit button.

This should save the the comment to the same record, but instead, a new record is being created either when the authorisation form is opened, or when the save is occurring.

 

 

Badge +2

My mistake - the Submit button isn't on the Request (item) View, it is on the Request Form, and therefore is not seen by the approver.

Badge +4

Hi Gram,


 


I just want to clarify is everything working now,


 If not please let me know issue you are facing currently.


 


Regards


Quintin

Badge +2

Well, with there being only one instance of the Create event (on the Request Form's Submit button), I don't understand how a 2nd record is being created when the Authoriser opens his form.

I guess it's either some rule issue I'm not comprehending, or when the workflow fires it's performing a Create.

 

In the interim, I've done something unknown, and now my Request Form hangs when I try and open it... Will have to try and resolve that first and will then take a look at the W/f, but any advice appreciated...

 

 

Cheers,
Gram

Badge +2

Ok, I found what was causing the Request View (and therefore Form) to hang - it was the ID field on View's Initialise.

The field wasn't populating, because the Create event is on the Submit button on the Request form - so at the Request View's (and also the Form's) initialise stage, the ID field does not yet have a value

 

So I added the ID field to the Authorisation Form instead.

On testing, a request is submitted correctly, it gets assigned an autonumber ID (confirmed by refreshing the My Requests view). The workflow runs, sending the emails to the requester and the approver. The link in the approver's email opens the Authorisation form, displaying a record that contains the correct requester's Name, the Start Date, End Date and length of the holiday, but the ID field is blank.

 

So... currently the Authorisation form opens a 'new' record containing the correct details, but with no ID, and then when the Workflow View's Submit btn is clicked, it somehow performs a Create, though I don't know how or where this is occurring.

 

Instead, I need the Authorisation form to open on the correct record (complete with ID), and then when the Approver enters a Comment and clicks the Workflow View's Submit btn, for that record to update with the Request Status and Comments.

 

Badge +2

Ok, focussing on a single component the problem, then...

 

A user submits a holiday request. This starts the workflow, firing an email to the authoriser. The email contains a Worklist Item link. When the authoriser clicks this it opens the correct form.

How do I get the correct record to load up in that form (as opposed to an apprently new record populated with some of the correct data)?

 

 

 

Badge +2

I managed to resolve this issue.

The reason a 2nd record was being generated was because the rule On View execute Create Method included the ID number field in the Input Mappings, in error.

 

From there I was also able to fix the Outcomes in the K2 Studio workflow, so it added the Comment field to the emails and passed them back to the SmartObject.

 

 

Reply