Collect data from a User - Validation Bug
-
Monday, July 23, 2007 5:23 PM
Hi,
I use the action "Collect data from a User". I add a new field of the type Choice, the next step I write two choices:
Approved
Rejectedand configure it:
Default value is blank
Display as: Radio Buttons
uncheck Allow Fill-in choices
uncheck Allow blank valuesClick Finich button
When the task is created I need to choose among Approved or Rejected, however if it be not chosen any alternative the validation doesn't work.
If I have a field text the validation works perfectly.
Is there a bug in validation form when the field is a "Choice type" ?
Please help-me.
Answers
-
Tuesday, July 24, 2007 10:17 AM
I confirm that, there is a bug so validation does not fire in a collect data generated form.
I've implemented a custom JS validation before form submit, based on this Rob's post:
(My choice/approval field is a DropDown)
Code Snippetfunction ValidateApproval(fieldName)
{
var x = getTagFromIdentifierAndTitle('select', 'DropDownChoice', fieldName);
if (x.value == '')
{
alert('You must choice an approval value!');
return false;
}
return true;
}And so, in submit button, before postback
Code Snippet<INPUT onclick="javascript: if(ValidateApproval('ApprovalField')) {ddwrt:GenFireServerEvent(concat('__update;__workflowTaskComplete={',ddwrt:EcmaScriptEncode(string($Id)),'*',ddwrt:EcmaScriptEncode($ListName),'};__commit;__redirectsource;__redirectToList={',ddwrt:EcmaScriptEncode($ListName),'};'))}" type="button" name="btnMarkSubmited" value="Complete Task">></INPUT>
HTH
Massimo
-
Tuesday, July 24, 2007 12:04 PM
Hi Massimo,
I already hoped to be a bug. Thanks for help!
How I have a radio button I made another function!
Code Snippetfunction checkRadio()
{
var theForm = document.forms[0];
for (var i=0; i < theForm.elements.length; i++)
{
if (theForm.elements[i].type == "radio")
{
if( theForm.elements[i].checked )
{
return true;
}
}
}
alert("Por favor selecione Aprovado / Rejeitado.");
return false;
}so, in submit button, before postback
Code Snippet<input type="button" name="btnMarkSubmited" value="Gravar" onclick="javascript: if(checkRadio()) {ddwrt:GenFireServerEvent(concat('__update;__workflowTaskComplete={',ddwrt:EcmaScriptEncode(string($Id)),'*',ddwrt:EcmaScriptEncode($ListName),'};__commit;__redirectsource;__redirectToList={',ddwrt:EcmaScriptEncode($ListName),'};'))}"></input>
Thanks a lot Massimo!
Att
All Replies
-
Tuesday, July 24, 2007 10:17 AM
I confirm that, there is a bug so validation does not fire in a collect data generated form.
I've implemented a custom JS validation before form submit, based on this Rob's post:
(My choice/approval field is a DropDown)
Code Snippetfunction ValidateApproval(fieldName)
{
var x = getTagFromIdentifierAndTitle('select', 'DropDownChoice', fieldName);
if (x.value == '')
{
alert('You must choice an approval value!');
return false;
}
return true;
}And so, in submit button, before postback
Code Snippet<INPUT onclick="javascript: if(ValidateApproval('ApprovalField')) {ddwrt:GenFireServerEvent(concat('__update;__workflowTaskComplete={',ddwrt:EcmaScriptEncode(string($Id)),'*',ddwrt:EcmaScriptEncode($ListName),'};__commit;__redirectsource;__redirectToList={',ddwrt:EcmaScriptEncode($ListName),'};'))}" type="button" name="btnMarkSubmited" value="Complete Task">></INPUT>
HTH
Massimo
-
Tuesday, July 24, 2007 12:04 PM
Hi Massimo,
I already hoped to be a bug. Thanks for help!
How I have a radio button I made another function!
Code Snippetfunction checkRadio()
{
var theForm = document.forms[0];
for (var i=0; i < theForm.elements.length; i++)
{
if (theForm.elements[i].type == "radio")
{
if( theForm.elements[i].checked )
{
return true;
}
}
}
alert("Por favor selecione Aprovado / Rejeitado.");
return false;
}so, in submit button, before postback
Code Snippet<input type="button" name="btnMarkSubmited" value="Gravar" onclick="javascript: if(checkRadio()) {ddwrt:GenFireServerEvent(concat('__update;__workflowTaskComplete={',ddwrt:EcmaScriptEncode(string($Id)),'*',ddwrt:EcmaScriptEncode($ListName),'};__commit;__redirectsource;__redirectToList={',ddwrt:EcmaScriptEncode($ListName),'};'))}"></input>
Thanks a lot Massimo!
Att
-
Tuesday, August 21, 2007 9:06 AM
Hi
I have a same requirement. I am also using Radio Buttons Approve / Rejece in my WorkFlow Taks
But After selecting the Option on Complete Task I want to update the Table in SQL 2005 Database
can any one help me in this
Thanks in advance
Regards
André Rentes wrote: Hi Massimo,
I already hoped to be a bug. Thanks for help!
How I have a radio button I made another function!
Code Snippetfunction checkRadio()
{
var theForm = document.forms[0];
for (var i=0; i < theForm.elements.length; i++)
{
if (theForm.elements[i].type == "radio")
{
if( theForm.elements[i].checked )
{
return true;
}
}
}
alert("Por favor selecione Aprovado / Rejeitado.");
return false;
}so, in submit button, before postback
Code Snippet<input type="button" name="btnMarkSubmited" value="Gravar" onclick="javascript: if(checkRadio()) {ddwrt:GenFireServerEvent(concat('__update;__workflowTaskComplete={',ddwrt:EcmaScriptEncode(string($Id)),'*',ddwrt:EcmaScriptEncode($ListName),'};__commit;__redirectsource;__redirectToList={',ddwrt:EcmaScriptEncode($ListName),'};'))}"></input>
Thanks a lot Massimo!
Att
-
Wednesday, September 05, 2007 4:20 PM
Where do you place this code? Every time I put the code in one of my aspx files I get an error message saying the web part has a problem. Is this even possible to use when creating workflows within Office SharePoint Designer?
Matt
-
Friday, September 07, 2007 3:09 PM
Hi Matt, try to put the js function in a script tag inside PlaceHolderMain at the top of page:
Code Snippet<asp:content id="content2" runat="server" contentplaceholderid="PlaceHolderMain">
<script type="text/javascript" language="javascript">
function ValidateApproval(fieldName)...
</script>
...
The call to this function at the bottom of the form instead, as I've highlited in my first reply.
This workaround IS for workflows (collect forms) generated by SPD
HTH
Massimo
-
Tuesday, March 11, 2008 10:24 AM
Thanks Massimo you solve all my problems.

-
Saturday, July 11, 2009 10:28 PMWhere would I need to change? I cant get this to work
-
Tuesday, May 25, 2010 11:29 PM
Has anyone heard of microsoft fixing this Bug or submitting it to Premier support to be resolved? Second, using this Javascript and modification to the form, if I open the task in SP-Designer after the Javascript and event handlers have been added to the ASPX task form, they get stripped out, and I have quite a few Collect Task forms throughout the workflow makign this quite extensive to maintain. I also find it very frustrating that this has gone known since the conception of MOSS 2007, and never resolved and they are now releasing MOSS 2010.. still unresolved. Why?
- Edited by BobBreton Tuesday, May 25, 2010 11:52 PM New info
-
Saturday, May 29, 2010 6:08 PM
We requested a fix for this issue in Mid-2007 (before the original post).
Should was included in SP1, but I can confirm the behavior is still unchanged with SP2 (both SharePoint and SPD)
Massimo Prota Microsoft .NET MCAD - MCTS MOSS Development and Configuration http://blogs.ugidotnet.org/mprota -
Tuesday, September 21, 2010 3:31 PM
I have been fumbling around all morning to try and implement this work around.
Here is what I have added immediately after the placeholderMain tag ->
function validateField(fieldName)
{
var theForm = document.forms[0];
for(var i=0; i < theForm.elements.length; i++)
{
if(theForm.elements[i].title == fieldName)
{
if(theForm.elements[i].value == "")
{
alert("You must select a value for " + fieldName + "!");
return false;
}
return true;
}
}
}I have also tried ->
function ValidateApproval(Test2)
{
var x = getTagFromIdentifierAndTitle('select', 'DropDownChoice', Test2);
if (x.value == '')
{
alert('You must choice an approval value!');
return false;
}
return true;
}In either case I always get an 'Error on page' when I click the 'Complete Task' button:
Line: 753
Char:2
Error: Object Expected
Code: 0
URL: http://servername:port/Workflows/WorkflowF/New%20Task%20_x0028_5_x0029_.aspx?ID=48&List=645ff444%2D3de9% etc.Can anyone tell me what I am doing wrong? I have a feeling it is something to do with the call from the button itself but there isn't much to that.
This is what I have for both cases I have referenced above, respectively:onclick=”javascript: if(validateField(‘Test2’)) {ddwrt:GenFireServerEvent…….
onclick="javascript: if(ValidateApproval('Test2')) {ddwrt:GenFireServerEvent
-
Thursday, January 13, 2011 5:07 AM
Hi Andre Rentes,
to perform validation on choice field in the edit formaspx add contenteditor webpart and write some java script below is the code snippet for ur reference
<html>
<body>
<script type="text/javascript" language="JavaScript">
functionPreSaveAction()
{
var control =document.getElementsByTagName("Input");
var selectedoptionscount =0
for(var i=0 ;i< control.length;i++)
{
if((control[i].type == "radio"))
{
if(control[i].checked == true)
{
if((control[i].name == ("ctl00$m$g_20d2b2ad_8bfb_45fc_a8b2_f85425d97f08$ctl00$ctl02$ctl00$ctl01$ctl00$ctl00$ctl07$ctl00$ctl00$ctl04$ctl00$ctl00"))||(control[i].name == ("ctl00$m$g_20d2b2ad_8bfb_45fc_a8b2_f85425d97f08$ctl00$ctl02$ctl00$ctl01$ctl00$ctl00$ctl07$ctl00$ctl00$ctl04$ctl00$ctl01")))
{
selectedoptionscount++;
}
}
}
}
if(selectedoptionscount ==0)
{
alert("select atleast one option);
return false;
}}
</script>
</body>
</html>
Note:to get the name of the radio button ,go to editform.aspx and in browser click on view->Source
To add webpart in editform follow the linkhttp://moblog.bradleyit.com/2009/04/creating-sections-in-sharepoint-forms.html
Regards
Bharani.T
bharani- Proposed As Answer by bharani.T Thursday, January 13, 2011 5:07 AM

