Saurabh Garg
Saurabh Garg

Reputation: 201

How to use a single returned value if method return set of values

function readMetaData() {

  var spreadsheet = SpreadsheetApp.getActiveSpreadsheet();
  var sheet = spreadsheet.getSheetByName(METADATA_SHEET);
  var range = sheet.getRange(1,2);
  var sprintFixVersion = range.getValue();
  var range = sheet.getRange(2,2);
  var hotfixAndPatchVersion = range.getValue(); 

  Logger.log(sprintFixVersion);
  Logger.log(hotfixAndPatchVersion);

  return {
    "sprintFixVersion":sprintFixVersion,
    "hotfixAndPatchVersion": hotfixAndPatchVersion
  };
}

above method returns two value, but while calling a function I need only one value at a time means either sprintFixVersion or hotfixAndPatchVersion. Is there any way to achieve this?

Upvotes: 1

Views: 49

Answers (2)

Saurabh Garg
Saurabh Garg

Reputation: 201

Even we can use

readMetaData()['hotfixAndPatchVersion']

Upvotes: 0

DonovanM
DonovanM

Reputation: 1198

If you just want to access one of those properties it's pretty simple. For example:

var hotfixVersion = readMetaData().hotfixAndPatchVersion;

Upvotes: 2

Related Questions