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

How to use datastructure in following method?

I have written following javascript function for some processing.


In js method have more than 15 parameters to pass to Controller using Saveaccount actionFunction.

<apex:actionFunction name="Saveaccount" action="{!createSavedSearch}" ">

<apex:param assignTo="{!text1}" value=""/>







<apex:param assignTo="{!text15}" value=""/>



function save(){


$('.text5').html().replace('x',''),$('.text6').html().replace('x',''), $('.text7').html(),$('.text8').html(),$('.text9').html().replace('%',''),





How to use  data structure - a map (hash), a JS object, or a custom class in above save method?

How  to improve this action function and it's associated JS and Apex code, calling it with one parameter?

Best Answer chosen by Admin (Salesforce Developers) 



Try grouping the parameters of the method in an apex class:

public void saveAccount(Wrapper w) {...}

public class Wrapper {
    public String text1;
    public String text2;
    public String text3;

 And in JavaScript populate a dictionary with the wrapper fields:

var param = {
    text1: $('.text1').html().replace('%',''),
    text2: $('.text2').html().replace('%',''),

Apex Editor LS - free alternative to apex editor.
Give kudos (click blue star under my icon) if this was useful