• VarunSforce
  • NEWBIE
  • 50 Points
  • Member since 2010

  • Chatter
    Feed
  • 2
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 15
    Replies

Hi everyone, 

 i have a trigger to update the rollup summary field on master record. when i was trying to update one field. its working correctly. 

here is the problem, when i was trying to update more than one field with based on the Amount field and the critiria is different. i have around 8 fields to update.

 here is the code for u r reference 

 

help is needed urgently

  • October 14, 2011
  • Like
  • 0

how do I make this cod work? it dies on the last SOQL statement.

 

trigger Load_Opportunity_Product_Details on OpportunityLineItem (before update) {

  List<PricebookEntry> pTypes = [SELECT Id, Product2Id FROM PricebookEntry];    //pull recordtype Id's and record type names from recordtypes where the sobject is contract
 
  MAP<Id , Id> maprtID_rtName = new MAP<Id , Id>();  //map record type ID's to record type names.
  for(PricebookEntry pTypeObj :  pTypes)
  {
  	mapptID_ptName.put(pTypeObj.id , pTypeObj.id); //for all recordtypes... log id's and record type names.
  }




	for (OpportunityLineItem opplineitem:Trigger.new){
		opplineitem.description = [Select Description FROM Product2 where id = mapptID_ptName.get(opplineitem.PricebookEntryId)];


	}



}

 

========================================================
Scenario:

We have a custom object with N number of fields, user can update any field and can submit record for approval. ( change the data and submit for approval.....)

Now if approver, approves the request then its Fine, if approver rejects the approval request then we want to rollback all the changed data.
========================================================

 

I would be writing APEX code to store previous state of data in one other object and when rollback is required will update record with this previous state.....

ANY INPUTS OR SUGGESTIONS.......

Hi everyone, 

 i have a trigger to update the rollup summary field on master record. when i was trying to update one field. its working correctly. 

here is the problem, when i was trying to update more than one field with based on the Amount field and the critiria is different. i have around 8 fields to update.

 here is the code for u r reference 

 

help is needed urgently

  • October 14, 2011
  • Like
  • 0

Hi All,

 

My trigger was working fine before, but now that i have changed the Serial_Number_New__c field from data type text to a lookup, the trigger wont work.  No error message is shown when i save the trigger.  But when i try creating a case nothing happens.

 

Please help!!!

trigger UpdateWarranty on Case (before insert, before update) {   
    
    for(Case c : Trigger.new){
        If(c.RecordTypeId == '012D0000000AoAZ'){
            String cid = c.Serial_Number_New__c;
            List<Warranty__c> Serials = [SELECT Engine_Number__c, Model_Number__c FROM Warranty__c WHERE      Name = :cid];
            c.Engine_s_n__c = Serials.get(0).Engine_Number__c;
            c.Model_Number__c = Serials.get(0).Model_Number__c;
           
            }
        }
}

  • October 14, 2011
  • Like
  • 0

Hi , 

 

I have a requirement where I want to show Address Location from "Google Map" custom link on an Account record BASED on following criteria :- 

 

- There is a custom picklist field "Primary Address" with values "Business, Home, Other"

- There are 3 sets of addresses : Business (Billing Address set of fields) , Home(Mailing Address set of fields) and Other (Custom Address set of fields)

- Now if "Primary Address" is "Business", when I click on "Google Map" custom link, it should show me only "Business" Address location. If the "Primary Address" is "Home", the custom link will show "Home" Address location and so on.

 

Please advise how can I achieve this?  

 

Thanks, 

 

Vimal

Is it possible to convert a lead into an Opportunity without creating an Account or Contact depending on the Lead Record Type?

  • October 12, 2011
  • Like
  • 0

how do I make this cod work? it dies on the last SOQL statement.

 

trigger Load_Opportunity_Product_Details on OpportunityLineItem (before update) {

  List<PricebookEntry> pTypes = [SELECT Id, Product2Id FROM PricebookEntry];    //pull recordtype Id's and record type names from recordtypes where the sobject is contract
 
  MAP<Id , Id> maprtID_rtName = new MAP<Id , Id>();  //map record type ID's to record type names.
  for(PricebookEntry pTypeObj :  pTypes)
  {
  	mapptID_ptName.put(pTypeObj.id , pTypeObj.id); //for all recordtypes... log id's and record type names.
  }




	for (OpportunityLineItem opplineitem:Trigger.new){
		opplineitem.description = [Select Description FROM Product2 where id = mapptID_ptName.get(opplineitem.PricebookEntryId)];


	}



}

 

Hello I have a simple Problem,

I have the CreatedDate field of an Object, and instead of the date i need the difference between now and the Date,

because I want to show it in the Visual Force like this for example:

5 Hours Ago or

10 day Ago.

 

I didn't find a method to calculate such things.

 

Thanks in advance.

Ok all here is one that I am running into Trouble with. I have a Trigger that is Before insert, before update.

It is validating the address via the postalcodes as well as ensuing a proper grouping for reporting using the County and State returned from the Zip look up.
It works great however I need to Accommodate for passing 2300+ accounts at one time.
Any one do a Bulk/Batch processing before insert, before update? I keep getting a recursive issue.


Hi

Tell me how to get only date from a value or how to delete time from this format.

2011-09-20 00:00:00

 

thanks

Anuraj

  • October 12, 2011
  • Like
  • 0

Hi,  my trigger only fires for the first record in the batch when performing a dataloader insert.  Any ideas on how to get it to fire for all the records in each batch?  Dataloader is set to batchs of 200.  I don't want to reduce the batch to a count of 1, I need it to do bulk.  The trigger is designed to perform a vlookup (using the zip code on the lead as a reference) on a custom object (Postal Code Test)  and populate a custom field on the Lead object.  Each record on the Postal Code Test object contains a zip code and a corresponding internal territory.

 

here's the trigger:

 

trigger UpdateLeadAreaAssign on Lead (before Insert, before Update) {

    try {

        for(Lead x : Trigger.New) {

            //set to no area until it finds a territory matching the zip

            x.Lead_Territory_Trigger__c = 'NOAREA';

           

            //fetch territory from custom object using postal code from lead

            List<Postal_Code_Test__c> triggerLeadArea =

                [SELECT p.Lead_Territory__c

                FROM Postal_Code_Test__c p

                WHERE Zip_Code__c =: x.PostalCode

                LIMIT 1];

           

            //update lead territory field on lead

            x.Lead_Territory_Trigger__c = triggerLeadArea[0].Lead_Territory__c;       

        }

    } 

    catch (Exception e) {      

        System.Debug('ERROR: ' + e);

    }

}

Hi,

I have written a  trigger on Attachment (after insert, after update) I am trying to fetch the Parent Name in that by following code.
Anyone having idea why reference field's data is not accessible in trigger?

for(attachment  a: trigger.new)
{
   system.debug(a.ParentId) ;                 //It returns the ID appropriately
   system.debug(a.Parent.Name);        //but this is returning null even when corresponding name field is having data.
   system.debug(a.Parent);                   //even this is being returned as null;
}

There can be attachments related to n  number of objects. I don't want to fire too many SOQL just to know to which Parent this attachment is referring to.
Can anyone please suggest workaround for it?
Thanks
  • June 09, 2011
  • Like
  • 0