function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Karthik@TMCKarthik@TMC 

VisualForce Remoting

Hi,

 

My Controller code is

 

@RemoteAction
    global static void getAttachment(List<String> IdList1){
        
         system.debug('IdList--'+IdList1);
         //IdList.addAll(IdList1);        
        
        List<Attachment> atList = [Select Id,Name,ParentId from Attachment where Id IN: IDList1];
        //attList.addAll(atList);
        
    }

 

how do i invoke this method from js.

 

Thanks in advance

Best Answer chosen by Admin (Salesforce Developers) 
MagulanDuraipandianMagulanDuraipandian

Use <apex:param> between <apex:actionFunction> tags.

 

Regards,

Magulan D

Salesforce.com certified Force.com Developer.

 

SFDC Blog

 

If this post is your solution, kindly mark this as the solution.

All Answers

MagulanDuraipandianMagulanDuraipandian

http://infallibletechie.blogspot.in/2012/10/calling-controller-method-using.html

 

Check the above link.

 

Regards,

Magulan D

Salesforce.com certified Force.com Developer.

 

SFDC Blog

 

If this post is your solution, kindly mark this as the solution.

Karthik@TMCKarthik@TMC

Hi Magulan,

 

I need to pass values from JS Method to Controller , so how would i accomplish this through action function..

 

 

Thanks for the quick Reply

MagulanDuraipandianMagulanDuraipandian

http://infallibletechie.blogspot.in/2012/10/calling-controller-method-using.html

 

Check this link

 

Regards,

Magulan D

Salesforce.com certified Force.com Developer.

 

SFDC Blog

 

If this post is your solution, kindly mark this as the solution.

MagulanDuraipandianMagulanDuraipandian

Use <apex:param> between <apex:actionFunction> tags.

 

Regards,

Magulan D

Salesforce.com certified Force.com Developer.

 

SFDC Blog

 

If this post is your solution, kindly mark this as the solution.

This was selected as the best answer
Karthik@TMCKarthik@TMC

The variables are local to JS Method. so, i cant use Param as it uses controller variables.

 

Any suggestions how to resolve?

MMNMMN

Hi,

 

I had the same problem than you. Here is the way I did to pass value from JS to controller using apex:actionFunction, apex:param and JS.

 

Apex controller, then VF page

 

public class myController(){

public myController(){
}

public void myFunc(){
    String myParamFromJS =Apexpages.currentPage().getParameters().get('myParam'); 
}
}

<apex:page standardController="myController">

	<apex:actionFunction name="go" action="{!myFunc}" immediate="true">
	   <apex:param name="myParam" value="" />
	</apex:actionFunction>


        <script type="text/javascript">
	    function update(){	
	        /*
                         YOUR CODE 
                */
			go(theparamyouwanttopass);
		}
	</script>
</apex:page>

 

 

 

 

cwall_sfdccwall_sfdc

Did you read the Visualforce Remoting documentation?

 

var ids = [];

MyController.getAttachment(ids, function(e,r) { ... });

 

http://www.salesforce.com/us/developer/docs/pages/Content/pages_js_remoting_example.htm