• imranraza
  • NEWBIE
  • 84 Points
  • Member since 2012

  • Chatter
    Feed
  • 3
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 17
    Replies

Can you help me with the following error msg?

 

Initial term of field expression must be a concrete SObject List

 

trigger ChatterPostSURLStatus on Contract (after update) {

  for(Contract c: Trigger.new){
    CollaborationGroup[] oG = [Select ID, Name from CollaborationGroup];
      if(c.Status == 'Granted' && c.ActivatedDate==Today() && oG.Name == 'Renewal'){
          FeedPost sPost = new FeedPost();
          sPost.ParentId = oG.ID;
          sPost.Body = c.Account && 'is now supported on SURL';
          insert sPost;
          }
    }
}

Hello,

I am new to working with Apex and I have what I suspect is in an easy question. I have a trigger that I have written to create a record on a custom object on Insert or Update of case with a specific topic. The issue I am having (as you would guess) is that it creating a new record everytime the case is updated.  I only want it to fire on update if the record is being saved with the "Price" topic when it wasn't previously. Anyone have a good idea for that?  I think I am close if I could get that answer.

 

 trigger CreatePriceRequestFromCase on Case (after Insert, after update){List<Request__c> Req =
new List<request__c>();
 
   String  RequestTypeId = Functions.getRecordTypeId( 'Price', 'Request__c' );

 if (trigger.isInsert){
       for (Case newCase: Trigger.New) {        
         if (newCase.Sub_Topic__c == 'Price){
                                    {Req.add(new Request__c(     
                 RecordTypeId = RequestTypeId,
                 Price__c = newCase.Price__c,
                 Case_Number__c = newCase.CaseNumber,
                 Status__c = 'New'));
                         insert Req;}
               

                  }
         }
         }else if (trigger.isUpdate){
                   for (Case newCase2: Trigger.New) {        
                   if (newCase2.Sub_Topic__c == 'Price){
                       {Req.add(new Request__c(     
                         RecordTypeId = RequestTypeId,
                         Price__c = newCase2.Price__c,
                         Case_Number__c = newCase2.CaseNumber,
                         Status__c = 'New'));
                                            
                            insert Req;}
                  }
                }
                }
               
                }

  • April 25, 2012
  • Like
  • 0

I have a apex:dataTable in my apex:page that works great.   I would like to center all of the column headers and some of the data values in the rows. 

 

I tried the following:

   1)  added style="text-align:center;" to the <apex:dataTable tag.   This centers the data rows (or values) but not the column headers.

   2)  added style="text-align:center;" to the apex header like this <apex:column headerValue="Product" style="text-align:center;"> but still does not center header.

  

Thanks in advance :)

As per my requirement i need to integrate salesforce with LiveMeeting Application. can someone help me how to integrate LiveMeeting with salesforce, any material or links? Thanks in Advance

Hi

I have written a controller .and i wrote a testcase for it but i less code cover 

can u please help me. which are in red color in controller the code has not covered...........

Thanks in advances

I am sending controller and testcase

Mycontroller

public class MyChecklist_All

                  {

                 

                  public Opportunity[] opp ;

                  public MyChecklist__c[] chklist{get;set;}

                  public MyChecklist__c[] chklistapprove{get;set;}

                  public MyChecklist__c[] chklistrefuse{get;set;}

                  Set<Id> oppid = new Set<Id>();

                  Public Contact Con {get; set;}

                  Public Account Ac {get; set;}

                 

                  public user u{get;set;}

                  public MyChecklist_All()

                  {

                 

                  u = [Select id,name ,LastName,FirstName,ContactId,Profile.Name from user where id=:UserInfo.getUserId()];

                  Con=[select id,lastname from Contact where id =: u.ContactId];

                  Ac = [select id,lastname from Account where PersonContactId =: con.Id];

                  opp=[select id from Opportunity where Accountid=:ac.id];

                  for(Opportunity aa: opp)

                   {

                   oppid.add(aa.id);

                   }

                  chklist=[select id,Name,Opportunity_Name__r.Account.name,Product_Name__c,Approved_On__c,Category__c,Comments__c,Checklist_Customized_By__c,Status__c from MyChecklist__c where Opportunity_Name__c IN: oppid

                  and Active__c=true];

                 

                  chklistapprove=[select id,Name,Opportunity_Name__r.Account.name,Product_Name__c,Approved_On__c,Category__c,Comments__c,Checklist_Customized_By__c,Status__c from MyChecklist__c where Opportunity_Name__c IN: oppid

                  and Approval_Status__c='Accepted'];

                 

                  chklistrefuse=[select id,Name,Opportunity_Name__r.Account.name,Product_Name__c,Approved_On__c,Category__c,Comments__c,Checklist_Customized_By__c,Status__c from MyChecklist__c where Opportunity_Name__c IN: oppid

                  and Approval_Status__c='Refused'];

                 

                  }

                  }

TEstcase:

@istest
private class MyChecklist_All_Tc
{
static testMethod void validatetest1()
{

Account a = new Account();
a.Name = 'Test Account';
a.BillingState = 'AL';
insert a;

Contact c = new Contact();
c.FirstName = 'Test';
c.LastName = 'Contact';
c.accountid=a.id;
c.Email = 'contactemail@example.com';
insert c;



opportunity o = new opportunity();
o.name='test';
o.StageName='prospecting';
o.CloseDate=date.valueof('2011-10-05');
o.Accountid=a.id;
insert o;


Profile p = [select id from profile where name='Customer Portal Manager Custom'];

User u = new User(alias = 'standt', email='standarduser@testorg.com',
emailencodingkey='UTF-8', lastname='Testing', languagelocalekey='en_US',
localesidkey='en_US', profileid = p.Id, Contactid = c.id,
timezonesidkey='America/Los_Angeles', username='standarduser@testorg.com');
System.runAs(u) {

Account ac = new Account();
ac.Name = 'Test Account';
ac.BillingState = 'AL';
insert ac;

Contact c1 = new Contact();
c1.FirstName = 'Test';
c1.LastName = 'Contact';
c1.accountid=a.id;
c1.Email = 'contactemail@example.com';
insert c1;


opportunity o1 = new opportunity();
o1.name='test';
o1.StageName='prospecting';
o1.CloseDate=date.valueof('2011-10-05');
o1.Accountid=ac.id;
insert o1;
MyChecklist__c m1=new MyChecklist__c();
m1.name='Test';
m1.Opportunity_Name__c=o1.id;
insert m1;

MyChecklist_All s1= new MyChecklist_All();

}
}
}

 

 

 

 


  • April 26, 2012
  • Like
  • 0

Hi,

 

We have an Apex Component(has one Controller attached to it) included in the Visualforce page. We want to get it refreshed when one User lookup is populated on the Visualforce Page. Please suggest if there is a way to accomplish this.

We had tried page reload. But that leads to Data being blanked out on the page. Is there any clean way to do it?

 

Can you help me with the following error msg?

 

Initial term of field expression must be a concrete SObject List

 

trigger ChatterPostSURLStatus on Contract (after update) {

  for(Contract c: Trigger.new){
    CollaborationGroup[] oG = [Select ID, Name from CollaborationGroup];
      if(c.Status == 'Granted' && c.ActivatedDate==Today() && oG.Name == 'Renewal'){
          FeedPost sPost = new FeedPost();
          sPost.ParentId = oG.ID;
          sPost.Body = c.Account && 'is now supported on SURL';
          insert sPost;
          }
    }
}

I'm working on a trigger for the Opportunity object that creates a few child "Commission" records when an opportunity is marked as  "Closed Won". The issue comes from my unit test that reopens and record that was marked as "Closed Won". 

 

Here is the error:

System.DmlException: Update failed. First exception on row 0 with id 006Q0000009MdFOIA0; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [CloseDate]: [CloseDate]

The error occurs on the last update to the opportunity StageName that essentially reopens the deal.  I'm really banging my head against the wall on this one since it's pretty clear I'm setting the CloseDate when I insert the record.

 

//...insert other required records for test

 //create opportunity
Opportunity opportunity = new Opportunity();
opportunity.AccountId = account.Id;
opportunity.OwnerId = ramUser.Id;
opportunity.Name = 'Test Opportunity';
opportunity.StageName = 'First Appointment';
opportunity.RecordTypeId = [SELECT Id FROM RecordType WHERE SObjectType='Opportunity' AND Name='RAM Opportunity'].Id;
opportunity.TotalCash__c = 3000.00; //creates positive revenue so commissions can be calculated
opportunity.CloseDate = system.today();
insert opportunity;

//update opportunity to closed won
opportunity.StageName = 'Closed Won';
update opportunity;

Test.startTest();

//update opportunity again to 'In Processing' - reopen the deal
opportunity.StageName = 'In Processing';
update opportunity;

//...assertions

Test.stopTest();

 Any ideas as to why this may be happening?

Hi all,

 

I have to implement search keyword functionality. 

 

keywords are searched in all the longtext area fields of a object. so I cannot use SOQL, beacuse salesforce does not allow selective soql based on longtext area fields. For this reason I used SOSL, but that is returning 200 records only.

 

Please help me, is there any method to implement search functionality. There are thousands of records. Please help me its urgent.

 

With regards

Palak

  • April 25, 2012
  • Like
  • 0

Hello,

I am new to working with Apex and I have what I suspect is in an easy question. I have a trigger that I have written to create a record on a custom object on Insert or Update of case with a specific topic. The issue I am having (as you would guess) is that it creating a new record everytime the case is updated.  I only want it to fire on update if the record is being saved with the "Price" topic when it wasn't previously. Anyone have a good idea for that?  I think I am close if I could get that answer.

 

 trigger CreatePriceRequestFromCase on Case (after Insert, after update){List<Request__c> Req =
new List<request__c>();
 
   String  RequestTypeId = Functions.getRecordTypeId( 'Price', 'Request__c' );

 if (trigger.isInsert){
       for (Case newCase: Trigger.New) {        
         if (newCase.Sub_Topic__c == 'Price){
                                    {Req.add(new Request__c(     
                 RecordTypeId = RequestTypeId,
                 Price__c = newCase.Price__c,
                 Case_Number__c = newCase.CaseNumber,
                 Status__c = 'New'));
                         insert Req;}
               

                  }
         }
         }else if (trigger.isUpdate){
                   for (Case newCase2: Trigger.New) {        
                   if (newCase2.Sub_Topic__c == 'Price){
                       {Req.add(new Request__c(     
                         RecordTypeId = RequestTypeId,
                         Price__c = newCase2.Price__c,
                         Case_Number__c = newCase2.CaseNumber,
                         Status__c = 'New'));
                                            
                            insert Req;}
                  }
                }
                }
               
                }

  • April 25, 2012
  • Like
  • 0

Hi There,

 

Looking for a little assistance on this trigger.

 

Essentially I am looking to update a hidden field on an opportunity with a line item name.  I am searching for a specific name as the hidden field will then be used in a VF email template.

 

However, I am not exactly sure how to call the product name within the trigger.  I have tried Product2, Name, etc. but I get a compile error message that the "Product2" or "Name" (whatever I seem to choose) is not a column on the entity "OpportunityLineItem".  Do I need to use a name from the pricebook?

 

Thanks to anyone in the community that can provide some assistance.

 

Here is my trigger code:

 

trigger CECProductUpdate on Opportunity (after update, after insert) {

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

    OpportunityLineItem[] OppLI = [Select o.Product2 from
                                      OpportunityLineItem o  where o.Product2 = '[5200] Online Product Course'];
                                      
                                      
    for (OpportunityLineItem CurOppLI : OppLI){

 OpptoUpdate.CEC_Hidden_Product__c = CurOpLI.Product2
    }


   update OpptoUpdate

}


 

  • April 24, 2012
  • Like
  • 0

Displaying Calendar on Visualforce page

  • April 24, 2012
  • Like
  • 0

Dear all,

 

Hoping someone can help here.

 

I am trying to write a trigger and class on Lead Convert to create a couple of custom object records.

 

The thing is I am only hitting 60% of coverage but the tested trigger is not showing in the

 

"Trigger code coverage" part? Any clues?

 

Also can someone help me with trying to achieve 100% please? Been trying for a couple of weeks to get this right now.

Thanks in advance

 

trigger LeadConvert2 on Lead (before update) {
     
      if (Trigger.new.size() == 1) {
      
        if (Trigger.old[0].isConverted == false && Trigger.new[0].isConverted == true) {
  
            if (Trigger.new[0].ConvertedAccountId != null) {

                Account a = [Select a.Id, a.Name, a.Description From Account a Where a.Id = :Trigger.new[0].ConvertedAccountId];
                a.Description = Trigger.new[0].Name;
                a.OwnerId = Trigger.new[0].Sales_ME1__c;
                update a;
 
                    // insert a Sales Monitor Line
                    Line_del__c obj = new Line_del__c();
                    obj.Name = a.Name;
                    obj.Team_s_Dept_s_del__c = Trigger.new[0].Sales_Team__c;
                    obj.ME1__c = Trigger.new[0].Sales_ME1__c;
                    obj.ME2__c = Trigger.new[0].Sales_ME2__c;
                    obj.DTR3__c = Trigger.new[0].Sales_DTR__c; 
                    obj.CU__c = Trigger.new[0].Sales_CU__c;
                    obj.Project_Completion_Date__c = Trigger.new[0].Sales_Project_Completion_Date__c;
                    obj.Division__c = Trigger.new[0].Sales_Division__c; 
                    obj.Utility__c = Trigger.new[0].Sales_Utility__c;
                    obj.Renewal_Acquisition__c = Trigger.new[0].Sales_Acquisition__c;
                    obj.Next_Action_Comments__c = Trigger.new[0].Sales_Next_Action_Comments__c;
                    obj.Notes__c = Trigger.new[0].Sales_Notes__c;                                        
                    obj.Linked_Account__c = a.Id;                    
                    insert obj;
                    
                    // insert a CR Monitor Line
                    if (Trigger.new[0].CR_ME1__c!= Null && Trigger.new[0].CR_DTR__c != Null) {
                    
                    Line_del__c obj2 = new Line_del__c();
                    obj2.Name = a.Name;
                    obj2.Team_s_Dept_s_del__c = 'a0P300000053prk';
                    obj2.ME1__c = Trigger.new[0].CR_ME1__c;
                    obj2.ME2__c = Trigger.new[0].CR_ME2__c;
                    obj2.DTR3__c = Trigger.new[0].CR_DTR__c; 
                    obj2.CU__c = Trigger.new[0].CR_CU__c;
                    obj2.Next_Action_Comments__c = Trigger.new[0].CR_Next_Action_Comments__c;
                    obj2.Notes__c = Trigger.new[0].CR_Notes__c;
                    obj2.Linked_Account__c = a.Id;
                    insert obj2;
                    
                    }
                    }
               }      
        }
 
}



@isTest
Private Class LeadConvert2{
static TestMethod void TestLeadConvert2(){

    Account accts = new Account(
    Name = 'TestCompany',
    OwnerId = '00530000004WakH' );
    insert accts;
    
    Line_del__c salesLine = new Line_del__c(
    Name = 'Test insert new Monitor Line',
    // FF Sales Team 
    Team_s_Dept_s_del__c = 'a0P300000053ps9', 
    ME1__c = '00530000004WakH',
    ME2__c = '00530000005dI0c',  
    DTR3__c = System.Today(),
    CU__c = System.Today(),
    Project_Completion_Date__c = System.Today(),
    Division__c = 'Util-Eyes',
    Utility__c = 'Gas',
    Renewal_Acquisition__c = 'Acquisition', 
    Next_Action_Comments__c = 'Test Next Action Text',
    Notes__c = 'Test Notes Text',
    Linked_Account__c = accts.Id   
    );

    Line_del__c CRLine = new Line_del__c (
    Name = 'Test insert new Monitor Line', 
    // CR Team 
    Team_s_Dept_s_del__c = 'a0P300000053prk', 
    ME1__c = '00530000004WakH', 
    ME2__c = '00530000005dI0c',      
    DTR3__c = System.Today(),
    CU__c = System.Today(),
    Next_Action_Comments__c = 'Test Next Action Text',
    Notes__c = 'Test Notes Text',
    Linked_Account__c = accts.Id   
    );
        
    test.StartTest();
    insert salesLine;
    insert CRLine;
    test.StopTest();
    
    }    
}

Hey! :)

 

I added a ContentDocument trigger via Force.com IDE und wanted to include this trigger in my managed package.

I create a test method that should fire my trigger, which then calls a trigger handler class.

 

Now the problem:

 

Whe I run the test class, I see as a result, that 80-ish% of my trigger handler code has been covered. This means, the trigger did definitely fire!! But I can't see this trigger in the result list.

But the biggest problem is, that the packaging process aborts everytime with the reason, that the ContentDocument trigger has 0% test coverage.

 

I don't know what to do, it just appears to me, that the ContentDocument trigger has not been fully integrated by SFDC?

 

Any help is appreciated!

 

Best Regards,

 

Nisse

I have a apex:dataTable in my apex:page that works great.   I would like to center all of the column headers and some of the data values in the rows. 

 

I tried the following:

   1)  added style="text-align:center;" to the <apex:dataTable tag.   This centers the data rows (or values) but not the column headers.

   2)  added style="text-align:center;" to the apex header like this <apex:column headerValue="Product" style="text-align:center;"> but still does not center header.

  

Thanks in advance :)

Hi,

 

Even though id values are same for pricebook2 id of opportunity and pricebookentry id for opportunity line item. I have verified both the ids by putting debug statements also.

Even I checked the status they are active as I am explicitly inserting isActive=true for test data records.

 

It is strange to know I a getting the below issue:

 "FIELD_INTEGRITY_EXCEPTION, Price Book Entry ID: id value of incorrect type".

 

Can some one please help on this issue?

 

Thanks,

JBabu.

 

  • April 12, 2012
  • Like
  • 0