+ Start a Discussion
Jim BoudreauxJim Boudreaux 

Is there a way to set the values of an SObject in a VF Controller via javascript?

Here's the scenario:

I have a pageblocktable with a list of custom objects. In the first column I have an edit link with the id of the item. Using jquery a dialog box is created when the user clicks the link. The dialog box has the fields of the custom object with the idea being the user can make changes and save via the dialog box. Right now I accomplish this by using Javascript remoting to call a method in the controller that returns the record the user selected when clicking the edit button. In my Javascript I must then explicitely set the values of all the input fields on the dialog box so when the box is rendered it has the current values of the record.

My question is, Is there a way to retrieve the record and set it to an sobject variable in the controller and expose that variable to the inputfields in the Dialog box? If I use the above example and set the value of the variable in the remote action function, the inputfields do not update. I think it's because the variable must be static for the remote action method to see it.

Any advice?


You can use a @remoteaction function or a normal form function. The specifics willl depend on your implementation, so I can't really be of much more help without further details...