Microsoft Developer Network > Página principal de foros > SharePoint - Workflow > Collect data from a User - Validation Bug
Formular una preguntaFormular una pregunta
 

RespondidaCollect data from a User - Validation Bug

  • lunes, 23 de julio de 2007 17:23André Rentes Medallas del usuarioMedallas del usuarioMedallas del usuarioMedallas del usuarioMedallas del usuario
     

    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.

Respuestas

  • martes, 24 de julio de 2007 10:17Massimo Prota Medallas del usuarioMedallas del usuarioMedallas del usuarioMedallas del usuarioMedallas del usuario
     Respondida

     

    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

  • martes, 24 de julio de 2007 12:04André Rentes Medallas del usuarioMedallas del usuarioMedallas del usuarioMedallas del usuarioMedallas del usuario
     Respondida

    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

Todas las respuestas

  • martes, 24 de julio de 2007 10:17Massimo Prota Medallas del usuarioMedallas del usuarioMedallas del usuarioMedallas del usuarioMedallas del usuario
     Respondida

     

    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

  • martes, 24 de julio de 2007 12:04André Rentes Medallas del usuarioMedallas del usuarioMedallas del usuarioMedallas del usuarioMedallas del usuario
     Respondida

    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

  • martes, 21 de agosto de 2007 9:06Umesh_K Medallas del usuarioMedallas del usuarioMedallas del usuarioMedallas del usuarioMedallas del usuario
     

    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

  • miércoles, 05 de septiembre de 2007 16:20xti55 Medallas del usuarioMedallas del usuarioMedallas del usuarioMedallas del usuarioMedallas del usuario
     

    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

  • viernes, 07 de septiembre de 2007 15:09Massimo Prota Medallas del usuarioMedallas del usuarioMedallas del usuarioMedallas del usuarioMedallas del usuario
     

    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

  • martes, 11 de marzo de 2008 10:24sarcos Medallas del usuarioMedallas del usuarioMedallas del usuarioMedallas del usuarioMedallas del usuario
     

    Thanks Massimo you solve all my problems. Smile

  • sábado, 11 de julio de 2009 22:28chester23 Medallas del usuarioMedallas del usuarioMedallas del usuarioMedallas del usuarioMedallas del usuario
     
    Where would I need to change? I cant get this to work