Tuesday, 4 September 2012

Check wheter dialog is completed succesfully or cancelled



ProcessLogStatus:
    {
        InProgress: 1,
        Succeeded: 2,
        Failed: 3,
        Canceled: 4,
        Waiting: 5
    }


IsDialogCancelled: function (regardingobjectid) {

        var fetchXml = '<fetch mapping="logical" count="1" version="1.0">';
        fetchXml = fetchXml + '<entity name="workflowlog">';
        fetchXml = fetchXml + '<attribute name="status" />';
        fetchXml = fetchXml + '<order attribute="createdon" descending="true" />';
        fetchXml = fetchXml + '<order attribute="stepname" descending="true" />';
        fetchXml = fetchXml + '<filter />';
        fetchXml = fetchXml + '<link-entity name="processsession" from="processsessionid" to="asyncoperationid">';
        fetchXml = fetchXml + '<attribute name="regardingobjectid" />';
        fetchXml = fetchXml + '<filter>';
        fetchXml = fetchXml + '<condition attribute="regardingobjectid" operator="eq" value="' + regardingobjectid + '" />';
        fetchXml = fetchXml + '</filter>';
        fetchXml = fetchXml + '</link-entity>';
        fetchXml = fetchXml + '</entity>';
        fetchXml = fetchXml + '</fetch>';
       
        var service = new crmSOAPService(orgUniqueName, server);
        var processlogstatus = service.Fetch(fetchXml);

        if (processlogstatus != null && processlogstatus.length > 0) {

            if (processlogstatus[0].attributes.status.value == ProcessLogStatus.Canceled) {
               
                return true;

            } else {

                return false;

            }

        } else {
            return false;
        }
    }

No comments:

Post a Comment