• beachbum50
  • NEWBIE
  • 25 Points
  • Member since 2009

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 3
    Replies

I have a controller extension that needs to have it's own 'customised' !save command. I call it !save2

 

Question 1: how can I force a record to be saved in apex code? Can I call the standard controller's

!save from within my extension's !save2 ?

 

Question 2: how can I edit - in code - the object that is to be saved? I need to set one of the record fields

to a specific value before saving.

 

Question 3: once saved - how do I return to the original record window? How can I redirect to a record

from within apex code?

 

Any pointers to code examples would really behelpful.

TIA.

hi,

 

I have created a simple command button on a VF page which goes to an apex class method.

It simply looks like this: <apex:commandButton action="{!opcancel}" value="Cancel Opp/Order" />

The !opcancel functionality is handled in an apex class as follows:

public class OppOperations {
    public OppOperations(ApexPages.StandardController controller) {

    }

    public PageReference opcancel() {
      
      opportunity[] updates = new opportunity[1];
      opportunity update_opportunity = new opportunity();
      
      update_opportunity.Id= '006R0000004aSPW'; //PROBLEM 1: why wont this line compile ?
            update_opportunity.Opp_Order_Status__c = 'Cancelled Order';
      
      updates[0] = update_opportunity;
      
      binding.update(updates); // PROBLEM 2: why wont this line compile
      
      PROBLEM 3: here I want to close the VF window that called this class as the update
                 is now complete
      return null;
    }

}

Basically - I have 3 problems in the above code snippet. I want to update my opportunity status to be

'Cancelled'. I would like to use SOQL to do this based on the unique record id. Question how can I do this?

Why is my syntax wrong? I can't find code examples of this type. Also - how can I close the VF window that

called this function? I want the original window to refresh showing the updated status. Basically - I need to

use SOQL to perform customised updates on individual object records. Any help would be much appreciated.

TIA.

i have created a visualforce page. when some clicks a customised button - i want to set

an object's value eg pseudo code would look like:

 

OnClick event (in visualforce page):

  my_object_record.my_field_value = "new status";

 

Can anyone point to me to a code example that shows me how to do this.

I dont want to use standard 'save' button as i don't always want to do this action on

a general save event.

tia.

I have a controller extension that needs to have it's own 'customised' !save command. I call it !save2

 

Question 1: how can I force a record to be saved in apex code? Can I call the standard controller's

!save from within my extension's !save2 ?

 

Question 2: how can I edit - in code - the object that is to be saved? I need to set one of the record fields

to a specific value before saving.

 

Question 3: once saved - how do I return to the original record window? How can I redirect to a record

from within apex code?

 

Any pointers to code examples would really behelpful.

TIA.

i have created a visualforce page. when some clicks a customised button - i want to set

an object's value eg pseudo code would look like:

 

OnClick event (in visualforce page):

  my_object_record.my_field_value = "new status";

 

Can anyone point to me to a code example that shows me how to do this.

I dont want to use standard 'save' button as i don't always want to do this action on

a general save event.

tia.