Advertisement
Guest User

Untitled

a guest
Jun 17th, 2016
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. // Connection var username = 'myusername'; var password = 'mypass'; var jsforce = require('jsforce'); var conn = new jsforce.Connection({ // you can change loginUrl to connect to sandbox or prerelease env. // loginUrl : 'https://test.salesforce.com' }); conn.login(username, password, function(err, userInfo) {
  2. if (err) { return console.error(err); }
  3. // Now you can get the access token and instance URL information.
  4. // Save them to establish connection next time.
  5. console.log(conn.accessToken);
  6. console.log(conn.instanceUrl);
  7. // logged in user property
  8. console.log("User ID: " + userInfo.id);
  9. console.log("Org ID: " + userInfo.organizationId);
  10. // ... });
  11.  
  12. // Metadata API var fullNames = [ 'Account', 'Contact' ]; conn.metadata.read('CustomObject', fullNames, function(err, metadata) {
  13. if (err)
  14. {
  15. console.error(err);
  16. }
  17. for (var i=0; i < metadata.length; i++)
  18. {
  19. var meta = metadata[i];
  20. console.log("Full Name: " + meta.fullName);
  21. console.log("Fields count: " + meta.fields.length);
  22. console.log("Sharing Model: " + meta.sharingModel);
  23. } }); }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement