Use data from your Excel or Web Service blocks in other blocks

Follow

Comments

3 comments

  • Avatar
    Arpana Karanjit

    Can we use data from Excel block in our JavaScript?

  • Avatar
    Matthijs Koopman

    Yes this is possible, the way you should do this is by adding an Excel building block to your app.

    Next add the JavaScript block as child of the Excel block, this will allow you to access the data from the Excel block.

    You can find information about the JavaScript SDK over here: https://support.appmachine.com/hc/en-us/articles/203990983-Module-core-js

    Or see the sample I've attached below:

    function onLoad(){
        document.title = App.Properties.__caption;  
        document.getElementById('blockName').innerText = App.Properties.__caption;
    
        getRecord();
        getAllRecords();
    };
    
    function getRecord(){
    
        //Get the select item in the excel block
        window.App.Core.getCurrentRecord(function(record){
    
            //Record does contain the JSON version of the selected item
            alert(JSON.stringify(record));
    
        });
    };
    
    function getAllRecords(){
    
        //Get all the records available in the excel building block
        window.App.Core.getRecords(function(records){
    
            //Loop through each record
            for(var i = 0; i < records.length; i++){
    
                //Get the current record
                var record = records[i];
                document.write(JSON.stringify(record));
            }
    
        });
    
    };
    
    
  • Avatar
    Richard
    Thanks this helped alot

Please sign in to leave a comment.