0

I'm trying to launch or populate another datatable based on values from another table.

For example, I'm using below code to get all "pending" items for the current user:

$(document).ready(function(){
loadPendingData();
});

function loadPendingData() {
//REST call
var requestInfo = _spPageContextInfo.webAbsoluteUrl + "/_api/web/Lists/getByTitle('AbsenceRequest')/Items?$filter=(((Manager0 eq '" + _spPageContextInfo.userEmail + "') and (Status eq 'Pending')) or ((Status eq 'Pending') and (AltManager eq '" + _spPageContextInfo.userEmail + "')))&$select=Id, Absentee, RequestType, ActivityType, EventDate, EndDate, Status";

var ajaxPending = $.ajax({
    url: requestInfo,
    type: "GET", 
    dataType: "json", 
    headers: { "accept": "application/json;odata=verbose" },
    success: mySuccHandler, 
    error: myErrHandler
});
}

And in my first datatable, I have a column that returns the following:

"aoColumns": [
            {//edit link
                "render": function(data, type, row) {
                    var rowID = row.ID;
                    var rowEventDate = row.StartDateISO;
                    var rowEndDate = row.EndDateISO;
                    return '<a href="javascript:modCheck(' + rowEventDate + "," + rowEndDate + ');">Check</a>';
                }
            },

On the second datatable, I want to use the rowEventDate and rowEndDate values to call another REST. Basically, when user clicks the check link, it should populate the 2nd datatable with items that are within the same date range. The purpose is for the managers to view all approved absences within the same date(s) requested before approving the current request. The REST call is as follow:

function modCheck(rowEventDate, rowEndDate) { 
var webAbsUrl = _spPageContextInfo.webAbsoluteUrl; 
var checkInfo = webAbsUrl + "/_api/web/Lists/getByTitle('AbsenceRequest')/Items?$filter=((StartDateISO ge datetime'" + rowEventDate.toISOString() + "') and (EndDateISO le datetime'" + rowEndDate.toISOString() + "'))&$select=Id, Absentee, RequestType, ActivityType, EventDate, EndDate, Status";

var ajaxAllAbsences = $.ajax({
    url: checkInfo,
    type: "GET", 
    dataType: "json", 
    headers: { "accept": "application/json;odata=verbose" },
    success: mySuccessH, 
    error: myErrHandler
});
}

But it's not populating the 2nd datatable. It doesn't have to be on the same page, it could be on another page but I just cant figure out how to pass the values from one page to another. enter image description here

1 Answer 1

0

EDIT I couldn't figure out how to pass the date variables to another function so I just passed the value as string, then converted to dates after. Seems to work.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.