如何在Vtiger中使用AppConnector?

时间:2017-01-03 10:49:54

标签: php jquery jquery-plugins vtiger vtigercrm

我在vtiger中有一个API调用,它会给出记录详细信息,这个调用是由vtiger中的AppConnector.request()方法执行的。

如何从此调用中获取数据并在某些条件下进行操作。意思是,......我有一个像这样的代码

creditLimit : function(){
    var recordsData = null;
    jQuery('.btn-success').on('click', function(){
        var account_id = jQuery('[name="account_id"]').val();
        console.log('Account id is :: ' + account_id);

        var dataUrl = "index.php?module=Inventory&action=GetOrgDetails&record="+account_id;
        console.log("Data URL", dataUrl);
        AppConnector.request(dataUrl).then(
            function(data){
                for(var id in data){
                    if(typeof data[id] === "object"){
                        recordsData = data[id];
                        console.log(recordsData);
                    }
                }
                if(recordsData !== null){
                    return false;
                }
            },
            function(error, err){
                alert("error");
            }
        );
    });
},

在请求成功时填充recordsData变量。当我写完后基于recordsData的任何条件时,

AppConnector.request(dataUrl).then(
    function(data){
        for(var id in data){
            if(typeof data[id] === "object"){
                recordsData = data[id];
                console.log(recordsData);
            }
        }
        if(recordsData !== null){
            return false;
        }
    },
    function(error, err){
        alert("error");
    }
);

这里我想拥有recordsData变量。

当我直接写在这里时,它首先执行而不是执行上述请求。如何从请求中获取数据。当我从请求中得到一些东西时,我想结束这个流程。

谢谢&的问候,

0 个答案:

没有答案