• NickSmyrnos
  • NEWBIE
  • 0 Points
  • Member since 2012

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

I am trying to update a Visualforce page that we use to override the Contact Detail page to show Chatter data as well as Social Contacts.  Chatter seems to be fairly easy to enable from the apex:detail tag.  Social Contacts seems to only be available via the <social:profileViewer> tag.  When I add this tag, I end up with a second header with the Contact name underneath the original header with the Contact name and Chatter info.

 

Is there a way to merge this data into a single header like native pages do?

 

 

VF snippet:

<apex:page id="MyPage" standardController="contact" name="ContactBusinessUser" extensions="Contact_BusinessUserController" >
<social:profileViewer entityId="{!contact.id}"/>

<apex:detail subject="{!$CurrentPage.parameters.id}" relatedList="true" inlineEdit="true" onComplete="EnableDisableButtons()" id="Contact_BusinessUser" showChatter="true"/>

 

I've got a trigger on account object that populates a field that counts and sums up the number of related accounts to the account being updated/inserted/deleted.  Pretty straightforward.

 

This trigger works but I need to know whether it would be considered bulkified.  If it's not, any suggestions on what ought to be changed to bulkify it would be much appreciated.

 

Here it is:

 

trigger Account on Account (before insert, after insert, before update, after update) { 



// ---------------------------------------------------------------
 // Active Managed & Unmanaged Paying Customers processing
 // ------------------------------------------------------------------

    if ((Trigger.isInsert || Trigger.isUpdate || Trigger.isDelete) && Trigger.isAfter) {    

         set<Id> AccountIds = new set<Id>();
 
             if(trigger.isInsert || trigger.isUpdate){
                 for(Account p : trigger.new){
                     AccountIds.add(p.Referring_Partner__c);
                 }
              }
 
             if(trigger.isDelete){
                for(Account  p : trigger.old){
                    AccountIds.add(p.Referring_Partner__c);
                 }
              }
 
          map<Id,Double> AccountMap1 = new map <Id,Double>();
 
              for(AggregateResult q : [select Referring_Partner__c,sum(Referring_Partner_Count__c)
                  from Account 
                  where Active_Products__c != null AND Managed_by_Partner__c !=null AND Referring_Partner__c IN :AccountIds 
                  group by Referring_Partner__c]){
                  
                  AccountMap1.put((Id)q.get('Referring_Partner__c'),(Double)q.get('expr0'));
               }
  
           map<Id,Double> AccountMap2 = new map <Id,Double>();
 
               for(AggregateResult q : [select Referring_Partner__c,sum(Referring_Partner_Count__c)
                   from Account where Active_Products__c != null AND Managed_by_Partner__c = false AND Referring_Partner__c IN :AccountIds 
                   group by Referring_Partner__c]){
          
                   AccountMap2.put((Id)q.get('Referring_Partner__c'),(Double)q.get('expr0'));
               }
 
           List <Account> AccountsToUpdate = new List<Account>();
 
               for(Account a : [Select Id, Active_Paying_M__c from Account where Id IN :AccountIds]){
   
                   Double Sum1 = AccountMap1.get(a.Id);
                   a.Active_Paying_M__c = Sum1 ;
                   Double Sum2 = AccountMap2.get(a.Id);
                   a.Active_Paying_U__c = Sum2;    
    
                   AccountsToUpdate.add(a);
                }
 
           
           update AccountsToUpdate ;
  
    }

}

 

Hi

 

Is it possible to use Email To Case by sending emails directly to the SFDC email address, instead of forwarding to that address from an email server?  For some customers, security may not allow them to forward email outside their firewall, and may also prevent them from deploying the Email To Case agent.

 

Thx,

Hamayoun

Yup, it's me again.

I dunno if I just suck, or if I'm really pushing this parser. I am making a call to facebook to get user data. The user data comes back as JSON. Most of it is simple string data. There are 3 fields that are arrays. Those arrays contain only 2 items (id and name). I have attempted to create the class based on the JSON and deserialize into it. I am receiving another salesforce system error.

 

System.UnexpectedException: Salesforce System Error: 996229906-358 (-433257328) (-433257328) 
An unexpected error has occurred. Your solution provider has been notified. (system)

Here is the json I am attempting to parse (cleaned up a bit)

{
    "id": "XXXXX",
    "name": "XXXXXX XXXXXXX",
    "first_name": "XXXXXX",
    "last_name": "XXXXXX",
    "link": "http://www.facebook.com/XXXXXX",
    "username": "XXXXXX",
    "about": "some data about the person.",
    "birthday": "00/00/0000",
    "hometown": {
        "id": "XXXXXXXXXXXXXXXXXXXXXXXX",
        "name": "Somewhere, New York"
    },
    "location": {
        "id": "XXXXXXXXXXXXXXXXXXXXXXXX",
        "name": "Nowhere, Nevada"
    },
    "bio": "This is some demo text",
    "inspirational_people": [
        {
            "id": "109425469076258",
            "name": "Miyamoto Musashi"
        },
        {
            "id": "112377255503169",
            "name": "Kenshin Himura"
        },
        {
            "id": "135952326470380",
            "name": "Spike Spiegel"
        },
        {
            "id": "146133595436195",
            "name": "Kamina"
        },
        {
            "id": "12534674842",
            "name": "Albert Einstein"
        },
        {
            "id": "184049470633",
            "name": "Bruce Lee"
        }
    ],
    "gender": "male",
    "email": "XXXXXX@XXXXXX.com",
    "timezone": -4,
    "locale": "en_US",
    "verified": true,
    "updated_time": "2011-11-07T21:17:55+0000"
}


OR EASILY PASTEABLE VERSION
{ "id": "XXXXX", "name": "XXXXXX XXXXXXX", "first_name": "XXXXXX", "last_name": "XXXXXX", "link": "http://www.facebook.com/XXXXXX", "username": "XXXXXX", "about": "some data about the person.", "birthday": "00/00/0000", "hometown": { "id": "XXXXXXXXXXXXXXXXXXXXXXXX", "name": "Somewhere, New York" }, "location": { "id": "XXXXXXXXXXXXXXXXXXXXXXXX", "name": "Nowhere, Nevada" }, "bio": "This is some demo text", "inspirational_people": [ { "id": "109425469076258", "name": "Miyamoto Musashi" }, { "id": "112377255503169", "name": "Kenshin Himura" }, { "id": "135952326470380", "name": "Spike Spiegel" }, { "id": "146133595436195", "name": "Kamina" }, { "id": "12534674842", "name": "Albert Einstein" }, { "id": "184049470633", "name": "Bruce Lee" } ], "gender": "male", "email": "XXXXXX@XXXXXX.com", "timezone": -4, "locale": "en_US", "verified": true, "updated_time": "2011-11-07T21:17:55+0000" } 

 

 Here is the code I am trying to run. You should be able to run this in execute anonymous. I have tried running it regular as well (being invoked by the page, which has the class as a controller) and get the same error either way.



string jsonData = '{ "id": "XXXXX", "name": "XXXXXX XXXXXXX", "first_name": "XXXXXX", "last_name": "XXXXXX", "link": "http://www.facebook.com/XXXXXX", "username": "XXXXXX", "about": "some data about the person.", "birthday": "00/00/0000", "hometown": { "id": "XXXXXXXXXXXXXXXXXXXXXXXX", "name": "Somewhere, New York" }, "location": { "id": "XXXXXXXXXXXXXXXXXXXXXXXX", "name": "Nowhere, Nevada" }, "bio": "This is some demo text", "inspirational_people": [ { "id": "109425469076258", "name": "Miyamoto Musashi" }, { "id": "112377255503169", "name": "Kenshin Himura" }, { "id": "135952326470380", "name": "Spike Spiegel" }, { "id": "146133595436195", "name": "Kamina" }, { "id": "12534674842", "name": "Albert Einstein" }, { "id": "184049470633", "name": "Bruce Lee" } ], "gender": "male", "email": "XXXXXX@XXXXXX.com", "timezone": -4, "locale": "en_US", "verified": true, "updated_time": "2011-11-07T21:17:55+0000" }';    
class facebookUser
    {
        public string id;
        public string name;
        public string first_name;
        public string last_name;
        public string link;
        public string username;
        public string about;
        public string birthday;
        public string gender;
        public string email;
        public string timezone;
        public string locale;
        public string verified;
        public string updated_time;
        public list<dataItem> hometown;
        public list<dataItem> location;
        public list<dataItem> inspirational_people;
        
        public facebookUser(string id, string name, string first_name, string last_name, string link, string username, string about, string birthday, string gender, string email, string timeZone, string locale, string verified, string updated_time)
        {
            this.id = id;
            this.name = name;
            this.first_name = first_name;
            this.last_name = last_name;
            this.link = link;
            this.username = username;
            this.about = about;
            this.birthday = birthday;
            this.gender = gender;
            this.email = email;
            this.timeZone = timeZone;
            this.locale = locale;
            this.verified = verified;
            this.updated_time = updated_time;
            this.hometown =  new list<dataItem>();
            this.location =  new list<dataItem>();
            this.inspirational_people = new list<dataItem>();      
        }
    }
    
    class dataItem 
    {
        public string id;
        public string name;
        
        public dataItem(string id, string name)
        {
            this.id = id;
            this.name = name;
        }
    }

//I have tried deserializing to a list, as well as a single object list<facebookUser> d = (list<facebookUser>)JSON.deserialize( jsonData,facebookUser.class);

//This fails too
facebookUser d = (facebookUser)JSON.deserialize( jsonData,facebookUser.class); 

 

Any thoughts would be much appreciated. Thank you.

I can schedule a job via Apex code:

 

System.schedule('test', '0 0 0 * * ?', new SchedulableClass());

 

The CronTrigger job doesn't have a "Name" field, so I can't query for the Job I just created.  This means I can't check to see if my job already exists calling System.schedule(); instead I just have to call "schedule()" and silently eat the exception it throws if the job already exists.

 

The only way you can figure out which CronTrigger is yours is to cache the return value of System.schedule(), which (it so happens) is the ID of the CronTrigger that is created.  However, you can't delete them from Apex:

 

 

Id jobid = System.schedule('test', '0 0 0 * * ?', new SchedulableClass());
delete new CronTrigger(Id = jobid);

// 'delete' throws 'DML not allowed on CronTrigger'

 

 

So the current state of Scheduled Jobs is:

 

You can create them from Apex Code, but not from the UI

You can delete them from the UI, but not from Apex Code

 

I guess that just seems odd to me.  Why did Salesforce create this whole new API (System.schedule()), with a seemingly random assortment of ways to manipulate it, instead of just exposing the CronTrigger table directly to the full range of DML operations?

 

Placing new functionality into new core objects, rather than new APIs, seems easier on everyone (the whole describe/global describe suite of API calls are an example of something that seems a natural fit for a set of read-only custom objects).

  • April 22, 2010
  • Like
  • 0