function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
澄人 鈴木 (Sumito)澄人 鈴木 (Sumito) 

Returned "Undefined" when using Google apps script to downloading Account data from Opportunity

Returned "Undefined" when using Google apps script to downloading Account data from Opportunity. Please help me to get proper record from Field "Account.Name".

Copied following method.
https://gist.github.com/stomita/990589

Modified as followings:

from: Opportunity
fields: Id,Account.Name

----
// Query account data from Salesforce, using REST API with OAuth2 access token.
  var fields = "Id,Account.Name";
  var soql = "SELECT "+fields+" FROM Opportunity LIMIT 100";
  var queryUrl = instanceUrl + "/services/data/v21.0/query?q="+encodeURIComponent(soql);
  var response = UrlFetchApp.fetch(queryUrl, { method : "GET", headers : { "Authorization" : "OAuth "+accessToken } });
  var queryResult = Utilities.jsonParse(response.getContentText());
----
AshwaniAshwani
I think authorization header is wrong. It should be:

var response = UrlFetchApp.fetch(queryUrl, { method : "GET", headers : { "Authorization" : "Bearer "+accessToken } });


澄人 鈴木 (Sumito)澄人 鈴木 (Sumito)
Thanks for your advise. I tried with the authorization header you recommend but the result was same as before.