Page 1 of 1

Getting variables for all cases through HTML/Javascript

Posted: Thu Aug 13, 2020 5:22 am
by amacquet
Hello,

I'm trying to make a HTML page in which all users could see informations for all cases, whether they participated or not.

Here is my JS function :
Code: Select all
$(document).ready(function () {
    $.get("../app-data.json", function (appdata) {
            token_value = readCookie('access_token');
            //Change the server name and the workspace
            var apiserver = 'http://xxx:82/api/1.0/workflow';
           var endpoint = '/cases/advanced-search';
            $.ajax({
                url: apiserver + endpoint,
                type: "GET",
                contentType: false,
                beforeSend: function (request) {
                    request.setRequestHeader("Authorization", "Bearer " + token_value);
                },
                success: function (data) {
                    console.log(data);
                    $.each(data, function (index, record) {
                        console.log(record.app_uid);
                        var apiserver = 'http://xxx:82/api/1.0/workflow';
                        var endpoint2 = '/cases/' + record.app_uid + '/variables';
						$.ajax({
                            url: apiserver + endpoint2,
                            type: "GET",
                            contentType: false,
                            beforeSend: function (request2) {
                                request2.setRequestHeader("Authorization", "Bearer " + token_value);
                            },
                            success: function (tableau) {
                                $('tbody').append('<tr class="tab-tr"><td class="tab-td"><a href="http://xxx:82/sysworkflow/fr-FR/neoclassic/cases/open?APP_UID=' + record.app_uid +
                                    '&DEL_INDEX=' + record.del_index + '" onclick="window.open(this.href); return false;">' + /*icône*/ '<img src="../images/historique.png" alt="historique" class="icone">' + ifUndefined(tableau.nom_recrute_label) + '</a></td><td class="tab-td">' + ifUndefined(tableau.prenom_recrute_label) +
                                    '</td><td class="tab-td">' + ifUndefined(tableau.service_label) + ifUndefined(tableau.service_apres_label) + '</td><td class="tab-td">' + convertDate(tableau.date_recrutement_label) + '</td><td class="tab-td">' +
                                    ifNonFini(record.app_status_label) + '</td></tr>');
                            }
                        });
                    });
                }
            });
        },
        'json'
    );
});
I can see in the browser console that the /cases/advanced-search endpoint return all cases, whether the logged user has participated or not.

Example, the array returned by the /cases/advanced-search endpoint contains 3 rows :
0: Object { app_uid: "1149291995f34f88a659ac2071367423", del_index: "9", del_last_index: "1", … }
​1: Object { app_uid: "1528625485f34ee27212209037342557", del_index: "9", del_last_index: "1", … }
​2: Object { app_uid: "8190002445f34eb42c6d290041730794", del_index: "9", del_last_index: "1", … }
​length: 3
​__proto__: Array []

But only 2 rows are displayed in my HTML tab.
Seems like the '/cases/' + record.app_uid + '/variables' endpoint returns variables only if the user has participated to the case.

Is there any way to retrieve variables, whether the logged user has participated or not to the case?

Thanks for your help
Antoine