我已經開發了谷歌企業應用套件腳本從在Salesforce的自定義對象拉一些數據,並有我的列順序是:查詢到Salesforce返回列無序
SELECT Component__r.Name, Component__c, Product__c, Story_Name__c, Description__c, id , Product_Id__c, Priority__c , StoryName FROM Story__c WHERE Product_Id__c
然而,我的結果成谷歌電子表格來順序:
StoryName Component__r Component__c Product__c Product_Id__c Priority__c Id Description__c Story_Name__c
有人告訴我,這是沒有不尋常的SOQL查詢在不同的順序查詢返回的數據。是否有人知道使用哪種方法/函數/過程使列按查詢順序出現在電子表格中?我想在將這些列放在電子表格中之前這樣做,但如果沒有其他方法,那就沒關係。任何意見
function renderGridData(object, renderHeaders){
var sheet = SpreadsheetApp.getActiveSheet();
var data = [];
var sObjectAttributes = {};
//Need to always build headers for row length/rendering
var headers = buildHeaders(object.records);
if(renderHeaders){
data.push(headers);
}
for (var i in object.records) {
var values = [];
for(var j in object.records[i]){
if(j!="attributes"){
values.push(object.records[i][j]);
} else {
var id = object.records[i][j].url.substr(object.records[i][j].url.length-18,18);
//Logger.log(id);
sObjectAttributes[id] = object.records[i][j].type;
}
}
data.push(values);
}
Logger.log(sheet.getLastRow());
var destinationRange = sheet.getRange(sheet.getLastRow()+1, 1, data.length, headers.length);
destinationRange.setValues(data);
}
感謝:
我的數據在此功能拉回。
你怎麼實際執行sql查詢?,休息api,ajax工具包,別的東西? – superfell 2012-07-11 22:19:36
REST API ..下面 SOQL碼從另一頁 '函數storyQuery(SOQL){ VAR SQL =「SELECT Component__r.Name,Component__c,Product__c,Story_Name__c,Description__c,ID,Product_Id__c,名稱FROM CMC_Story__c WHERE傳遞Product_Id__c ='「+ soql +」'ORDER BY Component__c「; return fetch(** getRestEndpoint **()+「/ services/data/v」+ API_VERSION +「/」+「query?q =」+ sql); }' 和 'function ** getRestEndpoint()** { var queryEndpoint =「.salesforce.com」; var endpoint = getInstanceUrl()。replace(「api-」,「」).match(「https:// [a-z0-9] *」); 返回端點+ queryEndpoint; }' – 2012-07-11 22:58:30