7

I'm using Andrew Fawcett's legendary Apex Wrapper Salesforce Metadata API in several projects. It perfectly works and provides a new dimension of APEX programming. Now there are situations where it would be more convenient to access Metadata API via JavaScript instead of APEX.

This is the case for projects, where the heavy lifting part of the logic is already JavaScript and an additional round-trip to APEX is making things more complicated. Especially with asynchronous functions and repetitive queries for completion the ping-pong between JS and APEX is hard-to-read and hard-to-maintain.

The only official JS wrapper I'm aware of is http://www.salesforce.com/us/developer/docs/ajax/

However it's possible to create a SOAP string and use XMLHttpRequest or $.ajax() to make the callout. Works fine.

To create the SOAP string I'm following the suggestions here and use SoapUI - which is free and really a smart tool.

My first question: is there a tool similar to Wsdl2Apex which converts entire WSDL to Javascript and works with the challenges of metadata.wsdl? (polymorphic, etc.)

Looking ahead, I would end up in rewriting many functions (or all). I'm now just wondering if I'm the first one who needs it or if there is already something existent? If there is nothing, I would also like to collaborate in a new project - just in case if others would be interested in such a JS wrapper, too.

The same need finally also applies to Tooling API.

Uwe Heim
  • 28,350
  • 18
  • 115
  • 283

1 Answers1

9

JSForce includes javascript access to the Metadata API. https://jsforce.github.io

JimRae
  • 5,036
  • 1
  • 26
  • 39
  • This looks very cool and I'll give it a try! Thanks Jim! – Uwe Heim Mar 03 '15 at 18:55
  • It also covers Tooling API and other APIs. – Uwe Heim Mar 04 '15 at 00:45
  • Yes, it does. I have also implemented a Visualforce / Bulk API interface with it as well. The Developers are very responsive to questions and issues as well. – JimRae Mar 04 '15 at 13:54
  • Quick test - great result! If we could use it for Lightning it too, it would be perfect - but before that Salesforce needs to open up the API http://salesforce.stackexchange.com/questions/68124/lightning-is-direct-api-access-on-the-roadmap – Uwe Heim Mar 04 '15 at 14:13
  • I would post that as an enhancement on the jsforce project. – JimRae Mar 04 '15 at 16:24
  • I'm afraid the work needs to be done rather on the Salesforce side than on jsforce. It's really a matter of Lightning design and security considerations at this time. See Doug's answer on the link above. – Uwe Heim Mar 04 '15 at 16:33