Optional Client Event

  • 21 March 2007
  • 6 replies
  • 0 views

Badge +3
Hi,

I have an activty with a client event and a server event.
the client event (custom code), call a webservice to get some information and process data on our intranet and get a response (wait for user imput or continue to the next activity).

Depending to the reponse of the web service, i have to go directly to the server event and finish the activity to go to the next activity.

could you tell me how should I proceed

Thank

6 replies

Badge +9
I think the best place for the web service call is within a server event, not a client event since according to your description there is no human involved. I'd store the web service response in a process level data field.

I would then break these two events into their own separate activities and connect the two with a line that had a line rule that checks the web service response value previously stored in the process data field.
Badge +3
thanks but I can split my activity.

To give you more information:
When the activity starts, it call a webservice with the activity serial number as param.
The web service do some work and give a response.
If the response is continue --> go to the next activity
If the response is Wait --> send an e-mail and wait for user imput

The e-mail conains a link with the serial number to allow the user to take action but in some case, the user go to our intranet (without read the e-mail) and click on a link with the serial number (stored in our intranet by our webservice).

If a call the webservice ouside the client event, the serial number is different.
And I could not split my activity because the workflow is mainained by our support service and should be as simple as possible (i have actually 26 activities and it's a limit for some of our support people :shock: :cry: )
Amazing but true...

so My code look like...


Function HTTPFunction(ByVal K2 As ClientEventContext)
(-- var init--)

Try
' Call the webservice
oWebService.Url = K2.StringTable("WebServiceURL")
oWebService.Credentials = SourceCode.K2Utilities.GeneralMod.GetCredentials(oWebService.Url)

sAction = oWebService.SetK2ActivitySeriallNumber(IntranetRequestsId,K2ActivityName,K2ActivitySerialnumber)

if sAction = "Wait" then
(-- Add workitem to the user and send a mail --)
else
(-- do nothing and continue --)
end if

End Function



how can i solve this problem without having to split my activity / my event

thanks
Badge +9
Ok, I think I follow.

If splitting the events is not an option, then you will have to embed some conditional logic in your server event. There is no way to completely,conditionally skip an event within a K2 activity, however if you capture the webservice response back to a datafield (probably can just use Activity data field) in the client event, you can then wrap the entire code that currently exists within the server event within an IF statement that checks to make sure that the web service response was as expected. If not, that code will be skipped. So, the actual event will execute, but it will either execute or skip the code based upon the return value stored in the data field.

This buries some business logic outside of line rules, which is a little different than normal, but this is the only option I can think of that doesn't involve splitting the events.
Badge +13
Bob, even though you could skip some codes in the event, wouldn't the Client Event will still be stuck waiting to be completed?

I think the right way to do this is still to split the event if a client event has a chance of being skipped.

Unless you can use GotoActivity within the Preceding rule or somewhere so you actually bypasses the client event/that given activity.

However you won't be able to use parallel routing within your process since all other routes will be cancelled.
Badge +9
Good point Peter, I overlooked that.

I agree also that the right way to do this is splitting the events into separate activities.

Ponchautf, what sort of processing is your webservice doing with the serial number that could trigger a condition to skip the client event?
Badge +3
Thank,

I will use the gotoactivity within my server event.

Reply