Full .js button code:
{!REQUIRESCRIPT("/soap/ajax/29.0/connection.js")}
{!REQUIRESCRIPT('/resource/' & LEFT(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(TEXT(NOW()),':',''),'-',''),' ',''),10) & '000/JS')}
sforce.connection.sessionId = "{!$Api.Session_ID}";
var accId = "{!Opportunity.Account}";
runURL(accId);
Static resource:
function runURL(accId){
function errorMsg(accId) {
var accInfo = sforce.connection.query("SELECT Id, Company_Legal_Name__c FROM Account WHERE Id = '" + accId + "' AND Company_Legal_Name__c != ''");
console.log("##### Acc ID " + accId);
console.log("##### Acc Query " + accInfo);
if (accInfo.size != 1) {
return "\u2022 Please enter a Company Legal Name";
} else return "";
}
}
When I run the above code I can't seem to pass the Account Id to a function in a static resource... however the console.log() actually outputs the correct Account Id, although I get the below error:
The query is not actually picking up the Account Id, also this function in inside of another function.