upsertRecord = (sobjectName, recordDataWithID, oauth) => {
  const sobj = nforce.createSObject(sobjectName)
  const recordId = !!recordDataWithID.id ? recordDataWithID.id : ''
  sobj.setExternalId('Id', recordId)
  Object.entries(recordDataWithID).map(([key, value]) => {
    sobj.set(key, value)
  })
  return new Promise((resolve, reject) => {
    org.upsert(
      {
        sobject: sobj,
        oauth: oauth,
        requestOpts: {
          method: !recordId ? 'POST' : 'PATCH'
        }
      },
      (error, response) => {
        if (!error) {
          if(!recordId) {
            resolve(response)
          } else {
            resolve(recordDataWithID)
          }
        } else {
          reject(error)
        }
      }
    )
  })
}
Upsert a record
@param {string} sobjectName - Name of the SObject (e.g. Account)
@param {object} recordDataWithID  - Key value pair of Field Names and Field Values
@param {object} oauth       - OAuth string received from successful authentication