Hi there,
I'm trying to use required fields validators on my k2 smart form. I have a K2 plan button which kicks off the workflow. The way I was trying to do it is the usual Page.IsValid, which works, but the workflow has already been started, and the fields are greyed out.
How do I get it to do the validation after they click the button, but before the workfow gets started?
Thanks,
Chloe
Page 1 / 1
Hi Chloe,
Please have a look at the following KB article: http://kb.k2workflow.com/Articles/KB000008.aspx
Please have a look at the following KB article: http://kb.k2workflow.com/Articles/KB000008.aspx
I got the following error when using the code mentionned in the knowledge base:
<script language="javascript" type="text/javascript">
var bW3Compliant = (document.getElementById) ? 1 : 0;
if (bW3Compliant) {
document.Form2.K2Submit.onclick = K2Button1_onclick;
}
function K2Button1_onclick()
// fires prior to server posting.
{
return (confirm("Are you sure you would like to start this process?")) ? true : false;
}
</script>
Server Error in '/Film Elimination' Application.
--------------------------------------------------------------------------------
Process instance is in an error state
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Exception: Process instance is in an error state
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
Exception: Process instance is in an error state]
Client.Throw(String s, Exception e) +106
Client.InternalCall(UInt32 sock, ArchiveX ar, Int32 hdr) +190
SourceCode.K2ROM.WorklistItem.Finish(Boolean Sync) +113
SourceCode.K2ROM.WorklistItem.Finish() +7
SourceCode.K2SmartForms.K2SmartForm.SaveData(K2SaveType SaveType, Object TriggerControl) +3135
1Exception: Process instance is in an error state]
SourceCode.K2SmartForms.K2SmartForm.SaveData(K2SaveType SaveType, Object TriggerControl) +5667
SourceCode.K2SmartForms.K2Button.OnClick(EventArgs e) +144
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +57
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +18
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
System.Web.UI.Page.ProcessRequestMain() +1292
<script language="javascript" type="text/javascript">
var bW3Compliant = (document.getElementById) ? 1 : 0;
if (bW3Compliant) {
document.Form2.K2Submit.onclick = K2Button1_onclick;
}
function K2Button1_onclick()
// fires prior to server posting.
{
return (confirm("Are you sure you would like to start this process?")) ? true : false;
}
</script>
Server Error in '/Film Elimination' Application.
--------------------------------------------------------------------------------
Process instance is in an error state
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Exception: Process instance is in an error state
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
Exception: Process instance is in an error state]
Client.Throw(String s, Exception e) +106
Client.InternalCall(UInt32 sock, ArchiveX ar, Int32 hdr) +190
SourceCode.K2ROM.WorklistItem.Finish(Boolean Sync) +113
SourceCode.K2ROM.WorklistItem.Finish() +7
SourceCode.K2SmartForms.K2SmartForm.SaveData(K2SaveType SaveType, Object TriggerControl) +3135
1Exception: Process instance is in an error state]
SourceCode.K2SmartForms.K2SmartForm.SaveData(K2SaveType SaveType, Object TriggerControl) +5667
SourceCode.K2SmartForms.K2Button.OnClick(EventArgs e) +144
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +57
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +18
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
System.Web.UI.Page.ProcessRequestMain() +1292
Have a look in K2.net Service Manager under Error Profiles. You should see more information as to the reason why the process instance is in error state.
Regards,
Ockert
Regards,
Ockert
Hi there,
I'm now getting a different error. The process status is set to error, but when I got into the service manager I can't find any explanation for the error under error profiles. Any idea why the error wouldn't show here, or how I can find out why the error has occurred?
Thanks,
Chloe
I'm now getting a different error. The process status is set to error, but when I got into the service manager I can't find any explanation for the error under error profiles. Any idea why the error wouldn't show here, or how I can find out why the error has occurred?
Thanks,
Chloe
Make sure that you have no filters specified on the Error Profile in K2.net Service Manager. You can also add a new Error Profile with the default configuration; this will insure that all errors are displayed.
Hi there,
I'm just returning to this issue after ignoring it for while! I have required field validators on my asp.net page, when I do Page.IsValid in the workflow button event, the workflow is started regardless if problems are encountered. I tried the javascript function as recommended, and it works fine, displaying a message box. I'm not sure how to build in here a way of checking my required fields though. What I really want it to do is use my required field validators to check the textboxes. My javascript isn't great, but is there a way of doing this? Or if not a way in javascript that I can check that the required fields are present?
Thanks in advance!
Chloe
I'm just returning to this issue after ignoring it for while! I have required field validators on my asp.net page, when I do Page.IsValid in the workflow button event, the workflow is started regardless if problems are encountered. I tried the javascript function as recommended, and it works fine, displaying a message box. I'm not sure how to build in here a way of checking my required fields though. What I really want it to do is use my required field validators to check the textboxes. My javascript isn't great, but is there a way of doing this? Or if not a way in javascript that I can check that the required fields are present?
Thanks in advance!
Chloe
Your best bet is using the java script as explained in http://kb.k2workflow.com/Articles/KB000008.aspx
Hi,
To test for a required field server side: Add a required field validator to the form, link it to the textbox you would like to test against.
Set the K2 button's CausesValidation property to True...
When you click the button, the setting will force the required field validator to fire before the code of the button click event - thus you don't need to test for anything in code. If a field is empty the validator's error message text will be displayed - the process will not start...
You can also add a summary validator control to display the errors of all validators in one list.
Note: The validator must be visible - if it's visible property is set to False, it will not fire!
Hope this helps,
Tersia
To test for a required field server side: Add a required field validator to the form, link it to the textbox you would like to test against.
Set the K2 button's CausesValidation property to True...
When you click the button, the setting will force the required field validator to fire before the code of the button click event - thus you don't need to test for anything in code. If a field is empty the validator's error message text will be displayed - the process will not start...
You can also add a summary validator control to display the errors of all validators in one list.
Note: The validator must be visible - if it's visible property is set to False, it will not fire!
Hope this helps,
Tersia
Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.