MSDN > 論壇首頁 > SharePoint - Workflow > Collect data from a User - Validation Bug
發問發問
 

已答覆Collect data from a User - Validation Bug

  • Monday, 23 July, 2007 17:23André Rentes 使用者勳章使用者勳章使用者勳章使用者勳章使用者勳章
     

    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
      Rejected

     

    and configure it:

     

    Default value is blank
      Display as: Radio Buttons
      uncheck Allow Fill-in choices
      uncheck Allow blank values

     

    Click 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.

解答

  • Tuesday, 24 July, 2007 10:17Massimo Prota 使用者勳章使用者勳章使用者勳章使用者勳章使用者勳章
     已答覆

     

    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:

    http://blogs.msdn.com/sharepointdesigner/archive/2007/06/13/using-javascript-to-manipulate-a-list-form-field.aspx

     

    (My choice/approval field is a DropDown)

     

    Code Snippet
    function 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, 24 July, 2007 12:04André Rentes 使用者勳章使用者勳章使用者勳章使用者勳章使用者勳章
     已答覆

    Hi Massimo,

     

    I already hoped to be a bug. Thanks for help!

     

    How I have a radio button I made another function! Smile

    Code Snippet

     function 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, 24 July, 2007 10:17Massimo Prota 使用者勳章使用者勳章使用者勳章使用者勳章使用者勳章
     已答覆

     

    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:

    http://blogs.msdn.com/sharepointdesigner/archive/2007/06/13/using-javascript-to-manipulate-a-list-form-field.aspx

     

    (My choice/approval field is a DropDown)

     

    Code Snippet
    function 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, 24 July, 2007 12:04André Rentes 使用者勳章使用者勳章使用者勳章使用者勳章使用者勳章
     已答覆

    Hi Massimo,

     

    I already hoped to be a bug. Thanks for help!

     

    How I have a radio button I made another function! Smile

    Code Snippet

     function 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, 21 August, 2007 9:06Umesh_K 使用者勳章使用者勳章使用者勳章使用者勳章使用者勳章
     

    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 Snippet

     function 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, 5 September, 2007 16:20xti55 使用者勳章使用者勳章使用者勳章使用者勳章使用者勳章
     

    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, 7 September, 2007 15:09Massimo Prota 使用者勳章使用者勳章使用者勳章使用者勳章使用者勳章
     

    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, 11 March, 2008 10:24sarcos 使用者勳章使用者勳章使用者勳章使用者勳章使用者勳章
     

    Thanks Massimo you solve all my problems. Smile

  • Saturday, 11 July, 2009 22:28chester23 使用者勳章使用者勳章使用者勳章使用者勳章使用者勳章
     
    Where would I need to change? I cant get this to work