• bikla78
  • NEWBIE
  • 175 Points
  • Member since 2006

  • Chatter
    Feed
  • 7
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 80
    Questions
  • 121
    Replies
Is there a way to auto-populate the city and state fields based on the zip code entered?

I created a VF page that pulls the related events for a particular contact. This is currently set within the contact page layout. However, how can I make it so that when a user clicks on the subject field it takes them to the event page layout for the event record?

 

 

2
3
4
5
6
7
8
9
10
11
12
13
14
public class ActivityController {
    private final Contact cont;
    public ActivityController(ApexPages.StandardController controller) {
        this.cont = (Contact)controller.getRecord();
    }
    Public Event[] getActivities(){
        return [Select id, subject, what.id, who.id, type, activitydate from Event 
               where whoid=:cont.id ];

    }
    

    

 

 

<apex:page standardController="contact"   extensions="ActivityController">
<apex:pageBlock title="Event History" >
<apex:pageBlockTable value="{!Activities}" var="a">
<apex:column value="{!a.activitydate}" />
<apex:column value="{!a.subject}"/>
<apex:column value="{!a.whoid}"/>
<apex:column value="{!a.whatid}"/>
<apex:column value="{!a.type}"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:page>

I created a trigger that updates the account.status field by checking all opportunities associated with that account. If all opportunities are ended then it will update the account to former client if not, it will change it to current client. This logic works but now I am also trying to update the product associated with all opportunities. An update needs to happen to the product2.status field but I can't  figure out how to tie the opportunity.id  =  opportunitylineitem.opportunityid =opporutnitylineitem.pricebookentryid = pricebookentry.product2id = product2.id

 

My goal is so that if all opportunities associated with that product have a stage = ended then the product2.status would be updated to "Ready to be deployed" but  if at least 1 of those opportunities has stage= in process, then product2.status = 'Deployed" . This should update the product2 once the opportunity is created or updated.

 

As you can see I am using arrays.

 

trigger Opportunity_To_Account on Opportunity (before insert, before update) {

   Opportunity_Management.UpdateAccountStatus(trigger.new);

}

 

//--------------------------------------------------------------------------------------------------------------

// This class is used to automate various steps for Sales Opportunity Management for the CSDs

//--------------------------------------------------------------------------------------------------------------

public class Opportunity_Management

{

   public static void UpdateAccountStatus(Opportunity[] Opp)

    {

        for (Opportunity a:Opp)

        {

        if (a.accountId != null)

        {

            Opportunity[] Opps = null;

            OpportunityLineItem[] OpplineItem = null;

            Integer nEnded = 0;

            Integer nInProcess = 0;

 

           try     

           {

             Opps = [select Id, StageName From Opportunity where AccountId=:a.AccountId];

             Opplineitem = [select OpportunityId, PricebookEntryID From OpportunityLineItem where OpportunityId=:a.Id];

 

             for (Opportunity Opp2 :Opps)

             {

//-----------------------------------------------------------------------------------------------------------------

// When an opportunity stage is ended, it assigns it to the array with variable nEnded. It checks all opportunities

// with this stage for that particular account, (a.id)

//----------------------------------------------------------------------------------------------------------------

                   if (Opp2.Stagename == 'Won-Engagement Ended' && Opp2.Id <> a.Id)

                   {

                       nEnded = nEnded + 1;

//-----------------------------------------------------------------------------------------------------------------------

// When an opportunity stage is in process, it assigns it to the array with variable nInProcess.It checks all opportunities

// with this stage for that particular account, (a.id)

//------------------------------------------------------------------------------------------------------------------------

                   }

                  if (Opp2.Stagename == 'Won-Engagement in Process' &&  Opp2.Id <> a.Id)

                   {

                       nInProcess = nInProcess + 1;

                   }

                 }

 

                 if (a.Stagename == 'Won-Engagement in Process')

                   {

                       nInProcess = nInProcess + 1;

                   }

 

           }

 

           catch(Exception e)

           {

           system.debug(e);

           }

 

 

          Account acct = [select id from Account where Id = :a.accountid];

        // ??  Product2 prod = [select id from Product2 where Id]

 

 

          if (nInProcess > 0)

             {

              acct.Accountstatus__c= 'Current Client - Billing';

              acct.Type = 'Client';

             // ??? prod.status = 'Deployed'

 

 

              }

          if (nEnded > 0  && nInProcess < 1)

              {

              acct.Accountstatus__c= 'Former Client - Not Billing';

              // ??? prod.status = 'Ready to be deployed'

 

              }

           try

           {

            update acct;

            }

 

           catch (System.DmlException e) {

           system.debug(e.getMessage());

 

           }

 

          }

 

        }

 

     }

I created a field called Product2.contact__c which is a lookup against the contact record. I am trying to create a field update that pulls in the contact.consultant_region__C field into the Product2.consultant_region__C field by associating the reference ID in the contact__C field after a Product2 record is saved.  But it keeps saying that the it's incompatible. Can we not reference IDs from a custom field in APEX?

 

Description    Resource    Path    Location    Type
Save error: Incompatible element type Schema.SObjectField for collection of Id    Product_Automation.cls    DLC Sandbox/src/classes    line 12    Force.com save problem

 

public class Product_Automation
{
       public static void UpdateProductContactInfo(Product2[] ProdRec)
        {
           Set<Id> ContIds = new Set<Id>();
           for (Product2 prod : ProdRec)
           {
            ContIds.add(Product2.Contact__c);
           }
            Map<Id,String> ContactInfoMap = new Map<Id, String>();
 
        
 
            for(Contact c: [select id, Consultant_Region__c  from Contact where id IN :ContIds])
            {
               ContactInfoMap.put(c.id, c.Consultant_Region__c );
            }
                    
            for (Product2 c:ProdRec)
            {
                if( c.IsActive = 'True'  && c.consultant_region__c == null)
                {
                   c.consultant_region__c = ContactInfoMap .get(c.Contact__c);

                }
            }
       }      
      
}

This trigger ensures that contacts where contact.contact_type__c = 'Client' can not be deleted. The test case saved and compiled correctly.  When I "run tests" in this test method, I don;t receieve any failures for this test method.

 

Then I went to my trigger and tried to deploy it and it says  0% covered at leas 1% needs to be tested .  Line 3,5,7 and 9 not covered?

// This trigger ensures that client contacts are not deleted in Salesforce. This is a requirement to interface opportunity records into Oracle.
trigger ContactDeleteTrigger on Contact (before delete)
{
    if (Trigger.isDelete) 
    {
        for (Contact c : Trigger.old) 
        {
            if (c.contact_type__c == 'Client') 
            {
                c.contact_type__c.addError('You can not delete a client contact. Please contact your administrator');
            }
        }
    }

  

}

 

 

 

 

@isTest
private class delete_contacts_test
 {
    static testMethod void deleteContact() {
    
        //Create an Account
        Account A1 = new Account( Name = 'TestAccount', Type =  'Prospect', Industry = 'Banking', Physical_Street__c = 'Test Street',Physical_City__c = 'Los Angeles', Physical_State__c = 'CA', Physical_Zip_Postal_Code__c = '90017', Physical_Country__c = 'USA', Phone = '(888) 999-1234'  );
        insert A1;
        
        //Create a Contact, associating it with the above account
        Contact C1 = new Contact(
            FirstName='John',
            LastName='Smith',
            AccountId = A1.id,
            contact_type__c = 'Client',
            mailing_country__c = 'USA',
            mailing_street__c = 'Wilshire',
            mailing_state__c= 'CA',
            mailing_Postal_Code__c ='90017',
            mailing_city__c = 'LA',
            title = 'janitor',
            functional_area__c = 'Finance',
            title_level__c = 'VP',
            Direct_Mail_Status__c ='Do Not Send',
            leadsource = 'Direct Mail'          
            
     );
        insert C1;
        
    //Deleting the above contact causes the trigger to fire
        try { delete C1; }

        catch (System.DMLException e) {
    //verify that you received the correct error message
     //       System.assert(e.getMessage().contains('first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, You can\'t delete this record!'),
     //   e.getMessage());     
        }
    }
}

I have created this visual force page with an APEX controller. However, how can I get the edit link under "Action" next to each record? This is the same "edit" link under activity history on left side of each record. What visual force tag would do this?

Edit

 

Also how can i also put the link that says if there are a certain amount of record under mycustom  task history vf page?

 

<apex:page standardController="contact"   extensions="TaskController">
<apex:pageBlock title="Task History" >
<apex:pageBlockTable value="{!Tasks}" var="t">
<apex:column value="{!t.activitydate}" />
<apex:column value="{!t.subject}"/>
<apex:column value="{!t.whoid}"/>
<apex:column value="{!t.whatid}"/>
<apex:column value="{!t.type}"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:page>

public class TaskController {
    private final Contact cont;
    public TaskController(ApexPages.StandardController controller) {
        this.cont = (Contact)controller.getRecord();
    }
    Public Task[] getTasks(){
        return [Select id, subject, what.id, who.id, type, activitydate from Task
               where whoid=:cont.id ];
    }

}

I am trying to create a trigger that prevents a user from deleting a contact record if contact.contact_type__c = 'Client'.  I keep getting this issue below. What is the null object they are referring to?

 

trigger ContactDeleteTrigger on Contact (before delete)
{
    

    if (Trigger.isDelete) {


        for (Contact c : Trigger.new) {
            if (c.contact_type__c != 'Client') {
                c.addError('You can\'t delete this record!');
            }
        }
    }
}
ContactDeleteTrigger: execution of BeforeDelete

caused by: System.NullPointerException: Attempt to de-reference a null object

Trigger.ContactDeleteTrigger: line 8, column 26

Hey guys,

 

Has anyone here used the dupe blocker? We are currently using it and it's working well for us. We performed a recent update (100 companies) using the dataloader and noticed that dupe warnings were created. Currently we have all the warnings being assigned to the administrator(me) until we get  the user trained.

 

We were thinking of setting dupe blocker batch size to 1 and then updating all your records in Salesforce to trigger all warning and place it on a dashboard-- essentially this would automate all our cleaninng efforts

 

We have been informed that there is a limt API calls allowedi by Salesforce in a 24 hr period and the resulting warnings will take up storage and need to be acted on one by one to merge-however we are okay with this since we plan on exporting all the warning out while we clean up the system

 

is there a technical concerns here? I think it should be fine since APEX governour limits essentially shields our system from making to many soql query calls. Not sure how the dupe blocker is built but its probably based on after update triggers that create a wanring(a task on each record) that violates the constraint in APEX(It's packaged so we can't see it)

 

Thoughts?

If current reminders for tasks are turned off, is there a way we can create a popo up reminder for certain types of tasks through VF or apex
Does anyone know how I can make an account read only if the a related task is not completed? If it is completed then the user would be able to edit the account again.

I have created this that updates a field that is associated with the whatID. It updates athe candidate status in the caniddate object based on a field that is inserted or updated in the event.event_type__C field.

 

Event.whatid = sfdc_candidate__C.ID

 

 

I am receiving a limit. How can I get this done with a list.

 

 

public class Event_WorkFlow_Manager

   {

   public static void UpdateCandidateStatus(Event[] EvRec) {

     Profile PR = [Select Name from Profile where Id = '00e60000000updM'];

     for (Event a:EvRec)

            {

         if (a.Subject != 'Sales Meeting' && a.type ==null)

         { 


     

      Integer i = [select count() from SFDC_Candidate__c where Id = :a.WhatId];

        if (PR.Name == 'DLC_Recruit_Test' && a.WhatId != null && i > 0) {

           SFDC_Candidate__c cand = [

           select Id, Contact__c, Name, (Select Id From Events where Id = :a.Id)

           from SFDC_Candidate__c

           where Id = :a.WhatId

         ];



         // Offer Accepted workflow method to update Candidate Status



          if (a.Event_Type__c == '1 - Qualified Profile') {

                a.subject = 'Qualified Profile';

                cand.Candidate_Status__c = 'Qualified';

                cand.Candidate_Withdrew__c = a.Candidate_Withdrew__c;

                cand.Start_Date_Current_Company__c = a.Start_Date__c;

               cand.Candidate_Rejected__c = a.Candidate_Rejected__c ;

               cand.Offer_Not_Extended__c= a.Offer_Not_Extended__c;

               cand.Offer_Declined__c = a.Offer_Declined__c ;

               cand.Fall_Off__c = a.Fall_Off__c;

           try {

             update cand;


           }

Message Edited by bikla78 on 02-05-2010 04:48 PM

i have created this vf page. How can I create a hyperlink so that when they click on subject, it takes them to the event record

 

<apex:page standardController="contact"   extensions="ActivityController">
<apex:pageBlock title="Event History" >
<apex:pageBlockTable value="{!Activities}" var="a">
<apex:column value="{!a.activitydate}" />
<apex:column value="{!a.subject}"/>
<apex:column value="{!a.whoid}"/>
<apex:column value="{!a.whatid}"/>
<apex:column value="{!a.type}"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:page>

 

I have created some custom links on the homepage so that the users can hyperlink to a certain user's calendar for the current month. Each month, I have to manually update the links . I do this on the last Friday of each month to show the next month. I basically go in and change the link. Is there a way I can automate this in APEX so it looks at the system date and the link date?

 

 for example:

 

https://na4.salesforce.com/00U/c?cType=1&cal_lkid=00530000000d0Uz&md0=2009&md1=3

 

https://na4.salesforce.com/00U/c?cType=1&cal_lkid=00530000000d0Uz&md0=2009&md1=4

I have an after insert trigger on my event object the sends an outbound email to the event.whoid.email.  How can I run apex trigger 2 days before event date and once again a day before the event date? The purpose is to remind the contact associated with the event that the meeting will be happening..kinda like an outlook reminder

 

 

The name of thetigger is ConsultantNotification

When I launch Eclipse IDE i receive the error:

 

 Incompatible JVM

 

Version 1.4.2_04 of the JVM is not suitable for this product. Version:1.5 or greater is required.

 

I installed all JDK versions and reinstalled as high as 6 but I still get this errror. Any ideas would be greatly appreciated

I a getting a strange error. I am performing insert using the apex dataloader. However, I am receiving a before update exception? Does anyone now why an update exception would show up when I am inserting new records?

 

 

Event_To_Cand_Status: execution of BeforeUpdate

caused by: System.Exception: Too many SOQL queries: 21

Class.Event_WorkFlow_Manager.UpdateCandidateStatus: line 4, column 19
Trigger.Event_To_Cand_Status: line 2, column 1

This trigger checks that a contact with the same first and last is not saved in the database with the same accountid.  This works well but has anyone written any APEX with regular expressions in regard to duplicate record prevention? I was thinking it could check for LIKE name matches as well

 

Stephen Smith would be same as

Steve Smith

Steeeve Smith

Seve Smith

Steve Smit

 

etc...

 

I think alot of you guys will appreciate this post since duplicate record prevention is so common today


trigger ContactDuplicateTrigger on Contact (before insert) {
   for (Contact c : Trigger.new){
      
      Contact[] contacts= [select id from Contact where FirstName = :c.FirstName and LastName = :c.LastName and accountid = :c.accountid];
      
      if (contacts.size() > 0) {
          c.LastName.addError(' Contact already exists with this company');
      }    
   }
}

 

I have a custom report that was built in the reports tab. Is there anyway I can schedule the printable view of the report as a web html file and schedule an export it to a location on my hard drive.

I created a custom link in the contact page layout for this. However, it doesn't seem to be pulling all activities associated with the contactid on the current page. I should get like over 10 events that meet this criteria but it only brings displays 2.  Something is wrong with my statement in red

 

<apex:page controller="ActivityController">
<apex:pageBlock >
<apex:pageBlockTable value="{!Activities}" var="a">
<apex:column value="{!a.subject}"/>
<apex:column value="{!a.type}"/>
<apex:column value="{!a.owner.name}"/>
<apex:column value="{!a.who.name}"/>
<apex:column value="{!a.what.name}"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:page>




public class ActivityController
{
    Public Event[] getActivities()
    {
      string currId =ApexPages.currentPage().getParameters().get('id');
       return [Select id, subject, what.id, who.id, type, activitydate from Event
               where whoid=: currid and type= 'Client Meeting (Event)'];

    }



 
}

Message Edited by bikla78 on 10-07-2009 03:48 PM

When a product2 record is inserted the product2.payrate should  insert or update the pricebookentry.unitprice field with the custom calculation and assign  01s300000000EfuAAE pricebookentry.pricebook2id

pricebookentry.unitprice =     product2.payrate / .90 *  2.5 + 5 and rounded to the nearest 5 dollars

I have started this but having issues with it with associating the objects

 
trigger Product_Before_Insert_Update on Product2 (before insert) {
    
    sObject s = [select , payrate__cID from Pricebook2 where id = '01s300000000EfuAAE'];

    for (Product2 newProduct: Trigger.new) {

     double billrate = payrate / .90 * 2.5 + 5;

    PricebookEntry z = new PricebookEntry(Pricebook2Id=s.ID,Product2Id=newProduct.ID, UnitPrice=billrate, IsActive=TRUE, UseStandardPrice=FALSE);
    insert z;
     
      
    }


Message Edited by bikla78 on 09-30-2009 05:01 PM
  • September 30, 2009
  • Like
  • 0

Guys,

we have an issue with a deactivtaed user and is there a way I can pull a query from the system that show recent reports (time date and stamp)that were exported from salesforce for a particular user? is there anyway this can be done without contacting Salesforce?

  • September 24, 2009
  • Like
  • 0

I created a VF page that pulls the related events for a particular contact. This is currently set within the contact page layout. However, how can I make it so that when a user clicks on the subject field it takes them to the event page layout for the event record?

 

 

2
3
4
5
6
7
8
9
10
11
12
13
14
public class ActivityController {
    private final Contact cont;
    public ActivityController(ApexPages.StandardController controller) {
        this.cont = (Contact)controller.getRecord();
    }
    Public Event[] getActivities(){
        return [Select id, subject, what.id, who.id, type, activitydate from Event 
               where whoid=:cont.id ];

    }
    

    

 

 

<apex:page standardController="contact"   extensions="ActivityController">
<apex:pageBlock title="Event History" >
<apex:pageBlockTable value="{!Activities}" var="a">
<apex:column value="{!a.activitydate}" />
<apex:column value="{!a.subject}"/>
<apex:column value="{!a.whoid}"/>
<apex:column value="{!a.whatid}"/>
<apex:column value="{!a.type}"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:page>

I created a trigger that updates the account.status field by checking all opportunities associated with that account. If all opportunities are ended then it will update the account to former client if not, it will change it to current client. This logic works but now I am also trying to update the product associated with all opportunities. An update needs to happen to the product2.status field but I can't  figure out how to tie the opportunity.id  =  opportunitylineitem.opportunityid =opporutnitylineitem.pricebookentryid = pricebookentry.product2id = product2.id

 

My goal is so that if all opportunities associated with that product have a stage = ended then the product2.status would be updated to "Ready to be deployed" but  if at least 1 of those opportunities has stage= in process, then product2.status = 'Deployed" . This should update the product2 once the opportunity is created or updated.

 

As you can see I am using arrays.

 

trigger Opportunity_To_Account on Opportunity (before insert, before update) {

   Opportunity_Management.UpdateAccountStatus(trigger.new);

}

 

//--------------------------------------------------------------------------------------------------------------

// This class is used to automate various steps for Sales Opportunity Management for the CSDs

//--------------------------------------------------------------------------------------------------------------

public class Opportunity_Management

{

   public static void UpdateAccountStatus(Opportunity[] Opp)

    {

        for (Opportunity a:Opp)

        {

        if (a.accountId != null)

        {

            Opportunity[] Opps = null;

            OpportunityLineItem[] OpplineItem = null;

            Integer nEnded = 0;

            Integer nInProcess = 0;

 

           try     

           {

             Opps = [select Id, StageName From Opportunity where AccountId=:a.AccountId];

             Opplineitem = [select OpportunityId, PricebookEntryID From OpportunityLineItem where OpportunityId=:a.Id];

 

             for (Opportunity Opp2 :Opps)

             {

//-----------------------------------------------------------------------------------------------------------------

// When an opportunity stage is ended, it assigns it to the array with variable nEnded. It checks all opportunities

// with this stage for that particular account, (a.id)

//----------------------------------------------------------------------------------------------------------------

                   if (Opp2.Stagename == 'Won-Engagement Ended' && Opp2.Id <> a.Id)

                   {

                       nEnded = nEnded + 1;

//-----------------------------------------------------------------------------------------------------------------------

// When an opportunity stage is in process, it assigns it to the array with variable nInProcess.It checks all opportunities

// with this stage for that particular account, (a.id)

//------------------------------------------------------------------------------------------------------------------------

                   }

                  if (Opp2.Stagename == 'Won-Engagement in Process' &&  Opp2.Id <> a.Id)

                   {

                       nInProcess = nInProcess + 1;

                   }

                 }

 

                 if (a.Stagename == 'Won-Engagement in Process')

                   {

                       nInProcess = nInProcess + 1;

                   }

 

           }

 

           catch(Exception e)

           {

           system.debug(e);

           }

 

 

          Account acct = [select id from Account where Id = :a.accountid];

        // ??  Product2 prod = [select id from Product2 where Id]

 

 

          if (nInProcess > 0)

             {

              acct.Accountstatus__c= 'Current Client - Billing';

              acct.Type = 'Client';

             // ??? prod.status = 'Deployed'

 

 

              }

          if (nEnded > 0  && nInProcess < 1)

              {

              acct.Accountstatus__c= 'Former Client - Not Billing';

              // ??? prod.status = 'Ready to be deployed'

 

              }

           try

           {

            update acct;

            }

 

           catch (System.DmlException e) {

           system.debug(e.getMessage());

 

           }

 

          }

 

        }

 

     }

This trigger ensures that contacts where contact.contact_type__c = 'Client' can not be deleted. The test case saved and compiled correctly.  When I "run tests" in this test method, I don;t receieve any failures for this test method.

 

Then I went to my trigger and tried to deploy it and it says  0% covered at leas 1% needs to be tested .  Line 3,5,7 and 9 not covered?

// This trigger ensures that client contacts are not deleted in Salesforce. This is a requirement to interface opportunity records into Oracle.
trigger ContactDeleteTrigger on Contact (before delete)
{
    if (Trigger.isDelete) 
    {
        for (Contact c : Trigger.old) 
        {
            if (c.contact_type__c == 'Client') 
            {
                c.contact_type__c.addError('You can not delete a client contact. Please contact your administrator');
            }
        }
    }

  

}

 

 

 

 

@isTest
private class delete_contacts_test
 {
    static testMethod void deleteContact() {
    
        //Create an Account
        Account A1 = new Account( Name = 'TestAccount', Type =  'Prospect', Industry = 'Banking', Physical_Street__c = 'Test Street',Physical_City__c = 'Los Angeles', Physical_State__c = 'CA', Physical_Zip_Postal_Code__c = '90017', Physical_Country__c = 'USA', Phone = '(888) 999-1234'  );
        insert A1;
        
        //Create a Contact, associating it with the above account
        Contact C1 = new Contact(
            FirstName='John',
            LastName='Smith',
            AccountId = A1.id,
            contact_type__c = 'Client',
            mailing_country__c = 'USA',
            mailing_street__c = 'Wilshire',
            mailing_state__c= 'CA',
            mailing_Postal_Code__c ='90017',
            mailing_city__c = 'LA',
            title = 'janitor',
            functional_area__c = 'Finance',
            title_level__c = 'VP',
            Direct_Mail_Status__c ='Do Not Send',
            leadsource = 'Direct Mail'          
            
     );
        insert C1;
        
    //Deleting the above contact causes the trigger to fire
        try { delete C1; }

        catch (System.DMLException e) {
    //verify that you received the correct error message
     //       System.assert(e.getMessage().contains('first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, You can\'t delete this record!'),
     //   e.getMessage());     
        }
    }
}

I have created this visual force page with an APEX controller. However, how can I get the edit link under "Action" next to each record? This is the same "edit" link under activity history on left side of each record. What visual force tag would do this?

Edit

 

Also how can i also put the link that says if there are a certain amount of record under mycustom  task history vf page?

 

<apex:page standardController="contact"   extensions="TaskController">
<apex:pageBlock title="Task History" >
<apex:pageBlockTable value="{!Tasks}" var="t">
<apex:column value="{!t.activitydate}" />
<apex:column value="{!t.subject}"/>
<apex:column value="{!t.whoid}"/>
<apex:column value="{!t.whatid}"/>
<apex:column value="{!t.type}"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:page>

public class TaskController {
    private final Contact cont;
    public TaskController(ApexPages.StandardController controller) {
        this.cont = (Contact)controller.getRecord();
    }
    Public Task[] getTasks(){
        return [Select id, subject, what.id, who.id, type, activitydate from Task
               where whoid=:cont.id ];
    }

}

I am trying to create a trigger that prevents a user from deleting a contact record if contact.contact_type__c = 'Client'.  I keep getting this issue below. What is the null object they are referring to?

 

trigger ContactDeleteTrigger on Contact (before delete)
{
    

    if (Trigger.isDelete) {


        for (Contact c : Trigger.new) {
            if (c.contact_type__c != 'Client') {
                c.addError('You can\'t delete this record!');
            }
        }
    }
}
ContactDeleteTrigger: execution of BeforeDelete

caused by: System.NullPointerException: Attempt to de-reference a null object

Trigger.ContactDeleteTrigger: line 8, column 26
Does anyone know how I can make an account read only if the a related task is not completed? If it is completed then the user would be able to edit the account again.
Is there a way to auto-populate the city and state fields based on the zip code entered?

I have created some custom links on the homepage so that the users can hyperlink to a certain user's calendar for the current month. Each month, I have to manually update the links . I do this on the last Friday of each month to show the next month. I basically go in and change the link. Is there a way I can automate this in APEX so it looks at the system date and the link date?

 

 for example:

 

https://na4.salesforce.com/00U/c?cType=1&cal_lkid=00530000000d0Uz&md0=2009&md1=3

 

https://na4.salesforce.com/00U/c?cType=1&cal_lkid=00530000000d0Uz&md0=2009&md1=4

scheduledApexClassName m = newscheduledApexClassName();

//Seconds Minutes Hours Day_of_monthMonth Day_of_week optional_year

String sch = '0 10,20,30,40,50 * * 11 ?2009';

system.schedule('Registration Report', sch, m);

 

Read more at http://www.chiragmehta.info/chirag/2009/11/12/salesforce-schedule-apex-to-run-at-any-time-interval/

 

 

I a getting a strange error. I am performing insert using the apex dataloader. However, I am receiving a before update exception? Does anyone now why an update exception would show up when I am inserting new records?

 

 

Event_To_Cand_Status: execution of BeforeUpdate

caused by: System.Exception: Too many SOQL queries: 21

Class.Event_WorkFlow_Manager.UpdateCandidateStatus: line 4, column 19
Trigger.Event_To_Cand_Status: line 2, column 1



I have built a controller and apex page that is supposed to display all meetings associated with the contact on the current page where the meeting type is a "Client- Event Meeting".  Good news is my page shows up but  I have 3 issues

 

   1. How come the contact name and company name does not appear when I have it referenced in my APEX tag.
  

   2. How can I have this behave the same way as related list objectso that when I click on subject, name or company it takes me

        directly to the object like a standard hyperlink
 

   3. How can I add this Visualforce page as a button on the contact page called “Client Meetings” so that when someone

      go to the John Do contact record, and they click this button, it will display all the events associated with him in the current page

 

This is my first real VF page assignment so please bare with me

 

 

<apex:page controller="ActivityController">
<apex:pageBlock >
<apex:pageBlockTable value="{!Activities}" var="a">
<apex:column value="{!a.subject}"/>
<apex:column value="{!a.type}"/>
<apex:column value="{!a.owner.name}"/>
<apex:column value="{!a.who.name}"/>
<apex:column value="{!a.what.name}"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:page>

 

public class ActivityController 
{
Public Event[] getActivities()
{
return [Select id, subject, what.name, who.name, type, activitydate,owner.name from Event
where whoid = :System.currentPageReference().getParameters().get('id')and type = 'Client Meeting (Event)'];
}




}

Message Edited by bikla78 on 07-14-2009 11:19 PM
Message Edited by bikla78 on 07-14-2009 11:19 PM