0

I am writing logic on new Quote button Opportunity , where the new quote button should display error based on related list available or not. related list is an other object which has OppId associated to it, Webservice method:

global class OppConXXX{

    WebService static void OppConXXX(String oppId){
        try {
            Map<Id,List<Opportunity_Contract__c>> oppToConMap =  new Map<Id,List<Opportunity_Contract__c>>();
            System.debug('you are here !');
            for(Opportunity_Contract__c oppCon :[
            Select Id,Opportunity__c,Contract_Rate__c From Opportunity_Contract__c Where Opportunity__c =:oppId])
        {
            if(oppToConMap .containsKey(oppCon.Opportunity__c)){
                oppToConMap .get(oppCon.Opportunity__c).add(oppCon);
            } else {
                oppToConMap .put(oppCon.Opportunity__c,new List<Opportunity_Contract__c> {oppCon});
            }
        }
           Integer listSize = oppToConMap.size();
        }
       catch(exception e) { 
        throw e ;
    }   

    }

I want to pass listSize to onclick JavaScript where I need to show alert based on its count.

Custom Button code:

{!REQUIRESCRIPT("/soap/ajax/21.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/21.0/apex.js")}

if("{!Opportunity.Type}" == 'Upsell' || "{!Opportunity.Type}" == 'Downsell')
{
alert("abcd");
var result = sforce.apex.execute("OppConXXX","OppConXXX",..);
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.