Microsoft Developer Network > 포럼 홈 > SharePoint - Workflow > Collect data from a User - Validation Bug
질문하기질문하기
 

답변됨Collect data from a User - Validation Bug

  • 2007년 7월 23일 월요일 오후 5: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.

답변

  • 2007년 7월 24일 화요일 오전 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

  • 2007년 7월 24일 화요일 오후 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

모든 응답

  • 2007년 7월 24일 화요일 오전 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

  • 2007년 7월 24일 화요일 오후 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

  • 2007년 8월 21일 화요일 오전 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

  • 2007년 9월 5일 수요일 오후 4: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

  • 2007년 9월 7일 금요일 오후 3: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

  • 2008년 3월 11일 화요일 오전 10:24sarcos 사용자 메달사용자 메달사용자 메달사용자 메달사용자 메달
     

    Thanks Massimo you solve all my problems. Smile

  • 2009년 7월 11일 토요일 오후 10:28chester23 사용자 메달사용자 메달사용자 메달사용자 메달사용자 메달
     
    Where would I need to change? I cant get this to work