+ Start a Discussion
mjohnson-TICmjohnson-TIC 

Apex:CommandButton Action Not Initiating

Begining last week (or at least when I was notified), none of the actions associated with apex commandbuttons are initiating when clicked for all Visualforce pages associated with 1 specific Apex class I created. Clicking apex:commandbuttons with actions associated with this particular class do not even register an event log when trying to debug. I have not touched these Visualforce pages or Apex class in several months, and there have been no issues until last week. My temporary work around is creating an apex:actionsupport with the appriate onclick action for each button, but this is not ideal. Any ideas what might be causing this?

Best Answer chosen by Admin (Salesforce Developers) 
mjohnson-TICmjohnson-TIC

Thanks for the tip, monitoring the Javascript event log I found the following.

 

XMLHttpRequest for https://ticgums--c.na3.visual.force.com/apex/ProductChangeNotification required Cross Origin Resource Sharing (CORS).

 

Origin https://c.na3.visual.force.com not found in Access-Control-Allow-Origin header.

 

XMLHttpRequest: Network Error 0x80070005, Access is denied.

 

 

Upon some investigation I found the following. Within the past month I enabled a custom domain name for our org to configure single sign-on between multiple orgs. For all Visualforce pages accessed internally, this appended the custom domain as a prefix to the Visualforce server ( in our case instead of c.na3.visual.force.com, ticgums--.c.na3.visual.force.com is used). Visualforce pages accessed using direct links in email, never got redirected to the tic-gums-- prefix, so the request and origin were coming from 2 separate locations. I think technically this could be considered a bug (all non-Visualforce links to na3 get redirected to our custom domain) but at least I can take the appropriate action to point Visualforce links directly to our custom domain.

All Answers

Satyendra RawatSatyendra Rawat

hi upload your code, helpful for finding bug.

mjohnson-TICmjohnson-TIC

From complex to simple, none of the actions initiate on submit of an apex:commandbutton for my class. Here is a simple example of one.

 

 

Action from the controller.

 

	public void approve(){
		try{
			Product_Notification_Batch__c ba = new Product_Notification_Batch__c(id=pnbid);
			ba.Approved_Date__c = datetime.now();
			update ba;
		}catch(exception e){
			
		}
	}

 

commandbutton on page referencing controller

 

<apex:commandbutton value="Approve Change" action="{!Approve}" rerender="approval"/>

 

Clicking the command button, not even a debug log will show up - the action method never even initiates. This is happening ONLY in our production environment (it works perfectly fine in sandbox) and has just started occuring within the past few weeks. This page worked perfectly for years in our production environment until 2-3 weeks ago, when the actions associated with the command buttons stopped working. No changes have been made to the Apex class or Visualforce page for 4-5 months.

SeAlVaSeAlVa

Couldn't it be that an Exception is being thrown and as there is no actions associated to the catch it is like a "silent error" ?

 

take a look to your debug-logs and look for "exception" keyword, for example

 

Regards

mjohnson-TICmjohnson-TIC

As I said, the action never initiates onclick of the apex:commandbutton - therefor no debug log is created. This is only happening in our production environment (na3), everything is working without issue in our sandboxes.

SeAlVaSeAlVa

Have you checked javascript logs? in case a javascript error is preventing it to execute the propper function.

mjohnson-TICmjohnson-TIC

Thanks for the tip, monitoring the Javascript event log I found the following.

 

XMLHttpRequest for https://ticgums--c.na3.visual.force.com/apex/ProductChangeNotification required Cross Origin Resource Sharing (CORS).

 

Origin https://c.na3.visual.force.com not found in Access-Control-Allow-Origin header.

 

XMLHttpRequest: Network Error 0x80070005, Access is denied.

 

 

Upon some investigation I found the following. Within the past month I enabled a custom domain name for our org to configure single sign-on between multiple orgs. For all Visualforce pages accessed internally, this appended the custom domain as a prefix to the Visualforce server ( in our case instead of c.na3.visual.force.com, ticgums--.c.na3.visual.force.com is used). Visualforce pages accessed using direct links in email, never got redirected to the tic-gums-- prefix, so the request and origin were coming from 2 separate locations. I think technically this could be considered a bug (all non-Visualforce links to na3 get redirected to our custom domain) but at least I can take the appropriate action to point Visualforce links directly to our custom domain.

This was selected as the best answer