• Phoenixed
  • NEWBIE
  • 0 Points
  • Member since 2012

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 7
    Replies

Hello,

 

i'm getting the error - 'You have uncommitted work pending. Please commit or rollback before calling out'  when performing  updates for multiple object or calling multiple update statements.

 

i have two sObjects 1) Contact and 2) Account as below -

 

sContact = [SELECT c.FirstName, c.LastName, c.Title FROM Contact c WHERE c.Id = :contactId];
sAccount = [SELECT a.Id, a.Name,a.Website FROM Account a WHERE a.Id = :accountId];

 

after this inside a loop i'm updating some filed values of both objects as -

 

   for(Integer i=0 ; i<selRecords.size() ; i++)
     {
              if(selRecords[i].AttributeType == 'contact')
                    {
                        sContact.put(selRecords[i].FieldName,selRecords[i].fieldValue);
                    }
                    if(selRecords[i].AttributeType == 'CompanyType')
                    {
                        sAccount.put(selRecords[i].FieldName,selRecords[i].fieldValue);
                    }
         }
     

               update sContact;
               update sAccount;

 

during the call "update sAccount" it throws the error - You have uncommitted work pending. Please commit or rollback before calling out.

 

i tried Database.SaveResult[] SR = database.update(updatesArr);   also, where updatesArr is array of SObject in which both of the above sObjects are assigned, but can't get it working.

 

Please suggest that how can we call multiple update statements or perform multiple sObject updates.

 

Thanks in advance.

          

I wanted to know if there is a way we can audit all the people that get emails via the Client's Custom App.

 

Is there a way, that a particular User can be set-up so that he can get all the auto-generated emails (new requests,emails etc..) and do an audit of who is on there?

hi..

 i wrote trigger on contract object.and it have some fields like start date,end date..and the contract period is 1year.but my need is before 60days of end date email will sent to the user..

 

 

i write the trigger..and i add the function today() the email is came..but how to add the 60days before of end date??

 

can anyone suggest me please??

 

Thanks&Regards

Bhagi.n

  • July 02, 2012
  • Like
  • 0

Hi,

 

I created a custom button and i want that button should work for queue member only if anyone else is clicking that button then it should show alert message that you are not the member of queue.

 

How i can implement this in custom button creation using javascript or anything else.

 

Thanks in Advance.

 

 

Thanks:))))

Can anyone help me move my coverage for this trigger to a higher %? any help is appriciated.

 

Lines not Covered

:

trigger trg_new_AdProductFulfillment on Opportunity (after update)
{
   List<Opportunity> closedWonOpps=new List<Opportunity>();

   for (Opportunity opp : trigger.new)
   {
       Opportunity oldOpp=trigger.oldMap.get(opp.id);
       if ( (opp.StageName=='Closed Won') &&
            (oldOpp.StageName!='Closed Won')&&
            (opp.Message_Sent__c== False))
       {
          closedWonOpps.add(opp);
       }
   }
    
   if (!closedWonOpps.isEmpty())
   {
    List<OpportunityLineItem> olis = [SELECT ID, OpportunityId,Account_Manager_ID__c,Opportuntiy_Owner_id__c,PO_IO_Number__c, Account_ID__c,Standard_RateproductID__c,Closed_Won_Date__c,
        Quantity FROM OpportunityLineItem WHERE Ad_Product_Fulfillment__c ='True' and
        OpportunityId in :closedWonOpps];

    List<Ad_Product_Fulfillment__c> afToInsert=new List<Ad_Product_Fulfillment__c>();
   for (OpportunityLineItem oli : olis)
   {
    
    For (integer i = 0; i < oli.Quantity; i++){
            Ad_Product_Fulfillment__c newaf= new Ad_Product_Fulfillment__c();
            newaf.Opportunity__c = oli.Opportunityid;
            newaf.Placement__c = oli.Standard_RateproductID__c;
            newaf.Account__c = oli.Account_ID__c;
            newaf.IO_Start_Date__c = oli.Closed_Won_Date__c;
            newaf.PO_IO_Number__c = oli.PO_IO_Number__c;
            newaf.Quantity__c = oli.Quantity;
            newaf.Expiration_Date__c = oli.Closed_Won_Date__c +365;
            newaf.Account_Executive__c = oli.Opportuntiy_Owner_id__c;
            newaf.Account_Manager__c = oli.Account_Manager_ID__c;
            afToInsert.add(newaf);
       }
          }

    insert afToInsert;
   }
}

 

 

Here is my Test Class:

@isTest(SeeAllData=True)

Public class Testtrg_new_AdProductFulfillment{

static testmethod void Testtrg_new_AdProductFulfillment()

{


List<Opportunity> closedWonOpps=new List<Opportunity>();

Opportunity opp = new Opportunity();
opp.StageName='Closed Won';
opp.Message_Sent__c= False;
opp.Name = 'Test';
opp.Account_Manager__c = '00550000000saAA';
opp.CloseDate =Date.newInstance(2012, 01, 15);
opp.Product_Interest__c = 'Job Posting';
opp.Billing_Email__c = 'test@otj.com';
opp.New_Dollar_Amount__c=100;
insert opp;

       {
          closedWonOpps.add(opp);
       }

List<OpportunityLineItem> olis = [SELECT ID, OpportunityId,Account_Manager_ID__c,Opportuntiy_Owner_id__c,PO_IO_Number__c, Account_ID__c,Standard_RateproductID__c,Closed_Won_Date__c,
        Quantity FROM OpportunityLineItem WHERE Ad_Product_Fulfillment__c ='True'and
        OpportunityId in :closedWonOpps];
        
OpportunityLineItem oppt = new OpportunityLineItem();
oppt.OpportunityId=opp.Id;
oppt.Quantity =1;
oppt.Cost_Type__c ='weekly';
oppt.TotalPrice =100;
oppt.PricebookEntryId='01u50000003SHVz';
insert oppt;

    List<Ad_Product_Fulfillment__c> afToInsert=new List<Ad_Product_Fulfillment__c>();
   {
Ad_Product_Fulfillment__c adg= new Ad_Product_Fulfillment__c();
            adg.Opportunity__c = '006W0000002VxWF';
            adg.Placement__c = '01t50000001YRdD';
            adg.Account__c = '001W0000004yqYJ';
            adg.IO_Start_Date__c = Date.newInstance(2012, 01, 15);
            adg.PO_IO_Number__c = '123';
            adg.Quantity__c = 1;
            adg.Expiration_Date__c = Date.newInstance(2012, 01, 15);
            adg.Account_Executive__c = '00550000000saAA';
            adg.Account_Manager__c = '00550000000saAA';
insert afToInsert;
}

}}

 Please help!

 

Thank you

Niki

hello,

is it possible to create two tabs for only one object (i don t need a view).

example: for an object X  i need to have X-A tab and X-B tab.

if yes .please tell me how we can do it??

Hi Frnds,

 

is there any possiblity to deploy a profile from sandbox environment to production environment?

 

Thanks in advance,

Reddy