function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Krrish GopalKrrish Gopal 

Custom java script button not working on Visualforce Page

I created a Visualforce page to override the standard case view page. I have a custom button "OnlineClosed" on case object that ask for a remark and update 2 field status and stage at case object. The button works fine on the standard case view page, but not at my visualforce page. Does anyone have any idea why this button does not working on the visualforce page? When I click on it, I get a error message "URL No Longer Exists".
About Custom Button 
Behavior: Execute JavaScript and Content Source: OnClick JavaScript.
var url = parent.location.href; 
var updateRecord = new Array(); 
var myquery = "SELECT Id FROM Case WHERE Id = '{!Case.Id}' limit 1"; 
var reason = prompt("Enter reason", ""); 
result = sforce.connection.query(myquery); 
records = result.getArray("records"); 
var update_Case = records[0]; 
update_Case.Status = "Closed"; 
update_Case.Stage__c= "Resolved"; 
update_Case.Remark__c= reason; 
result = sforce.connection.update(updateRecord); 
parent.location.href = url;

Code for Button on VisualForce page is below.
<apex:commandButton action="{!URLFOR($Action.Case.OnlineClosed,}" value="Online Closed"/>
Manjit Singh 15Manjit Singh 15
I think what you are trying to do is to reload the page after updating the some fields and it is an inline VF page.
Can you post the url it redirects you to. Also please try and handle any errors that you get while updating record.

Browser Console is your friend.
Krrish GopalKrrish Gopal
Hi Manjit,
 I create a visualforce page to override the standard case view page and here I'm trying to update 3 fields status(picklist), stage(picklist) and remark (input recevived from user) with the help of custom OnClick JavaScript buttun at case.