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
Michael CarrierMichael Carrier 

Custom Button Java Script Help

We created a button to update pricing on our opportunity, and it works, however if there is existing pricing the button will throw an unexpected number error. Is there somthing I can add to the beginning of the code to clear out the fields before it updates? Any help would be greatly appreciated. Here is the code below:

{!REQUIRESCRIPT("/soap/ajax/35.0/connection.js")}
var opptyObj = "{!Opportunity.Market_and_Package__c}";
if(opptyObj === "Basic-B"){
  var oppToUpdate = new sforce.SObject("Opportunity");
oppToUpdate.id = "{!Opportunity.Id}";
 oppToUpdate.pricefield1__c = 29.99;
sforce.connection.update([oppToUpdate]);
    window.location.reload();
} else
{
 alert("Pricing Not available for Opp");
}