• fourfourfun
  • NEWBIE
  • 70 Points
  • Member since 2013

  • Chatter
    Feed
  • 2
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 21
    Questions
  • 43
    Replies
Hi,

I'm looking to display a table in the home page for one subset of users, I'd like it to display a list of activities (these are stored in a custom object) they did last week. 

Does anyone have a nice guide or a blog which might point me in the right direction to help me make this? I'm assuming it would be rather straightforward. Doesn't necessarily have to be a table of results, if anyone has any other ideas with a bit of flair, I'm more than open to some solutions.

Trying to do a simple swap to replace an SOQL statement in my Apex with something that is generated from a string.

Here is what I'm looking at:

String AccountSOQLString = 'Select ownerid from account where ownerid=:search.ownerid'
//		List<Account> ownerAccs = Database.query(AccountSOQLString);

The above does not work.

		List<Account> ownerAccs = [Select ownerid from account where ownerid=:search.ownerid];

This does work.

The aim is to eventually have the string built up with a series of IF statements (which in itself is another sticking point it seems).

I'll start with the current sticking point though, any help?


Trying to alter some SOQL in my environment to filter on Account Owner rather than Contact Owner. Now I'm used to SQL and find SOQL maddening as I am not fully to grips with the syntax to do things I would find matter of fact in SQL. Here is what I have:

allcontacts=[select id, firstname, lastname, speciality__c, account.name, pcm_contact_type__c, account.ownerid, account.shippingpostalcode, account.target_account__c 
                           from contact 
                           where
                           Id not in (select contact__c from PCM_Activity_Attendee__c where PCM_Activity__c=:stdCtrl.getId())
                           and firstname like :'%' + search.firstname + '%'
                           and lastname like :'%' + search.lastname + '%'
                           and (pcm_contact_type__c like :search.pcm_contact_type__c+ '%' )
                           and account.name like :'%' + search.department + '%'           
                           and account.shippingpostalcode like :'%' + search.MailingPostalCode + '%'
                           and account.ownerid not in (select account.ownerid from account where account.ownerid=:search.profession__c)
                           and Account.RecordTypeId = '01230000000Y77V'
                           order by account.name asc, lastname, firstname
                           limit 50];
It is the bolded line that is the issue. 

If anyone can point out the logic to me so I can learn from this, that would be great!

Under setup --> Develop --> Appex Classes there is no "New" button please see the image below.
User-added image

I have clicked on developer console then in developer console window File --> New --> Appex Class
Give the new class name but when click on create button get the following error.

User-added image

Please help me how can i fix this so that i can create my custom controller class.
Thanks in advance.
Is there a way of doing this? I've got a controller that has some features that are taking AGES to run now. Would be nice to see how / why it is getting hung up.

Got some stuff where buttons add/delete contacts to a record but for some reason they are taking ages to do so.
Just curious. I just slapped in a clause in validation to bypass all the rules, essentialy to let bulk data updates by system admins to change records whether or not there are rules there.

How would this apply for Apex triggers? What would they run as? The code creator? I'd love to put a piece of code into Salesforce but I don't want to get spammed by errors when I do bulk updates that trigger it.
Trying to poll some opinion here. Got a standard VF page that I am quickly trying to uplift to be decent on Salesforce1. This document looks promising:

http://www.salesforce.com/us/developer/docs/salesforce1/Content/vf_dev_best_practices_approaches_mixed.htm

Now. It goes to great lengths to say what not to use in terms of pageBlock and pageBlockSection (which I have in my code that was inhereted), but what on earth are you meant to use in its stead? <div> etc?

For someone who isn't really an HTML head, it would be nice to have a little leg up.

Hi,

 

Got two objects. When saving on one, a trigger creates a bunch on the other referecing back with a lookup. When I delete from the former, I want it to delete everything that it created when saving.

 

This is what I have so far:

 

trigger CleanRelatedPCMActivities on Week__c (before delete) 

{
set<id> setActIds = Trigger.newmap.keySet();
 
//query for related Activities
 
list<PCM_Time_Record__c> ActivityRecords = [select Id from PCM_Time_Record__c where Weekly_Time__c in:setActIds];
if(ActivityRecords.size() > 0)
delete ActivityRecords;
}

Theory sounds good. Before deleting, set the ID of what you are deleting. Then query in the other object to find what it is related to, deleting whatever is found.

 

This is giving me this error though:

 

execution of BeforeDelete caused by: System.NullPointerException: Attempt to de-reference a null object: Trigger.CleanRelatedPCMActivities: line 4, column 1"

 

Anyone got a pointer on where I may have gone wrong?

Got a Q about Salesforce 1 - one of the things I really want to roll out to the users is a streamlined mobile version of their processes. One of these involves a Visualforce page that was developed for us.

Navigating to this on the mobile displays the page more in line with desktop Salesforce (i.e not really designed for form factor, no nice calendar pop up, very much not for mobile). How can I get in and start changing things to look different on mobile?

Hi, 

 

I have an established piece of code. What it is doing is writing, on save, from one record (week__c) in an object, and creating/updating a series of records in another one (PCM_Time_Record__c).

 

The only bugbear is that it is writing the other records as whoever is triggering the Apex. I need it to assign the written records as the owner of the source.

 

The code looks like this:

 

 List<PCM_Time_Record__c> insertBlocks = new List<PCM_Time_Record__c>
     {new PCM_Time_Record__c(Time_Block_Name__c='Monday AM1', Type__c=week.Monday_AM1__c,      Date__c=week.Week_Commencing__c, Weekly_Time__c = week.Id,RecordTypeId=recordTypeId, Duration_hours__c=hours, Proportion_Of_Day__c=0.25),

 

As you can see, it is doing a simple create.

 

 

I assumed it was as simple as adding another clause to the bracket that said OwnerID = week__c.OwnerID, but that is throwing up an "Expect ID error".

 

 

 

Here is the full trigger in case anyone needs it:

 

 

trigger createTimeBlocks on Week__c (after insert, after update) {
   
    //hours in the day, split into quarters
    decimal hours = 7.5/4;
    String recordTypeId = [Select Id from RecordType where Name = 'Time Block' and SobjectType = 'PCM_Time_Record__c' limit 1].id;
    PCM_Time_Record__c timeBlock;
        
    for (Week__c week : Trigger.new)
    {
     //For each week record being saved
     if(Trigger.isUpdate)
     {
        //If the Week record has been saved previously, then check for existing timeBlocks. These should also exist.
        List<PCM_Time_Record__c> timeBlocks = [select id from PCM_Time_Record__c where Weekly_Time__c = :week.Id];
        if(!timeBlocks.isEmpty())
        {
            delete timeBlocks;
        }   

     }
     //Create timeblocks.
     List<PCM_Time_Record__c> insertBlocks = new List<PCM_Time_Record__c>
        {new PCM_Time_Record__c(Time_Block_Name__c='Monday AM1', Type__c=week.Monday_AM1__c, Date__c=week.Week_Commencing__c, Weekly_Time__c = week.Id,RecordTypeId=recordTypeId, Duration_hours__c=hours, Proportion_Of_Day__c=0.25),
         new PCM_Time_Record__c(Time_Block_Name__c='Monday AM2', Type__c=week.Monday_AM2__c, Date__c=week.Week_Commencing__c, Weekly_Time__c = week.Id,RecordTypeId=recordTypeId, Duration_hours__c=hours, Proportion_Of_Day__c=0.25),
         new PCM_Time_Record__c(Time_Block_Name__c='Monday PM1', Type__c=week.Monday_AM2__c, Date__c=week.Week_Commencing__c, Weekly_Time__c = week.Id,RecordTypeId=recordTypeId, Duration_hours__c=hours, Proportion_Of_Day__c=0.25),
         new PCM_Time_Record__c(Time_Block_Name__c='Monday PM2', Type__c=week.Monday_AM2__c, Date__c=week.Week_Commencing__c, Weekly_Time__c = week.Id,RecordTypeId=recordTypeId, Duration_hours__c=hours, Proportion_Of_Day__c=0.25),
         new PCM_Time_Record__c(Time_Block_Name__c='Tuesday AM1', Type__c=week.Tuesday_AM1__c, Date__c=week.Week_Commencing__c+1, Weekly_Time__c = week.Id,RecordTypeId=recordTypeId, Duration_hours__c=hours, Proportion_Of_Day__c=0.25),
         new PCM_Time_Record__c(Time_Block_Name__c='Tuesday AM2', Type__c=week.Tuesday_AM2__c, Date__c=week.Week_Commencing__c+1, Weekly_Time__c = week.Id,RecordTypeId=recordTypeId, Duration_hours__c=hours, Proportion_Of_Day__c=0.25),
         new PCM_Time_Record__c(Time_Block_Name__c='Tuesday PM1', Type__c=week.Tuesday_PM1__c, Date__c=week.Week_Commencing__c+1, Weekly_Time__c = week.Id,RecordTypeId=recordTypeId, Duration_hours__c=hours, Proportion_Of_Day__c=0.25),
         new PCM_Time_Record__c(Time_Block_Name__c='Tuesday PM2', Type__c=week.Tuesday_PM2__c, Date__c=week.Week_Commencing__c+1, Weekly_Time__c = week.Id,RecordTypeId=recordTypeId, Duration_hours__c=hours, Proportion_Of_Day__c=0.25),
         new PCM_Time_Record__c(Time_Block_Name__c='Wednesday AM1', Type__c=week.Wednesday_AM1__c, Date__c=week.Week_Commencing__c+2, Weekly_Time__c = week.Id,RecordTypeId=recordTypeId, Duration_hours__c=hours, Proportion_Of_Day__c=0.25),
         new PCM_Time_Record__c(Time_Block_Name__c='Wednesday AM2', Type__c=week.Wednesday_AM2__c, Date__c=week.Week_Commencing__c+2, Weekly_Time__c = week.Id,RecordTypeId=recordTypeId, Duration_hours__c=hours, Proportion_Of_Day__c=0.25),
         new PCM_Time_Record__c(Time_Block_Name__c='Wednesday PM1', Type__c=week.Wednesday_PM1__c, Date__c=week.Week_Commencing__c+2, Weekly_Time__c = week.Id,RecordTypeId=recordTypeId, Duration_hours__c=hours, Proportion_Of_Day__c=0.25),
         new PCM_Time_Record__c(Time_Block_Name__c='Wednesday PM2', Type__c=week.Wednesday_PM2__c, Date__c=week.Week_Commencing__c+2, Weekly_Time__c = week.Id,RecordTypeId=recordTypeId, Duration_hours__c=hours, Proportion_Of_Day__c=0.25),
         new PCM_Time_Record__c(Time_Block_Name__c='Thursday AM1', Type__c=week.Thursday_AM1__c, Date__c=week.Week_Commencing__c+3, Weekly_Time__c = week.Id,RecordTypeId=recordTypeId, Duration_hours__c=hours, Proportion_Of_Day__c=0.25),
         new PCM_Time_Record__c(Time_Block_Name__c='Thursday AM2', Type__c=week.Thursday_AM2__c, Date__c=week.Week_Commencing__c+3, Weekly_Time__c = week.Id,RecordTypeId=recordTypeId, Duration_hours__c=hours, Proportion_Of_Day__c=0.25),
         new PCM_Time_Record__c(Time_Block_Name__c='Thursday PM1', Type__c=week.Thursday_PM1__c, Date__c=week.Week_Commencing__c+3, Weekly_Time__c = week.Id,RecordTypeId=recordTypeId, Duration_hours__c=hours, Proportion_Of_Day__c=0.25),
         new PCM_Time_Record__c(Time_Block_Name__c='Thursday PM2', Type__c=week.Thursday_PM2__c, Date__c=week.Week_Commencing__c+3, Weekly_Time__c = week.Id,RecordTypeId=recordTypeId, Duration_hours__c=hours, Proportion_Of_Day__c=0.25),
         new PCM_Time_Record__c(Time_Block_Name__c='Friday AM1', Type__c=week.Friday_AM1__c, Date__c=week.Week_Commencing__c+4, Weekly_Time__c = week.Id,RecordTypeId=recordTypeId, Duration_hours__c=hours, Proportion_Of_Day__c=0.25),
         new PCM_Time_Record__c(Time_Block_Name__c='Friday AM2', Type__c=week.Friday_AM2__c, Date__c=week.Week_Commencing__c+4, Weekly_Time__c = week.Id,RecordTypeId=recordTypeId, Duration_hours__c=hours, Proportion_Of_Day__c=0.25),
         new PCM_Time_Record__c(Time_Block_Name__c='Friday PM1', Type__c=week.Friday_PM1__c, Date__c=week.Week_Commencing__c+4, Weekly_Time__c = week.Id,RecordTypeId=recordTypeId, Duration_hours__c=hours, Proportion_Of_Day__c=0.25),
         new PCM_Time_Record__c(Time_Block_Name__c='Friday PM2', Type__c=week.Friday_PM2__c, Date__c=week.Week_Commencing__c+4, Weekly_Time__c = week.Id,RecordTypeId=recordTypeId, Duration_hours__c=hours, Proportion_Of_Day__c=0.25),
         new PCM_Time_Record__c(Time_Block_Name__c='Saturday AM1', Type__c=week.Saturday_AM1__c, Date__c=week.Week_Commencing__c+5, Weekly_Time__c = week.Id,RecordTypeId=recordTypeId, Duration_hours__c=hours, Proportion_Of_Day__c=0.25),
         new PCM_Time_Record__c(Time_Block_Name__c='Saturday AM2', Type__c=week.Saturday_AM2__c, Date__c=week.Week_Commencing__c+5, Weekly_Time__c = week.Id,RecordTypeId=recordTypeId, Duration_hours__c=hours, Proportion_Of_Day__c=0.25),
         new PCM_Time_Record__c(Time_Block_Name__c='Saturday PM1', Type__c=week.Saturday_PM1__c, Date__c=week.Week_Commencing__c+5, Weekly_Time__c = week.Id,RecordTypeId=recordTypeId, Duration_hours__c=hours, Proportion_Of_Day__c=0.25),
         new PCM_Time_Record__c(Time_Block_Name__c='Saturday PM2', Type__c=week.Saturday_PM2__c, Date__c=week.Week_Commencing__c+5, Weekly_Time__c = week.Id,RecordTypeId=recordTypeId, Duration_hours__c=hours, Proportion_Of_Day__c=0.25),
         new PCM_Time_Record__c(Time_Block_Name__c='Sunday AM1', Type__c=week.Sunday_AM2__c, Date__c=week.Week_Commencing__c+6, Weekly_Time__c = week.Id,RecordTypeId=recordTypeId, Duration_hours__c=hours, Proportion_Of_Day__c=0.25),
         new PCM_Time_Record__c(Time_Block_Name__c='Sunday AM2', Type__c=week.Sunday_AM2__c, Date__c=week.Week_Commencing__c+6, Weekly_Time__c = week.Id,RecordTypeId=recordTypeId, Duration_hours__c=hours, Proportion_Of_Day__c=0.25),
         new PCM_Time_Record__c(Time_Block_Name__c='Sunday PM1', Type__c=week.Sunday_AM2__c, Date__c=week.Week_Commencing__c+6, Weekly_Time__c = week.Id,RecordTypeId=recordTypeId, Duration_hours__c=hours, Proportion_Of_Day__c=0.25),  
         new PCM_Time_Record__c(Time_Block_Name__c='Sunday PM2', Type__c=week.Sunday_PM2__c, Date__c=week.Week_Commencing__c+6, Weekly_Time__c = week.Id,RecordTypeId=recordTypeId, Duration_hours__c=hours, Proportion_Of_Day__c=0.25)
        };
     insert insertBlocks;
    }
}

 

 

Thanks for any help!

I have a visualforce page.

 

It has four buttons on it:

 

Save

Close

 

and in a section which has a few free text fields

 

Search 

Clear

 

Essentially it is a custom designed search function which adds contacts to a record based on the parameters placed in the free text fields.

 

The issue is, you need to press the search button to search. The natural thing to do is to enter your search term and press enter. This is either closing or saving the record. Once the user presses back to get back to the search screen, it actually causes a new record to be saved when they complete. The result being that lots of empty records get created.

 

Of course user education is one thing, but is there a way to make the focus shift from Save or Close down to Search?

 

Thanks,

Hi..

 

I need a trigger which will work anytime the Account Owner changes, update all Account Contacts to that same Owner as their related Account.

 

So I created a trigger..Which doesn't work..To test it i created a account with two contacts .So i get contact owner same as account owner.i manually changed one contact owner to another user

So my account owner ,contact1 owner are user1 and contact 2 owner is user2

 

and changed the account owner/Out of two,only one contac whose owner id is same as account changes and other doesnt.

This is my trigger ..Please help me where i am going wrong.

 

 

trigger Changeownertrigger on Account (after insert,after update) {
  
      Set<Id> accountIds = new Set<Id>(); 
      Map<Id, String> oldOwnerIds = new Map<Id, String>();
      Map<Id, String> newOwnerIds = new Map<Id, String>();
      Contact[] contactUpdates = new Contact[0]; 
     
      for (Account a : Trigger.new) 
      { 
         if (a.OwnerId != Trigger.oldMap.get(a.Id).OwnerId) 
         {
            oldOwnerIds.put(a.Id, Trigger.oldMap.get(a.Id).OwnerId); 
            newOwnerIds.put(a.Id, a.OwnerId); 
            accountIds.add(a.Id); 
         }
      }
        if (!accountIds.isEmpty()) { 
         for (Account acc : [SELECT Id, (SELECT Id, OwnerId FROM Contacts) FROM Account WHERE Id in :accountIds])
            {
            String newOwnerId = newOwnerIds.get(act.Id); 
            String oldOwnerId = oldOwnerIds.get(act.Id); 
            for (Contact c : acc.Contacts) 
            { 
               if (c.OwnerId == oldOwnerId) 
               {
               Contact updatedContact = new Contact(Id = c.Id, OwnerId = newOwnerId);
               contactUpdates.add(updatedContact);
               }
            }
            
            }
       }
            update contactUpdates;
}

 Pease help i need this asap...