You need to sign in to do that
Don't have an account?
Alaa
Which apex tag to update the value of some field in opportunity object
Hi, I created a visualforce page and mapped it to opportunity object ... in some scenario I want to update the value of one field in the opportunity object from this visualforce page so what apex tag should I use? Is there anyway to do so?
Yes, you can use <apex:inputfield> tag. Here is an example for updating an account.
Hope that helps.
Afzal
You can use apex:inputField tag to do so.
It will bing the value on the Visualforce page directly to the object.
Are you using Custom controller?
Thank you.. but how can I do this automatically without asking the user to click the save button ? what I need is to update some field value when user update or edit an opportunity so I want to update the fiedl value automatically without asking the user to fill a from and click save. .. is there anyway to do so?
If I understand correctly, here is an example:
When the user clicks the "Save" button, the controller will set the Opportunity Description automatically, and insert the record.
can I create a method "updateDescription()" in this controller and call it once the page loads to update the description field based on some logic without having any form ?
Yes. Here are some possible ways to do it:
- Specify an action in the <apex:page> tag. This will be called when the page is loaded.
- Create an actionFunction and call it using javascript when the page loads.
I'm not sure that performing DML when the page loads is a good idea, but it can be done.
I agree with you its not a good idea to do this on page load but i dont want to ask the user to trigger some action or rely on him to do this... I want to do this automatically.... whenever an opportunity is getting updated I want to check some logic and then update some field value in the opportunity object.... I can do it using appex triggers and put the event "on update" but then I dont know how to get the current record being updated and update the field value ... I appreciate it if you have any example on this ?
Getting the current record in a trigger is easy.
There is a context variable called trigger.new which is an array of all the records to be updated. This is a simple example which will set the description for accounts when they are updated:
Take a look at the section on "Invoking Apex | Triggers" in the documenation:
http://www.salesforce.com/us/developer/docs/apexcode/index.htm
Thnak you for your help.