FatalFlaw
FatalFlaw

Reputation: 1163

Salesforce javascript remoting: is it possible from javascript (ie, not visualforce)?

I have a javascript app running in a home page sidebar component. I need to access an apex controller, and javascript remoting would be a good fit, except I can't use VF as I am in a home page component. Is it possible to use javascript remoting from actual raw javascript?

Note - I can't put a VF page in an iframe in the homepage component as I need to access items in the main page.

Upvotes: 1

Views: 2001

Answers (2)

Karan Nangru
Karan Nangru

Reputation: 11

You cant access the salesforce context in the HTML or Image type homepage component in any way such as the Ajax-toolkit, REST API suggested above. To use Ajax toolkit you would require a salesforce session id that you cannot get in an html home page component.

The ONLY solution is to use LINK type homepage component. This component allows you to call a method on click. You can access the salesforce context variables in this method, thus get hold of the salesforce sessiod id by calling {!$Api.Session_ID}.

Set this session id in the client session and fetch it in the html Homepage Component and thereon use this id for the ajax toolkit call.

Upvotes: 1

eprasu
eprasu

Reputation: 41

It is not possible to use JAVAScript Remoting without Visualforce page and annotated controller. Instead you can try Web-services, Ajax-toolkit, REST API

Upvotes: 1

Related Questions