Показать сообщение отдельно
Старый 23.09.2020, 16:13   #2  
Ion is offline
Ion
Участник
 
332 / 16 (1) ++
Регистрация: 19.12.2012
Цитата:
Сообщение от Ion Посмотреть сообщение
Ребята привет.

Версия срм-ки 2020 release wave 1 enabled Server version: 9.1.0000.22251 Client version: 1.4.1442-2008.3.

Суть задачи проста как мир, обновить грид после асинхронной операции.
Функцию зарегистрировал с CrmParemeter "SelectedControl" и вызываю после асинхронной операции, но грид не обновляется

X++:
    function rejectGridView(primaryControl) {
        initiateApprovaRequestFromGrid(primaryControl, 173030003);
    }

    function approveGridView(primaryControl) {
        initiateApprovaRequestFromGrid(primaryControl, 173030002);
    }

    function initiateApprovaRequestFromGrid(primaryControl, status) {
        var entityGuids = [];
        var rows = primaryControl.getGrid().getSelectedRows();
        rows.forEach(function (selectedRow, i) {
            var entity = selectedRow.getData().getEntity();
            entity.attributes.forEach(e => {
                if (e.getName() == "status" && e.getValue() == 173030001) {
                    entityGuids.push({ id: entity.getId() })
                }
            })
        });
        if (entityGuids.length > 0) {
            showApprovalDialog(primaryControl, entityGuids, status);
        }
    }

    function handleApprovalRequest(primaryControl, recordsToApprove, status, comment) {
        Xrm.Utility.showProgressIndicator("Please wait...");
        var last = recordsToApprove.length - 1;
        recordsToApprove.forEach((record, indx) => {
            var data =
            {
                "status": status,
                "approvalcomment": comment
            };
            Xrm.WebApi.updateRecord("landedcost", record.id, data).then(
                function success(result) {
                    if (length == indx) {
                        Xrm.Utility.closeProgressIndicator();
                        primaryControl.refresh();
                    }
                },
                function (error) {
                    console.log(error.message);
                }
            );
        })
    }
Отбой! Пока писал увидел что название переменной было неправильно написано