You need to sign in to do that
Don't have an account?
Srinivas223
onclick javascript button not working
Hello All,
I have a requirement where i have to show an alret message when there is no opportunity line item to the opportunity and if account billing country belongs to few restricted countries. I have my restricted countries in a custom setting. Here is the sample code.
the code is working fine when I am checking for opportunity line items but I could not compare the account billing country to the list of countries in the custom setting.
I appreciate your help.
I have a requirement where i have to show an alret message when there is no opportunity line item to the opportunity and if account billing country belongs to few restricted countries. I have my restricted countries in a custom setting. Here is the sample code.
the code is working fine when I am checking for opportunity line items but I could not compare the account billing country to the list of countries in the custom setting.
I appreciate your help.
{!REQUIRESCRIPT("/soap/ajax/32.0/connection.js")} {!REQUIRESCRIPT("/soap/ajax/32.0/apex.js")} var x='{!Opportunity.Mission_Types__c}'; if (x == '') alert('Enter at least one Mission Type'); var myQuery = "select Id, name,product2id from opportunityLineItem where OpportunityId= '{!Opportunity.Id}' limit 1"; result = sforce.connection.query(myQuery); var records = result.getArray("records"); if(records =='') alert('There should be at least one product ' ); // this is working fine var oppQuery = "select AccountId from opportunity where Id= '{!Opportunity.Id}' limit 1"; oppResult = sforce.connection.query(oppQuery); var opp = oppResult.getArray("opp"); var accId = opp[0].AccountId; // here is the problem. it says cannot read the property // accountid var account = "select billingCountry from account where Id=: accId limit 1"; accResult = sforce.connection.query(account); var acc = accResult.getArray("acc"); var billingCountry = acc[0].billingCountry; var customSetting ="select id, name,CountryAbbreviation__c from SMProposalRestrictedCountries__c"; data = sforce.connection.query(customSetting); var customSettingData = data.getArray("data"); var restrictedCountry; for(var i=0;i<customSettingData.length;i++){ IF(customSettingData[i].name == billingCountry ) restrictedCountry = true; } if(restrictedCountry == true) alert('Restricted Billing country on Account'); if (x != '' && records != '') { window.location.href='/apex/OpptySendEmailToSpecialMissions?id={!Opportunity.Id}'; }
Abdul Khatri
Please try this
Abdul Khatri
Abdul Khatri
That helped?
Abdul Khatri
Hello
Abdul Khatri
Man was my last solution helpful?
Abdul Khatri
Are you really following up on this solution?
Abdul Khatri
Hello