You need to sign in to do that
Don't have an account?
b.gonzalez
Field Product.Quantity does not exist. Check spelling? - Custom JavaScript button
I am modifying a custom javascript button to include a validation that prevents the user from entering quanitities less than 50 for each product that is listed on the Opportunity record. Products are a related list on the Opportunity record.
However I am not sure how to reference the Quantity field in the button. See bolden section. Please help!
However I am not sure how to reference the Quantity field in the button. See bolden section. Please help!
{!REQUIRESCRIPT("/soap/ajax/19.0/connection.js")} {!REQUIRESCRIPT("/soap/ajax/19.0/apex.js")} var strStatus = '{!Opportunity.Opportunity_Status__c}'; switch(strStatus) { case 'Denied': alert('This opportunity cannot be approved because it has been denied.'); break; case 'Closed': case 'Awaiting Claim': case 'Claim Submitted': case 'Closed Expired': case 'Closed Won': case 'Closed Lost': alert('This opportunity cannot be updated.'); break; } var strAmount = '{!Opportunity.Amount}'; switch(strAmount){ case '$0.00': alert('This opportunity cannot be approved because no products are listed.'); break; } var strQuantity = '{!Product.Quantity}'; switch(strQuantity){ case 'Quantity < 50' alert('Quantity on products cannot be less than 50.'); break; default: sforce.apex.execute("CMR_DesignWebService", "ApproveToPMIDesign",{OpportunityId:'{!Opportunity.Id}'}); alert('Opportunity Approved in PMI system.'); window.location = window.location; break; }
2) Also expressions {! Opportunity.Amount} will be evaluated on server so it will not have values entered by the user in UI unless it has been updated in the server. you might have to use document.getElementById using $Component global variables.
http://www.salesforce.com/docs/developer/pages/Content/pages_variables_global_component.htm