Unable to execute the code for finding out the duplicate values existed in the sharepoint list using jquery

Unanswered Unable to execute the code for finding out the duplicate values existed in the sharepoint list using jquery

  • 21. října 2011 5:16
     
     
    Hello All,
                      Im srikanth,new to sharepoint. I have a task to find out the duplicate value existed in the list using jquery. Im new to jquery, im unable to find out the error existed in this below code: Can any one tell me what is wrong in the code that i have written.
    $().SPServices
    ({
    operation: "GetListItems",
    listName: "Questions",
    async: false,
    CAMLQery: query,
    completefunc:function(xData,status)
    {
    // alert ($(xData.responseXML).find("z\\:row").length);
    $(xData.responseXML).find("z\\:row").each(function()
    {

    var duid=$(this).attr("ID");
    if(i==duid)
    {
    alert("Found");
    }

    });
    }


    });

Všechny reakce

  • 24. října 2011 9:05
    Moderátor
     
     

    Hi,

     

    Thank you for your question.

     

    I am trying to involve someone familiar with this topic to further look at this issue.


    Entan Ming
  • 9. listopadu 2011 23:08
     
     

    Hi Srikanth,

    If you still did not find the help/answer for this question, please feel free to open a support ticket with Microsoft customer support team for further assistance.

    Cheers,

    Jeff - MSFT

  • 10. listopadu 2011 3:39
     
      Obsahuje kód

    Hi Srikanth,

    I had tried the below code and it works for me.

    <script type="text/javascript" src="[Link to your jquery-1.6.2.min]">
    </script>
    <script type="text/javascript" src="[Link to jquery.SPServices-0.6.2.min]"></script>
    <script type="text/javascript">
      $(function() {
    
      <!--Query for fetching the list item details from the list-->
      var query = "<Query></Query>";  
      <!--SPServices to query the sharepoint list and fetch the title-->
      $().SPServices({
      operation: "GetListItems",
      listName: "Questions",
      async: false,
      CAMLQuery: query,
      completefunc: function (xData, status) {
      $(xData.responseXML).find("z\\:row").each(function() {
      var duid = $(this).attr('ows_ID');
      if(i == id)
      {
      alert("Found")
      }  
      });
      }
      });
      });
    </script>
    

    Hope this helps !

  • 10. května 2012 5:37
     
     

    @Rakesh: Can you please explain your above code? What is the variable i? do we need to replace the ows_ID with the column name for the checking the duplicate values? I would appreciate your response.

    Please let me know if the below code is correct.

    wrote the script in  PreSaveAction so that the value can be checked before adding or updating.
    Where test is the SharePoint Custom List, title is the column name of the custom list

    <script type="text/javascript" src="../../Assets/jquery.SPServices-0.6.2.min.js">
    </script>
    <script type="text/javascript" src="../../Assets/jquery-1.7.2.min.js"></script>
    <script type="text/javascript">

    function PreSaveAction()

    {

      $(function() {

      <!--Query for fetching the list item details from the list-->
      var query = "<Query></Query>"; 
      <!--SPServices to query the sharepoint list and fetch the title-->
      $().SPServices({
      operation: "GetListItems",
      listName: "test",
      async: false,
      CAMLQuery: query,
      completefunc: function (xData, status) {
      $(xData.responseXML).find("z\\:row").each(function() {
      var duid = $(this).attr('title');
      if(i == duid)
      {
      alert("Found")
      } 
      });
      }
      });
      });

    }
    </script>


    Amalaraja Fernando,
    SharePoint Architect
    This post is provided "AS IS" with no warrenties and confers no rights.



  • 12. května 2012 2:22
     
     

    Hi amalaraja,

    Yes you are right. Replace your list name and column name in the above code. In your case the column name would be "ows_Title" and the list name will be "test".

  • 14. května 2012 4:23
     
     

    @Rakesh: Thanks for the reply.

    From your below code, what is variable i and what values does it hold?

    if(i == duid)
      {
      alert("Found")
      } 


    Amalaraja Fernando,
    SharePoint Architect
    This post is provided "AS IS" with no warrenties and confers no rights.

  • 16. května 2012 10:03
     
     

    Hi Amalaraja,

    Sharepoint 2010 as default supports to avoid duplicate value in a list while adding list item.

    There is an option called Enforce unique values.

    Could you please tell the exact req or why the above option could not be used.Also please tell me when the script would be run.in which form etc.

  • 22. května 2012 8:40
     
     

    @Balu: Thanks for the reply. I know that SharePoint 2010 supports Enforce Unique values. My Query was on MOSS 2007.


    Amalaraja Fernando,
    SharePoint Architect
    This post is provided "AS IS" with no warrenties and confers no rights.