• Raj R.
  • SMARTIE
  • 780 Points
  • Member since 2012

  • Chatter
    Feed
  • 2
    Best Answers
  • 3
    Likes Received
  • 1
    Likes Given
  • 76
    Questions
  • 101
    Replies
Hi Everyone,

I'm having problem with heap size error
We have a trigger from the trigger we are calling so any classes,if we do any changes in the record it showing heap size 

Please help 
Thanks in advance 

Regards
Rathod
I  have picklist field called "Novated_opportunity__c", when 'yes' is selected, need to hide "Outline_of_the_Novated_opportunity__c"

I am using below script, no error's however no result.

<apex:page standardController = "Pricing_Request__c" showHeader="true" >
    <apex:form>
        <apex:outputPanel id="t1">
            <apex:pageBlock>
                <apex:pageBlockSection title="Novated leases">
                    <apex:inputField value="{!Pricing_Request__c.Novated_opportunity__c}" >
                    
                        <apex:actionSupport event="onchange" rerender="t1" />
                    </apex:inputField>
                </apex:pageBlockSection>
                
                <apex:pageBlockSection title="Novated leases">
                    <apex:inputField value="{!Pricing_Request__c.Outline_of_the_Novated_opportunity__c}" rendered="{!IF( Pricing_Request__c.Novated_opportunity__c == 'Yes', true, false )}" >
                        <apex:actionSupport event="onchange" rerender="t1" />
                    </apex:inputField>
                    
                </apex:pageBlockSection>
            </apex:pageBlock> 
        </apex:outputPanel>
    </apex:form>
</apex:page>


Thanks,
Vinod

Here's what I've been staring at for 16 minutes so far. 

User-added image

Deployed via SFDX, specifying a single apex test to run, which has less than 40 lines of code. Takes only a fraction of a second to run in scratch org or sandbox.

But when I deploy to Production, all components are validated within a minute or two, then the status switches to 'Running {testname}'.... and stays that way. For literally 15 minutes or more. Before the test is even started. 

I'm not finding a lot of posts on this issue. Plenty of people talking about the time it takes to actually run the test. But I'm talking about the time it takes to start running the tests. This isn't a one time thing, but it also isn't consistent. Sometimes the tests will begin running pretty much immediately. Sometimes I'll end up cancelling and redeploying because a 30 minute delay to START testing seems ridiculous even given Salesforce's standards. And when I do cancel and redeploy? Good chance it'll take a fifth of the time, for no apparent reason.

What I'd really like is some better communication during this process. Why is my test run delayed? What was prioritized ahead of it? How can I anticipate deployment times so it's not a complete crapshoot regardless of build size? 

Hi Developers,

I have a requirement to integrate Salesforce with Azure Queue. I want to write a batch class to hit the queue and if there is any record in the queue, then insert/update in the salesforce. Any code/Document for reference will be much helpful.

Thanks,
Rishabh
Hi,

I wrote a trigger to update the Project Item from Project (Parent to Child update.)

For the same, I wrote a test class also. I covered all the things in test class even though my code coverage is 50% only.

Kindly let me know where am doing the mistake.


Trigger:

trigger OI_Update_ProjItem_Status on Project__c (after update) {
    
    set<id>setprojid = new set<id>();
    list<Sale_Products__c>lstsp = new list<Sale_Products__c>();
    list<Project_Item__c>lstpi = new list<Project_Item__c>();
    
    for(Project__c proj : Trigger.New){
        if((proj.Nature_of_Case__c == 'Project Complete / Delivered - Payment Due' || proj.Nature_of_Case__c == 'Project Completed - Payment Recieved') && (proj.Project_Type__c.Contains('Indoor')
            || proj.Project_Type__c.Contains('Furniture'))){
             setprojid.add(proj.id);
        }
            
    }
    if(setprojid.size() > 0){
     
        for(Project_Item__c pi : [SELECT id, Status__c FROM Project_Item__c WHERE Project__c IN :setprojid]){
            pi.Status__c = 'Delivered';
            lstpi.add(pi);
        } 
           
        for(Sale_Products__c sp : [SELECT id, Status__c , Work_Order__c FROM Sale_Products__c WHERE Work_Order__c IN : setprojid]){
            sp.Status__c = 'Delivered';
            lstsp.add(sp);
        } 
   } 
   if(lstpi.size() > 0){
       update lstpi;
   } 
   if(lstsp.size() > 0){
       update lstsp;
   }            
}

Test Class:

@isTest(seealldata=true)
Public class TestWorkorder{
    static testMethod void TestWorkorder(){
    
       Test.startTest();  
        
        
        
        
             Profile p = [SELECT Id FROM Profile WHERE Name='Standard User'];
             
            User u = new User(Alias = 'Test', Email='Test@testorg.com', 
            EmailEncodingKey='UTF-8', LastName='Testing', LanguageLocaleKey='en_US', 
            LocaleSidKey='en_US', ProfileId = p.Id, 
            TimeZoneSidKey='America/Los_Angeles', UserName='xyz@gmail.com');
            
            insert u;
            
            
        
       Pricebook2 pb = new Pricebook2(Name = 'Standard Price Book 2009', Description = 'Price Book 2009 Products', IsActive = true );
      insert pb;
    
    
        Product2 prod = new Product2(Name = 'SLA: Bronze', IsActive = true);
        insert prod;
    
    
// First insert a price for the standard price book

            Pricebook2 standardPB = [select id from Pricebook2 where isStandard=true];
            
            PricebookEntry standardPBE = new PricebookEntry(Pricebook2Id = standardPB.Id, Product2Id = prod.Id, UnitPrice = 1000, IsActive = true);
                insert standardPBE;
                
            PricebookEntry pbe = new PricebookEntry(Pricebook2Id = pb.Id, Product2Id = prod.Id, UnitPrice = 1000, IsActive = true);
                insert pbe;
        
        Account a = new Account(Name = 'ApprovalTest' ,Lock_record__C=FALSE ,ownerid=u.ID);
        insert a; 
       
        
        
        Opportunity opp =New Opportunity(Name='Test', accountId = a.id, StageName='Closed Won',CloseDate=Date.newInstance(2018, 04, 30));
        insert Opp; 
        
       
            
             Contact con = new COntact();
            con.email='test@fmail.co';
            con.ACCOUNTID=a.ID;
            con.ownerid=a.ownerid;
            con.lastname='test' ;
            
            insert con;
                         
            
        
       
           
            
        
        Opp.Pricebook2Id = pb.id;
        update Opp;
        
        OpportunityLineItem OL = new OpportunityLineItem(opportunityid=Opp.id, Quantity=1, unitprice=8000,  
            pricebookentryid=pbe.id);
        insert OL;  
            
        Quote Q = new Quote();
        Q.Name = 'QuoteOrbit';
        Q.OpportunityId = Opp.id; 
        Q.Quote_Count__c = 00000000;
        Q.Approved__c = true;
        Q.Quote_Number__c ='000000';
        Q.Quotation_Date__c = date.newinstance(2013,3,5);
        Q.Pricebook2Id = pb .id;
        
        insert Q;
        
        Quotelineitem QL = new Quotelineitem(quoteId=Q.id, Quantity =1, Unitprice=8000,pricebookentryid=pbe.id);
        insert QL; 
        
        Opp.SyncedQuoteId = Q.id;
        update Opp;
        
        
         
        Project__c Proj = new Project__c(name='OrbitProj', Opportunity__c = Opp.id, Quote__c = Q.id, Project_Type__c = 'New PE', Date_of_Installation__c = date.newinstance(2013,4,5),
            Nature_of_Case__c ='No Adv, Dspch & Erection Pending',Contact__C=con.ID,Customer_Name__c=a.id,Special_Instructions__c ='Test for Work order Pdf to be generated');    
            
        insert Proj;  
        
        Proj .Nature_of_Case__c = 'Project Completed - Payment Recieved';
        Proj .Nature_of_Case__c ='Project Complete / Delivered - Payment Due';
        Proj .Despatch_Date__c=Date.newInstance(2018, 04, 30);
        Proj .Delivery_Date__c=Date.newInstance(2018, 04, 30);
        
         update Proj ;
        
        
        
       
                
       
        
       
                
        Project_Item__c pi = new Project_Item__c(Project__c = Proj .id,Status__c = 'Pending',Product__c = prod.id,
                                 Technician_Member__c = 'suren; lakshmanan');
        insert pi;
        
        Project_Item__c pitm=[select ID, Status__c  from Project_Item__c  where ID=:Pi.ID];
        
        
        
        pitm.Status__c = 'Delivered' ;      
        
        update pitm;    
       
                
     
         
        
        Product_Inventory__c PInv=new Product_Inventory__c  (Product__c=prod.id);
        insert PInv;
        
        
     
        
        Sale_Products__c sp = new Sale_Products__c  (Status__c ='pending' ,Work_Order__c=Proj .id,Product_Inventory__c=PInv.ID,Quantity__c=1);
        insert sp ;
        
        Sale_Products__c Spr= [select Status__c  from Sale_Products__c  where ID=:Sp.id];
        
        Spr.Status__c ='Delivered';    
        
        update Spr;
        
       
        
         Test.stopTest();
 
        
    }
    
}

 
Hi,

I am looking for an Apex Class + Trigger to --> when I create an opportunity from a custom object record (very much like an account) with associated contacts, I'd like to automatically create X number of contact roles per contacts related to the custom object record and tie those Opportunities to the newly created Opportunity.

The account custom obejct record works very similar like the relationship for Account -- Opportunity -- Contact. 

I'd love to have the code also to prevent Duplicate Contact Roles (based on the contact Id) in the Opportunity Contact Role. Provided below is the Apex Trigger I have so far. The problem is the Trigger doesn't prevent duplicate Opportunity contact roles from being created, and I dont have an Apex class for it.

AccountSpecific__c --> custom object record
Accountspecificid__c --> custom field on the Contact
AccountSpecificOppId__c --> custom field on the Opportunity
trigger createOpportunityContactRoles on Opportunity (after insert) {

    Set<Id> accSpecificIds = new Set<Id>();
    List<OpportunityContactRole> ocrList = new List<OpportunityContactRole>();
    Map<Id, List<Contact>> accountSpecificContacts = new Map<Id, List<Contact>>();
    
    for(Opportunity o: Trigger.New) {
        if(o.AccountSpecificOppId__c != Null) 
            accSpecificIds.add(o.AccountSpecificOppId__c);
    }
    
    for(Contact con: [select id, AccountSpecificId__c from Contact 
                    where AccountSpecificId__c in: accSpecificIds]) {
        if(!accountSpecificContacts.containsKey(con.AccountSpecificId__c)) 
            accountSpecificContacts.put(con.AccountSpecificId__c, new List<Contact>());
        accountSpecificContacts.get(con.AccountSpecificId__c).add(con);
    }
    
    for(Opportunity opp: Trigger.New) {
        if(accountSpecificContacts.containskey(opp.AccountSpecificOppId__c) 
            && accountSpecificContacts.get(opp.AccountSpecificOppId__c) != NULL) {
            Boolean isFirstContact = true;
            for(Contact c: accountSpecificContacts.get(opp.AccountSpecificOppId__c)) {
                OpportunityContactRole ocr = new OpportunityContactRole(ContactId = c.Id, 
                                                                        OpportunityId = opp.id);
                if(isFirstContact) {
                    ocr.IsPrimary = true;
                    isFirstContact = false;
                }
                ocrList.add(ocr);
            }
        }           
    }
    
    if(ocrList.size() > 0)
        insert ocrList;
}

 
How can i update a check box in all parent account above the hierarchy from the child account check box?
Hi All,
            Noticed that after perparing and before processing,Total Batches field will be updated.

            Want to understand if preparing is the status where START method query is executed and 
            based on batch size total batches gets calculated ? All this happend during perparing state of batch job ?
            Can we understand if perparing is done means START method has completed successfully ?
            And BEGIN method won't start executing when status is perparing?

           Please comment on my above understandings.

Thanks
D
HI all - 

I have Opportunity Products configured via workflow + field update so based on Billing Frequency (Monthly, Quarterly, Yearly, One Time) my Standard Field Sales Price (aka UnitPrice) will calculate. I have tried this in Process Builder and it didn't work well either.
We have Subscription and Non-Subscription line items on Opportunity Products line items and customer may be billed differently for each line item.
Below is a view of Products I've chosen based on a 24 month contract:
User-added image
I created a custom field called "Unit Price" to hold the original amount input
I then wrote the following formulas to update the standard field called Sales Price (aka UnitPrice):

SUBSCRIPTION Update Field Sales Price:

IF(CONTAINS(Billing_Frequency__c, "Monthly"), Unit_Price__c *1, 
IF(CONTAINS(Billing_Frequency__c, "Quarterly"), Unit_Price__c *3, 
IF(CONTAINS(Billing_Frequency__c, "Yearly"), Unit_Price__c *12, 
IF(CONTAINS(Billing_Frequency__c, "One Time"), Unit_Price__c *1, null))))

NON-SUBSCRIPTION Field Update Sales Price:

IF(CONTAINS(Billing_Frequency__c, "Monthly"), 
Unit_Price__c * Quantity / Contract_Terms__c, 
IF(CONTAINS(Billing_Frequency__c, "Quarterly"), 
Unit_Price__c * Quantity / Contract_Terms__c *3, 
IF(CONTAINS(Billing_Frequency__c, "Yearly"), 
Unit_Price__c * Quantity / Contract_Terms__c * 12, 
IF(CONTAINS(Billing_Frequency__c, "One Time"), 
Unit_Price__c *1, null))))

Then, for the Total Contract Amount I create these two formula for updating the fields:

SUBSCRIPTION Field Update Total Contract Value:
TotalPrice / Billing_Frequency_Number__c * Contract_Terms__c

NON-SUBSCRIPTION Field Update Total Contract Value:
IF(CONTAINS(Billing_Frequency__c, "Monthly"), 
UnitPrice * Opportunity.Contract_Term_Number__c / 1, 
IF(CONTAINS(Billing_Frequency__c, "Quarterly"), 
UnitPrice * Opportunity.Contract_Term_Number__c / 3, 
IF(CONTAINS(Billing_Frequency__c, "Yearly"), 
UnitPrice * Opportunity.Contract_Term_Number__c / 12, 
IF(CONTAINS(Billing_Frequency__c, "One Time"), 
TotalPrice, null))))

My challenge is that the Contract Term updates just fine but the change doesn't trigger a recalculation. What am I doing wrong?
I have Evaluation Criteria as: Evaluate the rule when a record is created, and any time it's edited to subsequently meet criteria
I even checked the boxed on each Field Update that says: Re-evaluate Workflow Rules after Field Change
Even if I go into the Opportunity Product Line item record and make a change, re-calculations still don't happen. 

Thanks in advance to anyone who can help me with this!!
down vote favorite
I am trying to update a lookup field(Benefit_ID in Customer object) with the below code, The code works fine for single record but it is failing for multiple records:
Error: "caused by: System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, "
trigger updatelookupfield_Customer on Customer__c (before insert,before update) {
    Set<String> Bundle = new Set<String>();

    for (Customer__c Cust : Trigger.new) {
        Bundle.add(Cust.Bundle__c);
    }
List<Benfit__c> BenfitList = [SELECT id, Bundle__c FROM Benfit__c WHERE Bundle__c IN :Bundle];

    Map<String, Benfit__c> ASSIGN_BENEFIT = new Map<String, Benfit__c>();

    for (Benfit__c c : BenfitList) {
        ASSIGN_BENEFIT.put(c.Bundle__c, c);
    }

    for (Customer__c o : Trigger.new) {
              if (o.Bundle__c != null) {
            o.Benefit_ID__c = ASSIGN_BENEFIT.get(o.Bundle__c).id;
        }
        else {
            o.Benefit_ID__c = null;
        }
    }
    }
Just to highlight i am using multiple triggers on this object, not sure that is the reason for this issue.
 
Hello! 
I need to show on the VF page (table) results of the 3 SOQL requests:

I have 2 objects: Users and related SyncLog__c

I need to see on the table
First column: Users list
Second column: Is there records created before 10 AM YES/NO
Third column: Is there records created after 6 PM YES/NO



 
Hi Expert,

I need to create a Label type field on opportunity page layout:
As per below image i need "Security 4" Label in stanard page layout.

 User-added image

Please confirm

Regard
Mukesh
I currently am working on creating an Apex Class that initiially pulls a specific set of Placements (jstcl__Placement__c) and puts them in a list. 
It then takes that list of Placement Ojects and edits a relevant field called TimecardEnddateAudit__c field. I keep getting errors saying that the field jstcl__Timesheet_Period__c that exists in some of my if logic does not exist. Logically it should edit fields according to the logic:" If the jstcl__Timesheet_Period__c field is equal to 'Weekly Split' then add .5, else add 1. 
public class CamstimecardEndDateAudit{
public static void auditTimeCards(){

List<sObject> placements = [SELECT jstcl__Placement__r.Name
                            FROM jstcl__TG_Timesheet__c 
                            WHERE jstcl__Placement__r.ts2__Status__c IN ('Active') 
                             AND jstcl__Week_Ending__c = LAST_N_DAYS:15
                             AND jstcl__Status__c = 'Pending'];
                             
    for(List<sObject> A : placements){

        if(A.jstcl__Timesheet_Period__c = 'Weekly Split'){
        
        TimecardEndDateAudit__c = TimecardEndDateAudit__c + 0.5;}
        
        else{
        
        TimecardEndDateAudit__c = TimecardEndDateAudit__c ++;
}
}
}}