Skip to content

Instantly share code, notes, and snippets.

@ChuckJonas
Last active April 7, 2018 04:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ChuckJonas/dd1ebece206b135929ec39e781423af3 to your computer and use it in GitHub Desktop.
Save ChuckJonas/dd1ebece206b135929ec39e781423af3 to your computer and use it in GitHub Desktop.
BASS ts-force example
let accId = 'blah';
let accounts = await Account.retrieve(
`SELECT ${generateSelect(Object.values(Account.FIELDS))},
(
SELECT Owner.Id, Owner.Name
FROM ${Account.FIELDS.contacts.apiName}
)
FROM Account
WHERE Id = '${accId}'`
);
accounts.forEach(acc => {
acc.contacts.forEach(contact => {
if(contact.owner.name === 'the dude'){
contact.ownerId = acc.ownerId;
await contact.update(true); //should use CompositeCollection to bulkify this instead
}
});
});
let bulk = new CompositeCollection();
bulk.delete(accounts); //I didn't like those accounts anyways ;0
let newAcc = new Account({name: 'abc', otherField: 123});
await newAccount.insert(); //this one is much better
console.log(newAccount.id);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment