[Vtigercrm-developers] [Vtigercrm-Developer] How to work with AppConnector in Vtiger?

kiran kiranraju.jakka at gmail.com
Wed Jan 4 09:04:17 GMT 2017


Hi,

I have an API call in vtiger which will give Accounts record details, this
call is executed by AppConnector.request() method in vtiger.

How to get the data from this call and manipulate with some conditions.
Meaning that,... I have a code like this

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");
            }
        );
    });
},

	
I have an API call in vtiger which will give Accounts record details, this
call is executed by AppConnector.request() method in vtiger.

How to get the data from this call and manipulate with some conditions.
Meaning that,... I have a code like this

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 variable is filled when request successful. When i write any of
the conditions based on recordsData after the,



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");
    }
);


Here i would like to have the recordsData variable.

When i write here directly it is executing first rather than above request.
How to get the data from the request. I would like to end the flow when i
got something from the request.

Thanks & Regards,



--
View this message in context: http://vtiger-crm.2324883.n4.nabble.com/Vtigercrm-Developer-How-to-work-with-AppConnector-in-Vtiger-tp20341.html
Sent from the vtigercrm-developers mailing list archive at Nabble.com.


More information about the vtigercrm-developers mailing list