• grodi
  • NEWBIE
  • 0 Points
  • Member since 2015
  • Technical Architect
  • Salesforce

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 4
    Replies
Hi,
on product object we have currency__c picklist  (INR, USA, etc)and pricebooke also  have same currency__c(India, USA etc) picklist of same currencies. i created pircebooks  depends on picklist values. I am unable to map the related product to related pirce books records.
exm: if product is INR , it go and store to Indian pricebook( For this i am using ID mapping )
Here i am posting my code, Give me solutions for this, Thanks in advance


trigger Createdefaultpricebook on Product2 (after insert) {

 list<pricebookentry> z = new list<pricebookentry>();
    list<product2> produ = new list<product2>();
    
    sobject priceb = [select id, name from pricebook2 where isstandard = true];
    for(product2 p : trigger.new){
    pricebookentry pbe =new pricebookEntry();
    pbe.product2id= p.id;
    pbe.pricebook2id = priceb.id;
    pbe.unitprice = 0.00;
    pbe.isactive = true;
    pbe.UseStandardPrice=false;    
    z.add(pbe);
    }    
    
    insert z;
    
    //id mapping of currencies
    map<id, pricebook2> pbmap = new map<id, pricebook2>();
    list<pricebook2 > pbl = [select id, name from pricebook2 where CurrencyType__c !=null];
   for(pricebook2 pb : pbl){
    
    pbmap.put(pb.id, pb);
   }
   system.debug('***********'+ pbmap);
    
    id  indiaidpb = '01s28000007GbZ9AAK';
    id  usaidpb = '01s28000007Gby5AAC';
    id  euroidpb = '01s28000007GbyFAAS'; 
    id  yenumpb = '01s28000007GbyKAAS';
    id  englandidpb = '01s28000007GbyPAAS';
    
    
    list<pricebookentry> lispbe = new list<pricebookentry >();
    for(product2 p : trigger.new){  
   if(p.CurrencyType__c == 'INR'){
        pricebookentry custompric = new pricebookentry();   
        custompric.pricebook2id = '01s28000007GbZ9AAK';
        custompric.product2id = p.id;
        custompric.unitprice = 0.00;
        custompric.isactive = true;
        lispbe.add(custompric);
  
    }
    
    else if(p.CurrencyType__c == 'USD'){
    
        pricebookentry custompric = new pricebookentry();   
        custompric.pricebook2id = '01s28000007Gby5AAC';
        custompric.product2id = p.id;
        custompric.unitprice = 0.00;
        custompric.isactive = true;
        lispbe.add(custompric);
    
    }
    
         else if(p.CurrencyType__c == 'ERO'){
    
        pricebookentry custompric = new pricebookentry();   
        custompric.pricebook2id = '01s28000007GbyFAAS';
        custompric.product2id = p.id;
        custompric.unitprice = 0.00;
        custompric.isactive = true;
        lispbe.add(custompric);
    
    }
    
         else if(p.CurrencyType__c == 'YEN'){
    
        pricebookentry custompric = new pricebookentry();   
        custompric.pricebook2id = '01s28000007GbyKAAS';
        custompric.product2id = p.id;
        custompric.unitprice = 0.00;
        custompric.isactive = true;
        lispbe.add(custompric);
    
    }
    
         else if(p.CurrencyType__c == 'POUND'){
    
        pricebookentry custompric = new pricebookentry();   
        custompric.pricebook2id = '01s28000007GbyPAAS';
        custompric.product2id = p.id;
        custompric.unitprice = 0.00;
        custompric.isactive = true;
        lispbe.add(custompric);
    
    }
    
    }
    
    insert lispbe;
    

}

 
hi team
while i try to install the salesforce workbench, It displays the error
"An error has occured and you have been logged out:
API_DISABLED_FOR_ORG:API  is not enabled for this organisation or partner"

So can any one help in resolving this, what needs to be done in order to get acccess to workbench
 
Hi,

I want to fetch more than 50000 records and send it as response via rest api. I just want to show the data and no dml operations are performed. Can you suggest me a solution where I can overcome the soql limit exception?
  • March 22, 2016
  • Like
  • 0