0

Team,

Is there anyway at all, to add the input parameter "issueItem" into the CAML query result, i.e. tag each row of the result, so that when its passed back I can extract it at the same time as the rest of the results?

function getIncidentItemsWithCaml(listTitle,issueItem) {
    console.log('get Incidents for: ' + issueItem); 
    //use of $.Deferred in the executeQueryAsync delegate allows the consumer of this method to write 'syncronous like' code
    var deferred2 = $.Deferred();
    var clientContext = new SP.ClientContext.get_current();
    var list = clientContext.get_web().get_lists().getByTitle(listTitle);
    var camlQuery = new SP.CamlQuery();        
    camlQuery.set_viewXml('<View><Query><Where><Eq><FieldRef Name="Issue" /><Value Type="LookupMulti">' + issueItem + '</Value></Eq></Where></Query></View>');
    var items = list.getItems(camlQuery);
    clientContext.load(items);
    clientContext.executeQueryAsync(
        Function.createDelegate(this,
            function () { deferred2.resolve(items); }),
        Function.createDelegate(this,
            function (sender, args) { deferred2.reject(sender, args); }));

    return deferred2.promise();
};  
0

Team,

Sorted, I worked out how to add the extra parameter I wanted into the promise which achieved the same result I was looking for (see the last parameter in the promise.all and the last variable created at the end)

                // here we get the two promises
                var incidentsRequest = getIncidentItemsWithCaml('SMOIFIncidents', issueTitle);
                var risksRequest = getRiskItemsWithCaml('SMOIFRisks', issueTitle);

                // then we pass them to Promise.all to wait for them both to resolve
                Promise.all([incidentsRequest, risksRequest, issueTitle]).then(
                    function (allResponses) {

                        var incidentItems = allResponses[0];
                        var riskItems = allResponses[1];
                        var issueItem = allResponses[2];

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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