Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Get all contacts modified in last 2 days using soap query

Posted on by 4,601

Hi Guys,

I am looking fetch contacts modified in last 2 days using soap query.

Thanks,

Sandeep

*This post is locked for comments

  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Get all contacts modified in last 2 days using soap query

    Your query will look like this:

    function lastdaysmodifiedon(){
    var date = new Date();
    date.setDate(date.getDate()-2);
    
    var dateFilter = getODataUTCDateFilter(date);
    
    "/xrmservices/2011/OrganizationData.svc/ContactSet?$select=FullName,ModifiedOn&$filter=ModifiedOn ge" + dateFilter +"'";
     
    }
    
    function getODataUTCDateFilter(date) {
       var monthString;
       var rawMonth = (date.getUTCMonth() + 1).toString();
       if (rawMonth.length == 1) {
           monthString = "0" + rawMonth;
       }
       else { monthString = rawMonth; }
       var dateString;
       var rawDate = date.getUTCDate().toString();
       if (rawDate.length == 1) {
           dateString = "0" + rawDate;
       }
       else { dateString = rawDate; }
       var hourString = date.getUTCHours().toString();
       if (hourString.length == 1)
           hourString = "0" + hourString;
       var minuteString = date.getUTCMinutes().toString();
       if (minuteString.length == 1)
           minuteString = "0" + minuteString;
       var secondString = date.getUTCSeconds().toString();
       if (secondString.length == 1)
           secondString = "0" + secondString;
       var DateFilter = "datetime'";
       DateFilter += date.getUTCFullYear() + "-";
       DateFilter += monthString + "-";
       DateFilter += dateString;
       DateFilter += "T" + hourString + ":";
       DateFilter += minuteString + ":";
       DateFilter += secondString + "Z'";
       return DateFilter;
    }


  • Suggested answer
    a33ik Profile Picture
    a33ik 84,323 Most Valuable Professional on at
    RE: Get all contacts modified in last 2 days using soap query

    That's definitely correct. If you have more than 5000 records you will have to use paging to get all records:

    msdn.microsoft.com/.../gg309717.aspx

    msdn.microsoft.com/.../gg328046.aspx

  • sandeepstw Profile Picture
    sandeepstw 4,601 on at
    RE: Get all contacts modified in last 2 days using soap query

    It returns 5000 records, I don't think that right.

  • Suggested answer
    a33ik Profile Picture
    a33ik 84,323 Most Valuable Professional on at
    RE: Get all contacts modified in last 2 days using soap query

    Sandeep,

    Following FetchXml query should resolve your requirement:

    <fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false">

     <entity name="contact">

       <attribute name="fullname" />

       <attribute name="telephone1" />

       <attribute name="contactid" />

       <filter type="and">

         <condition attribute="modifiedon" operator="last-x-days" value="2" />

       </filter>

     </entity>

    </fetch>

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,253 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,188 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans