• Cloud_force
  • NEWBIE
  • 183 Points
  • Member since 2014
  • CloudForce


  • Chatter
    Feed
  • 5
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 114
    Replies
Hi All,

Have created a field set, no problems there.

I now want to use this field set on the default Acount page layout.  

I go to the page layout hoping the field set will be visible as one of the objects I can drag onto the form but it is nowhere to be seen. 

Any ideas?  Am using Group Edition and this may be the problem but there is nothing in the doco to suggest this would be a problem.

Thanks
Ross
 
I am an APEX newbie trying super hard to teach myself to code but this challenge is proving pretty difficult for me. The situtation is that we have a hierarchial lookup relationship in Opportunities where child Opportunities can be linked to parents. I have found that it is possible to write a trigger to do a roll-up summary from a lookup to another object but I have not found anything that says it is possible in the context of hierarchial lookups. So my first questions is, is this possible?

If so, I found some sample code on this site (http://blog.jeffdouglas.com/2009/07/30/roll-up-summary-fields-with-lookup-relationships-part-1/) that demostrates how to do this between two separate objects but I am having a little trobule translating. This is pretty complex compared to the triggers I have been able to write before so my second question pertains to a section of the code I don't understand. What exactly is the bolded part of the code doing? I have read about for loops and if statements but this is more complex than anything I have ever seen. Any help is much appreciated :)

trigger InventoryItemRollup on Inventory_Item__c (after delete, after insert, after update) {

Set<id> shipmentIds = new Set<id>();
List<shipment__c> shipmentsToUpdate = new List<shipment__c>();

for (Inventory_Item__c item : Trigger.new)
shipmentIds.add(item.Shipment__c);

if (Trigger.isUpdate || Trigger.isDelete) {
for (Inventory_Item__c item : Trigger.old)
shipmentIds.add(item.Shipment__c);

}
// get a map of the shipments with the number of items
Map<id,Shipment__c> shipmentMap = new Map<id,Shipment__c>([select id, items__c from Shipment__c where id IN :shipmentIds]);

// query the shipments and the related inventory items and add the size of the inventory items to the shipment's items__c
for (Shipment__c ship : [select Id, Name, items__c,(select id from Inventory_Items__r) from Shipment__c where Id IN :shipmentIds]) {

shipmentMap.get(ship.Id).items__c = ship.Inventory_Items__r.size();
// add the value/shipment in the map to a list so we can update it
shipmentsToUpdate.add(shipmentMap.get(ship.Id)); }

update shipmentsToUpdate;
}
Hi,

I have a set of unique email address that are stored in a SET. Based on that SET of emails, I want to query all the LEads in the system with that email address. Here is an example of my code. 

Note: I have more than 50,000 leads in the system so I used query in a for loop
Set<String> email = new Set<String>();

//some logic is performed
//at the end of the logic, email has about 10,000 records

For(Lead curLead : [Select Id, Name, Email From Lead Where Email IN: email]){

//some logic performed

}//end for loop

Why would I be getting a 'Too Many query row' error if the query is in the for loop paramater list? What am I doing wrong to be hitting the 50,000 query row governor limit?

If 'email' is bigger than the total number of leads in the system, would that cause an issue? What alternative methods can I use?

Hi,

I currently have a schedulable class that is scheduled to run on a nightly basis. However, it will be using SOQL queries that can return more than 50,000 records. I was thinking of using the '@future' call, but was not sure if it works as my test results have been inconclusive. here is what I am trying to do and wanted to know if it will be able to process more than 50,000 if it comes to it

public class Test implements Schedulable(SchedulableContext sc){

@future
public function() {
//some operations which may return greater than 50,000 records
List<Contact> newCnt = [Select Id From Contact]
}

}//end class

I am trying to start with salesforce einsten Can anyone please help me with this. In few posts i could see that i need to have einsten license to start. is there any way to start without paying? Need to try few things that could get me started.
I've the below record id, that has prefix 0BE. but when i enter this id in samlesforce url getting below error.
could you pls tell which object this id is actually referring to.. thanks in adv.

ERROR:
Insufficient Privileges
You do not have the level of access necessary to perform the operation you requested. Please contact the owner of the record or your administrator if access is necessary. For more information, see Insufficient Privileges Errors. 
 
  • November 22, 2017
  • Like
  • 0
I am getting error on click of button on list view. 
Error: A problem with OnClick JavaScript for this button or link was encountered: {faultcode:'sf:INVALID_FIELD,faultstring:'INVALID_FIELD: SELECT Account__c,payload__c from tc__c 

Payload__c's Data Type=Rich Text Area(131072).

Why are we getting error on quering payload__c field in dynamic query?
Hello Everyone.

I hope you all doing well.

I would like to know if it is possible in SFDC to extract the logic of Approval Processes or Validation rules or workflow rules and save it in some documents?

Any suggestion or help would be appreciated.

Thank you,
Sujit
 
Hello,

I am working on quotes and I need to retrive information from a custom child object of Product we created.
On the quote record page, when we click on a button, a PDF is generated.
For each product associated to the quote, information are returned from Quote Line Item by a SOQL query.
I would like to retrieve the information I need on the Product child object (one record of this object is associated to only one product).

Here is the query we use :
qlis = [SELECT Id, PriceBookEntry.Product2.Name, Description, Notes__c, UnitPrice, Quantity, TotalPrice, Total_Weight__c, CurrencyIsoCode, Weight__c, PricebookEntry.Product2.ProductKey__c, PricebookEntry.Product2.Item_designation_marking__c FROM QuoteLineItem WHERE QuoteId = :quoteId];

User-added image
What is the best way to do this ? I would like to do this in only one query but I don't think it is possible.
Please share an example for this. In code how we need to write for Auto approval process in API calls
The requirement is, When the user tries to update the address field in detail page using inline editing. When he click SAVE button in account,at that time it should save the Account and it should show an pop up window (In that i want to display related contact Name,Address field and checkbox as well as update button).

Am new to Apex coading, can anyone help me how to override the save button to show a pop up window if the address field is updated.
Is it possible to run Apex code under a different user than the logged in one?

So someone has logged in and they kick off some Apex code, but I need that specific method to run under an admin user? Is that possible?

Thanks.
I have a custom object Custom_object__c having a text field Text__c. I want to display value of the text field of all records of the custom object in the form of picklist on VF page. I need only value (not binded with the record id). I want this picklist to create a page where I can dispaly record with filter option(as filter i want to use this picklist).
Please suggest how I can accomplish this.

Thanks!
hi dudes,  in student123__C  detail page there are 3 fields,  firstname__c. lastname__c, middlename__c   .   i need to write a trigger to check "if a person is entering the same values then, throw an error that "duplicate contact found".   

Example:-   1st record i entered as  "  Siva Naga Raju "      so if am again entering this same name then it should throw an error.    

For that i created a forumla field   called TOTALNAME__C  ( firstname__c + lastname__c + middlename__c).  upto here ok.   But trigger not firing, intially i worte bulk trigger, but its not firing, so i wrote a simple trigger then, it is also not firing,   please some boby help me. thanks in advance.


 
trigger duplicatefullname on student123__c (before insert,before update) {

string name;
list<student123__c> databasenames;
for(student123__c stu:trigger.new)
{
name=stu.firstname__c+stu.lastname__c+stu.middlename__c;
databasenames=[select totalname__C from student123__c where totalname__C=:name];
if(databasenames.size()>0)
stu.adderror('another jaff found');

}
    
}

User-added image
Here is my apex code: 
global class InvoiceBatchClass implements Database.Batchable<string>, Database.Stateful{
                
            global final blob dataDocuments;
            global boolean entry1;
            global boolean entry;
            global boolean b;
           
    global InvoiceBatchClass (Blob data )
     {
                this.dataDocuments=data;
     }
          
        global Iterable<string>  start(Database.BatchableContext BC){
        string nameFile=this.dataDocuments.toString();        
        return new CSVIterator(this.dataDocuments.toString(), '\n');
    }
    
     global void execute(Database.BatchableContext BC, List<String> scope)
     { 
        entry1=false;
         entry=false;
        
        list<Integer> rdlist=new list<Integer>();
           for(String row : scope){
             if(entry){
             List<String> fields = row.split(',');
             
             rdlist.add(Integer.valueof(fields[3]));//--Order Product
             
             }
             else{
                 entry=true;
             }
         }
   List<Order> Checkrdlist=[SELECT ID,name,Order_No_From__c  from Order WHERE Order_No_From__c IN:rdlist];
       list<Invoice__c> InvoiceList=new list<Invoice__c>();
          
       for(String row : scope){
    if(entry1){

        b=false;
       system.debug('abc'+row);
       
         List<String> fields = row.split(',');
              
             Invoice__c Invoices=new Invoice__c();
             
              
               String mDate=String.valueof(fields[0]);
               String[] stro = mDate.split(' ');
               String[] dtso = stro[0].split('/');
               Date myDate1 = date.newinstance(Integer.valueOf('20'+dtso[2]), Integer.valueOf(dtso[1]), Integer.valueOf(dtso[0])); 
             
              String invoiceDateFrom=String.valueof(fields[1]);
               String[] str1 = invoiceDateFrom.split(' ');
               String[] dts1 = str1[0].split('/');
               Date myDate2 = date.newinstance(Integer.valueOf('20'+dts1[2]), Integer.valueOf(dts1[1]), Integer.valueOf(dts1[0])); 
            
            
            String invoiceDateTo=String.valueof(fields[2]);
               String[] str2 = invoiceDateTo.split(' ');
               String[] dts2 = str2[0].split('/');
               Date myDate3 = date.newinstance(Integer.valueOf('20'+dts2[2]), Integer.valueOf(dts2[1]), Integer.valueOf(dts2[0])); 
             
             Integer ORD=Integer.valueof(fields[3]);  
//Assign Order Object Fields....
            for(Order a:Checkrdlist){
                System.debug('aaa-hhhhh-'+a.Order_No_From__c+ORD);
               
                if(a.Order_No_From__c==ORD){
                b=true;
                Invoices.Order__c=a.id;
                Break;
                }
                
                
            }
              system.debug('firstdate'+myDate1);
               system.debug('seconddate'+myDate2);
              

                 Invoices.Invoice_Date__c=myDate1;   
                 Invoices.Invoice_Date_From__c=myDate2;   
                 Invoices.Invoice_Date_To__c=myDate3;    
                 //Invoices.Order__c='801610000009DH8';
                 Invoices.OrderNumberFrom_Ex__c=Integer.Valueof(ORD);
                 if(b==true){
                 InvoiceList.add(Invoices);
                     }
                   else{
                   // No Record found
                   }                          
                 system.debug('abc'+InvoiceList);
                   }
             
             else{
                 entry1=true;
             }
       
       }
        upsert InvoiceList OrderNumberFrom_Ex__c;
  }
    

     global void finish(Database.BatchableContext BC)
     {
     
         // Send an email to the Apex job's submitter notifying of job completion.  
       
     }   
     
}


Tried so many test code but fail to do it, Please can any one help me for this code. Need test class for this apex class

Thank you in advance
I have a query which nests the related tasks with a contract.  E.g. [Select Id, name , (select Id , subject from tasks ) from contracts].

i know how to create a wrapper class for a query that is not nested but how do I create the constructor class for a query above?

e.g. I would normally have something like

public class wrapper 
public contract con {get;set}
public boolean selected {get;set}
public wrapper (contract c)
 con=c

i cant seem to use this as the query also includes tasks?

any ideas? Thanks 
I wrote the following Class to update a field based on a value in the User table
public with sharing class SDMR_Enrollment_Cycles_Trigger_Handler {

    Public SDMR_Enrollment_Cycles_Trigger_Handler(){
        }
    Public void OnBeforeUpdate(SD_Mbr_Enroll_Cycles__c[] newCycles){    
        For (SD_Mbr_Enroll_Cycles__c c : newcycles){

            // Look up the User Id for the Unassigned user record, to be used when the Enrollment Credit Agent 
            // field is null 
            List<User> users = [Select id, LastName from User Where LastName='Unassigned' and isActive=True
                             Limit 1];
            Map<string, string> uservalues = new Map<string, string>{};
            For(User u2: users)
                uservalues.put(u2.LastName,u2.id);
            
// Populates the Enrollment Credit Agent L/U if the Enrollment Status field = "Enrolled" and the Use Me field = True
            If(c.Enrollment_Status__c == 'Enrolled' && c.Use_Me__c == True){
                    if(c.Enrollment_Credit_Agent__c!=null){       
                        c.Enrollment_Credit_Agent_L_U__c = c.Enrollment_Credit_Agent__c;}
// If the Enrollment Credit Agent L/U is null and the Enrollment Status field = "Enrolled" and the Use Me field = True
// then look up the User Id for the Unassigned user record.
                Else {c.Enrollment_Credit_Agent_L_U__c = uservalues.get('Unassigned') ;}
                       
        }   
        }
    }    
}
But I keep getting an error when I try and validate it in prodcution.  This is the line being flagged:  
List<User> users = [Select id, LastName from User Where LastName='Unassigned' and isActive=True Limit 1];

Component Errors
Error Message
0 0 SCEBSDMEC_TEST.EnrollmentBase_Enrolled_Batchable(), Details: System.LimitException: Too many SOQL queries: 101 Class.SDMR_Enrollment_Cycles_Trigger_Handler.OnBeforeUpdate: line 10, column 1 Trigger.SDMR_Enrollment_Cycles: line 6, column 1

Apex Test Failures
Error Message
SCEBSDMEC_TEST EnrollmentBase_Enrolled_Batchable System.LimitException: Too many SOQL queries: 101 
Stack Trace: Class.SDMR_Enrollment_Cycles_Trigger_Handler.OnBeforeUpdate: line 10, column 1 Trigger.SDMR_Enrollment_Cycles: line 6, column 1
Hi All,

Have created a field set, no problems there.

I now want to use this field set on the default Acount page layout.  

I go to the page layout hoping the field set will be visible as one of the objects I can drag onto the form but it is nowhere to be seen. 

Any ideas?  Am using Group Edition and this may be the problem but there is nothing in the doco to suggest this would be a problem.

Thanks
Ross
 
trigger createSal on Employee__c (after insert, after update) {

       List<Salary__c> sal = new List<Salary__c>();

    for (Employee__c newEmp: Trigger.New) {
        if (newEmp.Name != null) {
            sal.add(new Salary__c(Id = newEmp.Id, Bonus__c=100,Monthly_Salary__c = 12000));
        }
    }
    insert sal;

}
Hey everyone,

I've run into the incredibly frustrating "Apex CPU time limit exceeded" error, so I put in debug statements throughout my triggers, in between each class call, which should show the CPU time after each class is called. That should theoretically tell me which class is causing the issue.

The problem is that only some of the debug logs show up.

For example, here is my main opportunity trigger, where all the opportunity classes are called. I have a debug statement after each call:
 
trigger MainTriggerOpportunity on Opportunity (before insert, before update, after insert, after update) {
    
    if(trigger.isBefore){
            
        if(trigger.isInsert){
            
            if(checkRecursive.runBeforeInsertOnce()){
            
            ClassOppIndustry updater = new ClassOppIndustry();
            updater.updateOppIndustry(Trigger.new);
                
               	System.debug(LoggingLevel.ERROR,'[OPP] BEFORE INSERT: CPU time after ClassOppIndustry is ' + Limits.getCpuTime() + '/' + Limits.getLimitCpuTime());
            
            ClassRenewalDate updater1 = new ClassRenewalDate();
            updater1.updateRenewalDate(Trigger.new);
                
                System.debug(LoggingLevel.ERROR,'[OPP] BEFORE INSERT: CPU time after ClassRenewalDate is ' + Limits.getCpuTime() + '/' + Limits.getLimitCpuTime());
                
            ClassLeadConvertUpdates updater2 = new ClassLeadConvertUpdates();
            updater2.updateLeadConvertFields(Trigger.new);
                
                System.debug(LoggingLevel.ERROR,'[OPP] BEFORE INSERT: CPU time after ClassLeadConvertUpdates is ' + Limits.getCpuTime() + '/' + Limits.getLimitCpuTime());
                
            }
            
        }
        if(trigger.isUpdate){
            
            if(checkRecursive.runBeforeUpdateOnce()){
            
            ClassOppIndustry updater = new ClassOppIndustry();
            updater.updateOppIndustry(Trigger.new);
                
                System.debug(LoggingLevel.ERROR,'[OPP] BEFORE UPDATE: CPU time after ClassOppIndustry is ' + Limits.getCpuTime() + '/' + Limits.getLimitCpuTime());
            
            ClassRenewalDate updater1 = new ClassRenewalDate();
            updater1.updateRenewalDate(Trigger.new);
                
                System.debug(LoggingLevel.ERROR,'[OPP] BEFORE UPDATE: CPU time after ClassRenewalDate is ' + Limits.getCpuTime() + '/' + Limits.getLimitCpuTime());
                
            ClassBrandParent updater2 = new ClassBrandParent();
            updater2.addBrandParent(Trigger.new);
                
                System.debug(LoggingLevel.ERROR,'[OPP] BEFORE UPDATE: CPU time after ClassBrandParent is ' + Limits.getCpuTime() + '/' + Limits.getLimitCpuTime());
                
            ClassCallScheduledAdvance updater3 = new ClassCallScheduledAdvance();
            updater3.addCallScheduledDate(Trigger.new,Trigger.oldMap);
                
                System.debug(LoggingLevel.ERROR,'[OPP] BEFORE UPDATE: CPU time after ClassCallScheduledAdvance is ' + Limits.getCpuTime() + '/' + Limits.getLimitCpuTime());
                
            }
     }
  }
    
    
    if(trigger.isAfter){
        
        if(trigger.isInsert){
            
            if(checkRecursive.runAfterInsertOnce()){
            
            ClassRenewalProcess updater = new ClassRenewalProcess();
            updater.updateRenewalStatus(Trigger.new);
                
                System.debug(LoggingLevel.ERROR,'[OPP] AFTER INSERT: CPU time after ClassRenewalProcess is ' + Limits.getCpuTime() + '/' + Limits.getLimitCpuTime());
            
            ClassOppBrandCreate updater1 = new ClassOppBrandCreate();
            updater1.addBrand(Trigger.new);
                
                System.debug(LoggingLevel.ERROR,'[OPP] AFTER INSERT: CPU time after ClassOppBrandCreate is ' + Limits.getCpuTime() + '/' + Limits.getLimitCpuTime());
                
            ClassOppTeamMember updater2 = new ClassOppTeamMember();
            updater2.insertOpp(Trigger.new);
                
                System.debug(LoggingLevel.ERROR,'[OPP] AFTER INSERT: CPU time after ClassOppTeamMember is ' + Limits.getCpuTime() + '/' + Limits.getLimitCpuTime());
                
            ClassPrimaryContactCopy updater4 = new ClassPrimaryContactCopy();
            updater4.copyPrimary(Trigger.new);
                
                System.debug(LoggingLevel.ERROR,'[OPP] AFTER INSERT: CPU time after ClassPrimaryContactCopy is ' + Limits.getCpuTime() + '/' + Limits.getLimitCpuTime());
                
            ClassOppPicklists updater5 = new ClassOppPicklists();
            updater5.updatePicklists(Trigger.new);
                
                System.debug(LoggingLevel.ERROR,'[OPP] AFTER INSERT: CPU time after ClassOppPicklists is ' + Limits.getCpuTime() + '/' + Limits.getLimitCpuTime());
                
            ClassBDSourceCreate updater6 = new ClassBDSourceCreate();
            updater6.addBDSource(Trigger.new);
                
                System.debug(LoggingLevel.ERROR,'[OPP] AFTER INSERT: CPU time after ClassBDSourceCreate is ' + Limits.getCpuTime() + '/' + Limits.getLimitCpuTime());
                
            ClassMapPlatform updater7 = new ClassMapPlatform();
            updater7.copyPlatform(Trigger.new);
                
                System.debug(LoggingLevel.ERROR,'[OPP] AFTER INSERT: CPU time after ClassMapPlatform is ' + Limits.getCpuTime() + '/' + Limits.getLimitCpuTime());
                
            ClassAnnualDealRevenue updater8 = new ClassAnnualDealRevenue();
            updater8.addAnnualRevenue(Trigger.new);
                
                System.debug(LoggingLevel.ERROR,'[OPP] AFTER INSERT: CPU time after ClassAnnualDealRevenue is ' + Limits.getCpuTime() + '/' + Limits.getLimitCpuTime());
                
            ClassDemandGenOpportunity updater9 = new ClassDemandGenOpportunity();
            updater9.addContactRoles(Trigger.new);
                
                System.debug(LoggingLevel.ERROR,'[OPP] AFTER INSERT: CPU time after ClassDemandGenOpportunity is ' + Limits.getCpuTime() + '/' + Limits.getLimitCpuTime());
                
            }
       }
        if(trigger.isUpdate){
            
            if(checkRecursive.runAfterUpdateOnce()){
            
            ClassRenewalProcess updater = new ClassRenewalProcess();
            updater.updateRenewalStatus(Trigger.new);
                
                System.debug(LoggingLevel.ERROR,'[OPP] AFTER UPDATE: CPU time after ClassRenewalProcess is ' + Limits.getCpuTime() + '/' + Limits.getLimitCpuTime());
            
            ClassOppBrandCreate updater1 = new ClassOppBrandCreate();
            updater1.addBrand(Trigger.new);
                
                System.debug(LoggingLevel.ERROR,'[OPP] AFTER UPDATE: CPU time after ClassOppBrandCreate is ' + Limits.getCpuTime() + '/' + Limits.getLimitCpuTime());
                
            ClassDrawLoopUpdates updater3 = new ClassDrawLoopUpdates();
            updater3.updateDrawLoopFields(Trigger.new);
                
                System.debug(LoggingLevel.ERROR,'[OPP] AFTER UPDATE: CPU time after ClassDrawLoopUpdates is ' + Limits.getCpuTime() + '/' + Limits.getLimitCpuTime());
                
            ClassPrimaryContactCopy updater4 = new ClassPrimaryContactCopy();
            updater4.copyPrimary(Trigger.new);
                
                System.debug(LoggingLevel.ERROR,'[OPP] AFTER UPDATE: CPU time after ClassPrimaryContactCopy is ' + Limits.getCpuTime() + '/' + Limits.getLimitCpuTime());
                
            ClassOppPicklists updater5 = new ClassOppPicklists();
            updater5.updatePicklists(Trigger.new);
                
                System.debug(LoggingLevel.ERROR,'[OPP] AFTER UPDATE: CPU time after ClassOppPicklists is ' + Limits.getCpuTime() + '/' + Limits.getLimitCpuTime());
                
            ClassBDSourceCreate updater6 = new ClassBDSourceCreate();
            updater6.addBDSource(Trigger.new);
                
                System.debug(LoggingLevel.ERROR,'[OPP] AFTER UPDATE: CPU time after ClassBDSourceCreate is ' + Limits.getCpuTime() + '/' + Limits.getLimitCpuTime());
                
            ClassMapPlatform updater7 = new ClassMapPlatform();
            updater7.copyPlatform(Trigger.new);
                
                System.debug(LoggingLevel.ERROR,'[OPP] AFTER UPDATE: CPU time after ClassMapPlatform is ' + Limits.getCpuTime() + '/' + Limits.getLimitCpuTime());
                
            ClassAnnualDealRevenue updater8 = new ClassAnnualDealRevenue();
            updater8.addAnnualRevenue(Trigger.new);
                
                System.debug(LoggingLevel.ERROR,'[OPP] AFTER UPDATE: CPU time after ClassAnnualDealRevenue is ' + Limits.getCpuTime() + '/' + Limits.getLimitCpuTime());
                
            ClassDemandGenOpportunityUpdate updater9 = new ClassDemandGenOpportunityUpdate();
            updater9.addContactRoles(Trigger.new,Trigger.oldMap);
                
       

                
            }
        }
    }
}

But here is the log after I mass updated some opportunities in production:

User-added image

As you can see, only the final debug statements are showing up. Any idea why that would be? Also, if you have any suggestions on how to better find out where the CPU limit error is coming from, that would be extremely appreciated.

Thanks!
-Greg

Hi ,

 

     I am confused between synchronous and asynchronous can any one explain me from the scratch what are they actually , and when we use the @future annotation . Please Help me  !!!

 

 

Help is highly appreciated.

 

Thanks in Advance. 

  • June 22, 2013
  • Like
  • 2
difference between "Trigger.New" and "Trigger.old".