You need to sign in to do that
Don't have an account?
Passing selected option as parameter into Apex from Visual Force Page
Hi,
I'm new to this, sorry if this has already been covered but I'm getting very dismayed by this not working.
What I need to do is have an action associated with a selection from my selectList on my VF page that will go off and use the selectedOption as an Id in a query.
For example the selectList has a list of accounts (Sites) and I want the user to select an account, fire the action that will then display that account on screen to the user.
I just keep getting the "System.DmlException: Update failed. First exception on row 0; first error: MISSING_ARGUMENT, Id not specified in an update call: [] "
error message.
Here is the code from the VF page
<apex:selectList id="sites" size="1" title="Manager"> <apex:selectOptions value="{!ClientSites}"></apex:selectOptions> <apex:actionSupport event="onchange" action="{!saveCalendars}"> <apex:param name="site" value="{!theSite}" assignTo="{!theSite}" /> </apex:actionSupport> </apex:selectList>
And here is the code I'm trying to get to work...
public Id theSite {get; set;} public PageReference saveCalendars() { theSite = ApexPages.currentPage().getParameters().get('site'); Client_Site__c siteToUpdate = new Client_Site__c(Id = theSite); System.debug('This is the ID : ' + theSite); update siteToUpdate; return null; }
I really hope someone can help me with tis. Just cannot see why it won't work? The onlty thing I can think of is a timing thing with rendering etc.
Does anyone have suggestions on how I can fix this please?
Thanks in advance,
Ian
Hi,
try this approach
http://salesforceworld.blogspot.com/2011/06/parameter-passing-using.html
If a reply to a post answers your question or resolves your problem, please mark it as the solution to the post so that others may benefit.
chamil's blog
I still can't get it to work. What am I missing here?
Here is my script and the VF markup for the SelectList which gets record Ids from the database.
If I stick a simple alert in the JavaScript, it alerts the record number or Id which is what I want.
However, as soon as I make the JavaScript call myFunc then I cannot get any paramter back to the controller...
Here's the controller... the method I'm calling anyway. Also I have a get, set like so:
Can't believe I'm stuck on such a simple thing... :-(
I think at this time you solved that... But maybe someone has the same issue.
You just need to add a reference in the list..