• Florian Marx05282918216679144
  • NEWBIE
  • 0 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 1
    Replies
Hi,

in a Site.com Page I added a Button with a simple onClick JavaScript to validate connection options to SF. Simplified code example for connection test:

{!requireScript("/soap/ajax/29.0/connection.js")}
var result = sforce.connection.login("<USR>", "<PWD>");
alert("Logged in with session id " + result.sessionId);

No success or error, testing with a simple Alert works fine.
Can you provide tips / hints?
Hi,

in a Site.com Page I added a Button with a simple onClick JavaScript to validate connection options to SF. Simplified code example for connection test:

{!requireScript("/soap/ajax/29.0/connection.js")}
var result = sforce.connection.login("<USR>", "<PWD>");
alert("Logged in with session id " + result.sessionId);

No success or error, testing with a simple Alert works fine.
Can you provide tips / hints?

Hi,

 

I am attempting to use the new $RemoteAction variable and Visualforce.remoting.Manager.invokeAction() function in the summer 12 release.

 

I have successfully used them to call a remote action function when that function takes a single argument as its input, e.g.


Visualforce.remoting.Manager.invokeAction('{!$RemoteAction.RemoteController.test1Str}','1 argument', handleReturn,{escape: true});

 

I have methods currently working in salesforce which accept 0 and 2 or more arguments. The obvious way of calling these to me would be to simply include the arguments separated by commas as that is what is done with the current calls, e.g.

RemoteController.test0Str( handleReturn,{escape: true})

 would map to

Visualforce.remoting.Manager.invokeAction('{!$RemoteAction.RemoteController.test0Str}', handleReturn,{escape: true});

 and likewise for 2 arguments:

RemoteController.test2Str('2','arguments',  handleReturn,{escape: true})
Visualforce.remoting.Manager.invokeAction('RemoteController.test2Str','2','arguments', handleReturn,{escape: true})

 But for these two cases I get the following logged to the JS console:

Visualforce Remoting: Parameter length does not match remote action parameters: expected 0 parameters, got
Visualforce Remoting: Parameter length does not match remote action parameters: expected 2 parameters, got  

 So it is clear that salesforce know what it is expecting, but it is not clear how I pass the arguments.

 

I have also attempted passing the arguments as an array ,e.g.

[]
['1 argument']
['2','arguments']

 and (in desparation) as a single object with the argument names as the parameter names! None of this works.

 

Has anyone had any success using remoting in this fashion? There is a gist of my code at https://gist.github.com/2713502.

 

Regards,

 

James