• Violet
  • NEWBIE
  • 45 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 5
    Questions
  • 10
    Replies
Has anyone done an integration between ResortSuite and Salesforce? It seems that ResortSuite has Oracle DB, any suggestions?
  • December 21, 2016
  • Like
  • 0
I have a trigger on Account that updates all child Contact objects but I am hitting a DML error due to number of Contacts on the Account. I want to call a batch class from the trigger if the list of Contacts is larger than 10000 (DML limit). 

Is there a way to define the batch class in a way that it just takes the list of Contacts and updates them in batch? This is what I have for the batch and it is giving bunch of errors
 
global class SG_BatchContactUpdate implements Database.Batchable<sObject>{

  Map<Id, Contact> contactmap = new Map<Id, Contact>();
    global SG_BatchContactUpdate (Map<Id, Contact> contacts) {
        contactmap=contacts;
        
         }
global Database.QueryLocator start(Database.BatchableContext BC) {
return DataBase.getQueryLocator([SELECT Id FROM Contact WHERE Id IN : contactmap.keySet()]);
}
    
    //Execute Method.
    global void execute(Database.BatchableContext BC) {
        
    }
}

This is how I am calling from the trigger
Database.executeBatch(new SG_BatchContactUpdate(contactsToUpdate));

 
Trying to auto-populate Custom_Object on Asset from Opportunity before insert. Getting errors, any help would be appreciated
Asset has lookup to Opportunity
Asset has lookup to Custom_Object
Custom_Objet has lookup to Opportunity

User-added imageUser-added image
trigger AutoPopulate on Asset (before insert) {
    
    Map <Id, Opportunity> mapidopp= new map<id,Opportunity> ([select Id,(select Id,Name from Custom_Object__r 
                                    where Is_Primary__c=true ),(select Id,Name from Assets__r 
                                        where Id IN: Trigger.new)from Opportunity where 
                                    (Id IN (SELECT Opportunity_Name__c from Custom_Object__c))]);
    List <Asset> listasst=new List <Asset> ();
    for(Id i: mapidopp.keyset()){

    for (Custom_Object__c obj:mapidopp.get(i).Custom_Object__r){
          for (Asset asst:mapidopp.get(i).Assets__r ){
                System.debug('test7' + obj.Id);
              //getting error here that Custom_Object_r.Id was not retrieved in SOQL
              //but when I add it to SOQL get Attempt to de-refernece a null point
           		asst.Custom_Object__r.Id=obj.Id;
                listasst.add(asst);
           		System.debug('test4' + asst.Custom_Object__r.Id); 
           		
        }  
        }
        
    }

insert listasst;
}

 
  • September 06, 2015
  • Like
  • 0
A (custom object) has a custom lookup relatiomship to Opportunity(Opportunity_Name__c). Trying to write SOQL query to get the list of custom objects but none of the below  statements are working:

select Id,(select Id from A__c) from Opportunities

 select Id, (select Id from Opportunity_Name__c) from A__c

 
  • September 04, 2015
  • Like
  • 0
Trying to create a Trigger handler for a Trigger on Account to find List of Accounts that have opportunities with stage 'Closed Won', but not sure if I have the SOQL query set up right. Any help would be appreciated. Getting error ' unexpected token: 'SELECT''
public class NoAccDelwithClosedWonOpenOpps {
    public static Boolean checkAcc_OppClosedWon_Open(List<Account> listaccts){
        Boolean cantdelete;
        List<Account> listofaccts=[SELECT Id (SELECT Id FROM Opportunity WHERE StageName='Closed Won') FROM Account=:listaccts];      
        return cantdelete;
        }
    
  • August 28, 2015
  • Like
  • 0
Bug in Lightning Specialist Superbadge step 6? - Automate fulfillment cancellation actions.   
 
The task is when fulfillment is Cancelled, the related OpportunityLineItem unitprice (i.e., salesprice) should be same as the Fulfillment's Deposit. Simple. I manually checked this and is working fine, but when the app checks, it fails with the error : System.AssertException: Assertion Failed: Same value.  
 
ISSUE: Now, if I see the debug logs (captured when Salesforce trailhead checks this).  In below snippet (from debug logs) see the last 2 lines.  There is assertEquals which checks deposit and unitprice - Match.  But assertNotEqual is also checking deposit and unitPrice.  It fails here.  Both the values will be same, the assertNotEqual is failing because both the values are same!
 
Execute Anonymous: // make sure the deposit matches the unit price
Execute Anonymous: System.assertEquals(f1.deposit__c, oli1.unitprice); // one way in the future
Execute Anonymous: System.assertNotEquals(f2.deposit__c, oli2.unitprice); // one way in the past

How to fix this? Is this a bug?
I have a trigger on Account that updates all child Contact objects but I am hitting a DML error due to number of Contacts on the Account. I want to call a batch class from the trigger if the list of Contacts is larger than 10000 (DML limit). 

Is there a way to define the batch class in a way that it just takes the list of Contacts and updates them in batch? This is what I have for the batch and it is giving bunch of errors
 
global class SG_BatchContactUpdate implements Database.Batchable<sObject>{

  Map<Id, Contact> contactmap = new Map<Id, Contact>();
    global SG_BatchContactUpdate (Map<Id, Contact> contacts) {
        contactmap=contacts;
        
         }
global Database.QueryLocator start(Database.BatchableContext BC) {
return DataBase.getQueryLocator([SELECT Id FROM Contact WHERE Id IN : contactmap.keySet()]);
}
    
    //Execute Method.
    global void execute(Database.BatchableContext BC) {
        
    }
}

This is how I am calling from the trigger
Database.executeBatch(new SG_BatchContactUpdate(contactsToUpdate));

 
Trying to auto-populate Custom_Object on Asset from Opportunity before insert. Getting errors, any help would be appreciated
Asset has lookup to Opportunity
Asset has lookup to Custom_Object
Custom_Objet has lookup to Opportunity

User-added imageUser-added image
trigger AutoPopulate on Asset (before insert) {
    
    Map <Id, Opportunity> mapidopp= new map<id,Opportunity> ([select Id,(select Id,Name from Custom_Object__r 
                                    where Is_Primary__c=true ),(select Id,Name from Assets__r 
                                        where Id IN: Trigger.new)from Opportunity where 
                                    (Id IN (SELECT Opportunity_Name__c from Custom_Object__c))]);
    List <Asset> listasst=new List <Asset> ();
    for(Id i: mapidopp.keyset()){

    for (Custom_Object__c obj:mapidopp.get(i).Custom_Object__r){
          for (Asset asst:mapidopp.get(i).Assets__r ){
                System.debug('test7' + obj.Id);
              //getting error here that Custom_Object_r.Id was not retrieved in SOQL
              //but when I add it to SOQL get Attempt to de-refernece a null point
           		asst.Custom_Object__r.Id=obj.Id;
                listasst.add(asst);
           		System.debug('test4' + asst.Custom_Object__r.Id); 
           		
        }  
        }
        
    }

insert listasst;
}

 
  • September 06, 2015
  • Like
  • 0
A (custom object) has a custom lookup relatiomship to Opportunity(Opportunity_Name__c). Trying to write SOQL query to get the list of custom objects but none of the below  statements are working:

select Id,(select Id from A__c) from Opportunities

 select Id, (select Id from Opportunity_Name__c) from A__c

 
  • September 04, 2015
  • Like
  • 0
Trying to create a Trigger handler for a Trigger on Account to find List of Accounts that have opportunities with stage 'Closed Won', but not sure if I have the SOQL query set up right. Any help would be appreciated. Getting error ' unexpected token: 'SELECT''
public class NoAccDelwithClosedWonOpenOpps {
    public static Boolean checkAcc_OppClosedWon_Open(List<Account> listaccts){
        Boolean cantdelete;
        List<Account> listofaccts=[SELECT Id (SELECT Id FROM Opportunity WHERE StageName='Closed Won') FROM Account=:listaccts];      
        return cantdelete;
        }
    
  • August 28, 2015
  • Like
  • 0
Hi out there,
I an absolute Apex beginner and would like to solve a problem: Once an opportunity is closed won the products from that opportunity should automatically become assets for that customer. I know I need a trigger, a class and a test class. So in general my idea is as follows:

if opp stage = closed won
   and if opp has products
for each product (opp-line item) 
create asset
with account ID...
set asset name = product name

etc...

How can I solve this? Where could I find appropriate code samples? Any help is pretty welcome...
So thanks in advance...

best regards Thomas