Wait for a RetrieveMultiple query

Feb 2, 2015 at 5:22 PM
Hi all,

I have a RetrieveMultiple query and I need to wait to the end of the request to hide a loading icon. I tried to hide the icon on the OnComplete function but it does not work. Please, can anybody helps me?

Thanks,
David Narbona
Coordinator
Feb 8, 2015 at 5:41 PM
Hi There.

Not sure if this is related with the toolkit but a HTML code you are looking for.

You can try post the code here for us to have a look.

Kind Regards,
Jaimie
Feb 10, 2015 at 11:29 AM
Hi,

I have the next HTML code:
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=620">
    <title>TimeLine</title>
    <script type="text/javascript" src="/Javascript/XrmServiceToolkit.js"></script>
</head>
<body>
    <div id="content">
        
        <div id="Timeline" style="margin-top:20px;">
            <img id="imgLoading" src='/Images/imgsloading.gif' style='margin-left:50%; margin-top:4%; width: 36px;height: 36px;'/>
            <div id="auxTimeLine">
            ...
            </div>
        </div>
    </div>
    <header></header>
    <article></article>
</body>
</html>
And the next JS code:
$(function () {
    ...
    DrawThisWeek();
});

function DrawThisWeek() {
    var now = new Date();
    var currentUserNow = new Date();
    var previousMonday = null;
    var nextSunday = null;
    var weekDay = -1;
    var dayMinutes = 24 * 60;
    var nowHourMinutes = 0;
    var nowTotalMinutes = 0;
    var nowHours = 0;
    ...
    SetActivitiesObject(previousMonday, nextSunday);
}

function SetActivitiesObject(fromDate, toDate) {
    if ((EntityID != null) && (EntityID != "")) {
        ...
        ShowLoading();

        XrmServiceToolkit.Rest.RetrieveMultiple(
            "ActivityPointerSet",
            "$orderby=ScheduledEnd asc&$filter=RegardingObjectId/Id eq guid'" + EntityID + "' and ScheduledEnd ne null and ScheduledEnd ge datetime'" + fromDate + "' and ScheduledEnd le datetime'" + toDate + "'",
            function (Activityresults){ 
            ...
            },
            function (error) {
                ...
            },
            function onComplete() {                
            },
            false
        );

        ...

        DrawTimeline();
    }
}

function DrawTimeline() {    
    ...
    ShowTimeLine();
}


function ShowLoading() {
    $("#imgLoading").show();
    $("#auxTimeLine").hide();
}

function ShowTimeLine() {
    $("#imgLoading").hide();
    $("#auxTimeLine").show();
}
In Firefox it works correctly and you can see the loading image while the query is retrieving records, but in Chrome and IE the loading image is not shown.

Thanks & Regards,
David Narbona