1

On the Order object, how would one perform the Deactivate action in a Visualforce page?

Is there a way to discover how Salesforce is performing the action when the button is pressed on the standard page layout? The only way I could figure out the process is by inspecting the element with my browser which revealed:

navigateToUrl('/ord/orderactivation.jsp?actn=deact&retURL=%2F80154000000ClXW&id=80154000000ClXW&_CONFIRMATIONTOKEN=aconfirmationtokenhere'

If this is the only way, how can I get the token in my PageReference constructor on my extension?

1 Answer 1

1

Looks like it wasn't as complicated as I had originally thought. The extension written below should replicate all of the functionality on the Order that is missing from the standardController, including Reduce Order, Activate, Deactivate.

public class orderControllerExtension {
private final Order ord;

public orderControllerExtension(ApexPages.StandardController stdController){
    this.ord = (Order)stdController.getRecord();
}

public PageReference reduceOrder(){
    Id recordId = ord.Id;
    PageReference pageref = new PageReference('/801/e?retURL=%2F'+recordId+'&ordid='+recordId+'&rdct=1');
    pageref.setRedirect(false);
    return pageref;
}
public PageReference deactivate(){
    ord.Status = 'Draft';
    update ord;
    return null;
}
public PageReference activate(){
    ord.Status = 'Activated';
    update ord;
    return null;
}

}

1
  • The reduceOrder() function will not work within Console. If anyone has any ideas on this, feel free to add.
    – jdogg
    Commented Mar 9, 2016 at 22:03

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .