• Rental Mobil Lampung
  • NEWBIE
  • 0 Points
  • Member since 2022

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 4
    Replies
Hi. Sys Admin for our SF instance, but don't have much knowledge around coding.

Trying to update a quote status to "Activated" and I keep getting the following error below. Seems like it its based on a validation rule I have set up under the Opp, but I'm not sure how to go about fixing this.

Review the following errors
SBQQ.ContractAfter: execution of AfterUpdate caused by: System.DmlException: Insert failed. First exception on row 0; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, Please enter either an Contract Type OR Opportunity Type: [] Class.SBQQ.ContractService.generateRenewalQuote: line 2791, column 1 Class.SBQQ.ContractService.renewContracts: line 2282, column 1 Class.SBQQ.ContractService.forecastContracts: line 2188, column 1 Class.SBQQ.ContractService.processContracts: line 3263, column 1 Class.SBQQ.ContractService.processTriggerAfter: line 3186, column 1 Trigger.SBQQ.ContractAfter: line 6, column 1
 
m trying to callout thru schedulable and batch class...m stuck in  Too many callouts: 101 ...plz help
public class SchedulerForPostApex implements Schedulable{
    public void execute(SchedulableContext sc){
        system.debug('*******Going to call future method ');
        Postbatchclass  batchapex = new Postbatchclass();
        id batchprocessid = Database.executebatch(batchapex,1);
system.debug('Process ID: ' + batchprocessid);
  
        
    }
}

----------------------------------------------------------------------

global class Postbatchclass implements Database.Batchable<sObject>,Database.AllowsCallouts {

Public String query;
    
    global Database.QueryLocator start(Database.BatchableContext BC)
    {
        query = 'select id, Name, SOCi_Id__c FROM Account where SOCi_Id__c != null'; //need to define query
        return Database.getQueryLocator(query);

  
    }
     global void execute(Database.BatchableContext BC, List<Account> scope) {
     
         FOR(Account sr : scope){
           PostsRequest.getpostsCalloutResponseContents(sr);
       }
         
      }
      global void finish(Database.BatchableContext BC){
      }
}

-------------------------------------------------------------------------------------------------------------------------

public class PostsRequest { 
    
    private static final String API_KEY = 'apikeyy';     
    
    //@future(callout=true)
    public static void getpostsCalloutResponseContents(Account ac) {  
    Http h;
    HttpRequest req;
    HttpResponse res;

    //String finalResult = '';
    Map<String, List<PostClass>> WrapperPostMap = new Map<String, List<PostClass>>();
    List<Account> alist = [select id, Name, SOCi_Id__c FROM Account where SOCi_Id__c != null];  
    List<PostClass> WrapperPostList = new List<PostClass>(); 
    for (Account a : alist) {
        String result = null;                        
        h=new Http();
        req=new HttpRequest();
        req.setEndpoint('endpoint' + a.SOCi_Id__c + '/get?since=2011-01-01&api_key=' + API_KEY);
        req.setMethod('GET');
        res = h.send(req);
        if(res.getStatusCode() == 200){
            result = res.getBody();
          }        
      
            
        List<Object> resultList = (List<Object>) JSON.deserializeUntyped(res.getBody());              
      
        if(resultList != null){
          for (Object entry : resultList) {
                 WrapperPostList.add((PostClass)(JSON.deserialize(JSON.serialize(entry),PostClass.class)));
            }
          }
                WrapperPostMap.put(a.id, WrapperPostList);
          
                System.debug('The WrapperPostListid List value size is: ' + WrapperPostList.size()); 
      h=null;
        req=null;
        res=null;    
    
      } 
        
         System.debug('The WrapperPostListid List value is: ' + WrapperPostList);
         System.debug('The WrapperPostListid List value size is: ' + WrapperPostList.size());
        
        for (Account a : alist) {                
              makeCallout(WrapperPostMap.get(a.Id), a.id);
          }
        
    }    
  
    public static void makeCallout(List<PostClass> WrapperPostList, String aid) {
        String result = null;       
                  
       
      
             System.debug('The WrapperPostList list is: ' + WrapperPostList); 
        Set<String> postIds = new Set<String>();
        for (PostClass f : WrapperPostList) {
            postIds.add(f.id);
        }

        Map<String, Post__c> posts = new Map<String, Post__c>();
        Map<String, Post__c> newposts = new Map<String, Post__c>();
        for (Post__c p : [
                select Id, Name, SOCi_Post_Id__c
                from Post__c
                where SOCi_Post_Id__c in :postIds
                ]) {
            posts.put(p.SOCi_Post_Id__c, p);
        }


        for (PostClass f : WrapperPostList) {
            Post__c p;
            if (posts.containsKey(f.id)) {
             
            } else {
                
                p = new Post__c(SOCi_Post_Id__c = f.id, Account__c = aid);
                p.Name = f.network +' '+ 'Post';
                p.Date_Scheduled__c = Date.valueOf(f.created_at);
                p.Created_By__c = f.created_by_name;
                p.Post_Date__c = Date.valueOf(f.schedule);
              //  p.Channel__c=f.remote_network_id;
              //  p.Channel__c = [SELECT id from Channel__c where Account__r.SOCi_Id__c =: f.project_id and Type_of_Channel__c =: f.network LIMIT 1].id;
        newposts.put(f.id, p);
            }
            
          
        }

     insert newposts.values();
                     
  }
  
   
    class PostClass {
        public String id;
        public String project_id;
        public String network;
        public String created_by_name;
        public String schedule;
        public String created_at;
       // public String remote_network_id;
        
    }


 
}
  • September 28, 2017
  • Like
  • 0
I have a professional edition org and i want to set sharing rules on Opportunity Object  which is not available. Hence i am looking to go for Apex Managed Sharing. Would it work . If yes please help me with the solution.

Its urgent