I created a custom button with the send email features, so if the margin<0.4) show alert, than can't send the email. I created the button but it doesn't work.
Somebody can help me?
{!REQUIRESCRIPT("/soap/ajax/22.0/connection.js")}
var criteria1 = "SELECT id FROM OpportunityLineItem WHERE margin__c < 0.4 limit 1";
records = sforce.connection.query(criteria1);
records1 = records.getArray("records");
if(records1.length > 0){
alert("Before send email need approva process");
} else {
location.replace('/email/author/emailauthor.jsp?retURL=/{!Opportunity.Id}&p3_lkid={!Opportunity.Id}&rtype=003&&p24=b@b.com&template_id=0000000000000&new_template=true ');
}
catch(e){
alert('An Error Occured' +e)
}
'Attr.nodeValue' is deprecated. Please use 'value' instead. And this error. Refused to set unsafe header "User-Agent" connection.js:598send connection.js:598sforce.SoapTransport.send connection.js:1017sforce.Connection._invoke connection.js:1630sforce.Connection.invoke connection.js:1569sforce.Connection.query connection.js:1257(anonymous function) VM8329:4element.invokeAction 00611000006uOxS:172window.invokeOnClickJS_00b11000000IERF 00611000006uOxS:175onclick
I can't understand how can i fix that.