• rwoollen
  • NEWBIE
  • 50 Points
  • Member since 2007

  • Chatter
    Feed
  • 2
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 25
    Replies

could someone post some sample code for pulling both the newsfeed (in the workbook already) but with comments?  we'd like to build a more useful mechanism for filtering very busy feeds, but we don't want to lose sight of the comments on the feed posts, since they are just as valuable, or sometimes more valuable, than the posts themselves.

 

also, what is the proper way to query for feed posts to a specific chatter group?

Just signed up to sales force and wanted to install this automatic opt out application.

Got this error

Missing feature Apex Classes Installing this package requires the following feature and its associated permissions: Apex Classes

I am the administrator

Shame as this is my first experience with force.com

Any help would be appreciated

Nick

Apex code (and triggers) run in system security context unless 'with sharing' is specified and that works great and allows us to control things. However Chatter completely ignores this paradigm and has a security ruleset of its own which we cannot tweak or configure. Namely even though the code runs in system context you cannot insert a FeedPost into private groups unless running user is a member and there is no way to allow this?! Why the duality? Why is the existing security scheme bad for chatter?

 

Namely this prevents us from  posting custom notifications into special team's private groups when a certain condition happens on a record (and caused by people who should not have read access to other stuff in the private group), but the usability being blocked does not stop there. Given that Apex does not allow user impersonation there is absolutely NO way for an apex code/trigger to generate and insert a message into a group unless the record change is caused by the user already in the group (which kind of defeats the whole purpose of bringing it to groups' attention).

  • February 16, 2011
  • Like
  • 0

Due to the limit of 500 followed object per subscriber, I want to automatically remove the oldest EntitySubscription for a User.  Is there a way to figure out which EntitySubscription is the oldest record?  I don't see any date created record in EntitySubscription.

 

Thank you.

  • January 14, 2011
  • Like
  • 0

I've scoured the net and SF boards, but I could not find a single example of how to remove Chatter followers from an object. I'm pretty sure I did it right by just removing the correct EntityRelationship record, but the test method is failing. Either I wrote the removeAllFollowers method wrong, or I wrote the test wrong. Can you take a look and tell me if you see anything obvious? Thanks! 

 

Goal: When a Project__c is closed, remove all Chatter followers.

 

Problem: When I run my getFollowers() method two different times on the same Project__c object, I get two different records. Driving me crazy.

 

 

public static Boolean removeAllFollowers(Set<Id> objectToUnfollowIdSet) {
    
     List<EntitySubscription> subscriptionsToDeleteList =
     [SELECT e.Id, e.parentId, e.subscriberId
     FROM EntitySubscription e
     WHERE e.parentId IN :objectToUnfollowIdSet];
    
     try {
     delete subscriptionsToDeleteList;
     } catch (System.Exception e) {
     throw e;
     return false;
     }
    
     return true;
    }
public static Map<Id, Set<Id>> getFollowers(List<Id> objectIdList) {
    
     Map<Id, Set<Id>> objectToFollowerMap = new Map<Id, Set<Id>>();
     Set<Id> followerIdSet = new Set<Id>();
     List<EntitySubscription> subscriberList = [SELECT e.ParentId, e.SubscriberId 
     FROM EntitySubscription e
     WHERE e.ParentId IN :objectIdList];
     for (Id objectId : objectIdList) {
     followerIdSet.clear();
     for (EntitySubscription subscriber : subscriberList) {
     if (subscriber.parentId == objectId) {
     followerIdSet.add(subscriber.subscriberId);
     }
     }
     System.debug('objectId: ' + objectId + ' followerIdSet: ' + followerIdSet);
 objectToFollowerMap.put(objectId, followerIdSet);    
     }
     return objectToFollowerMap;
    }
static testMethod void testProjectCloses_HasChatterFollowers() {
     // Create test data
     User user1 = TestHelper.createUser('first', 'last', 'email@email.com', TestHelper.getSysAdminProfile().Id);
     Project__c project1 = TestHelper.createProject('project1', user1.Id);
     User user2 = TestHelper.createUser('bob', 'follower', 'email2@email.com', TestHelper.getSysAdminProfile().Id);
     EntitySubscription subscription = TestHelper.createChatterFollower(project1.Id, user2.Id);
     System.debug('SUBSCRIPTION: ' + subscription);
     // Ensure data is as expected
     Map<Id, Set<Id>> followersMap = ChatterHelper.getFollowers(new List<Id>{project1.Id});
 // This debug gives an ID of X
     System.debug('FOLLOWERSMAP: ' + followersMap);
     System.assertEquals(1, followersMap.size());
    
     // Invoke functionality
     System.Test.startTest();
     project1.Status__c = 'Closed';
     update project1;
     System.Test.stopTest();
    
     // Check results
     project1 = [SELECT p.Id, p.Status__c FROM Project__c p WHERE p.Id = :project1.Id];
     followersMap = ChatterHelper.getFollowers(new List<Id>{project1.Id});
 // This debug gives an ID of Y
     System.debug('FOLLOWERSMAP: ' + followersMap);
 // Failing here on this assert
     System.assertEquals(0, followersMap.size());
    }

 

  • January 13, 2011
  • Like
  • 0

I tried to insert a FeedTrackedChange in an APEX Trigger:

 

FeedTrackedChange ftc = new FeedTrackedChange();
...
insert ftc;	

I get the following error: DML operation INSERT not allowed on  FeedTrackedChange.

 

Does that mean I am not allowed to write any FeedTrackedChange from custom triggers or is there a workaround for this task?

 

 

could someone post some sample code for pulling both the newsfeed (in the workbook already) but with comments?  we'd like to build a more useful mechanism for filtering very busy feeds, but we don't want to lose sight of the comments on the feed posts, since they are just as valuable, or sometimes more valuable, than the posts themselves.

 

also, what is the proper way to query for feed posts to a specific chatter group?

Hi , I am trying to figure out the name of user who commented on a feed but unfortunately i am not able to make a query:

 

"Select u.Id,u.Parent.Name,  (Select ParentId From FeedComments) From UserFeed u" WORKS but when it does not allows me to create a parent relationship in inner query but it works on parent query.

 

"Select u.Id,u.Parent.Name, (Select ParentId,Parent.Name From FeedComments) From UserFeed u" gives an error.

 

Is there anything wrong in this query? I donot want to collect the Parent Ids and fetch names from User object in another query.

 

Any solutions please?

Hi,

 

I want to be able to add followers to an opportunity. Does anyone know how to do this.

 

this use case is that I have an opportunity and that I want to get some other people involved, do get them involved I want to add them on as followers. I want the adding of the users to be driven from the user level

  • June 17, 2010
  • Like
  • 0

Hey everyone! Starting to work a little bit using triggers in Salesforce relative to Chatter.

 

Business Case:

We are trying to update the chatter feed of the Opportunity when a change to a specific field is made. Ideally, we'd like to post the following in the chatter post details.

 

<OpportunityLineItem Link> -- <Account Link>

 

 

Here is the snippet of code that we're working with now:

 

            if(opportunityFeedPosts.size() == 0 || opportunityFeedPosts[0].FeedPost.Body != bodyText) {
//System.debug('OpportunityFeed Posts: '+opportunityFeedPosts[0]);

FeedPost opportunityPost = new FeedPost ();
opportunityPost.Type = 'LinkPost';
opportunityPost.Title = ''+entries.get(newOLI.Pricebookentryid).Product2.ProductCode+' socket details';
opportunityPost.Body = bodyText;
String id = String.valueOf(newOLI.Id).substring(0,15);
opportunityPost.LinkURL = 'https://cs2.salesforce.com/'+id;
opportunityPost.ParentID = newOLI.opportunityid;
posts.add(opportunityPost);
System.Debug('Got Here but did not post');

FeedPost opportunityPost2 = new FeedPost ();
opportunityPost2.Type = 'LinkPost';
opportunityPost2.Title = 'Account Details';
opportunityPost2.Body = bodyText;
String id2 = String.valueOf(opp.get(newOLI.OpportunityId).Account.Id).substring(0,15);
opportunityPost2.LinkURL = 'https://cs2.salesforce.com/'+id2;
system.debug('got here and it should have posted twice');
opportunityPost2.ParentID = newOLI.opportunityid;
posts.add(opportunityPost2);

 

 

The Result:

 

We get two posts where the message title is the same but the post bodies are different. Essentially we get a double post with each having a unique link for one to the opportunitylineitem and the other to the account.

 

Any help or quesitons are greatly appreciated!

 

 

  • April 26, 2010
  • Like
  • 0

Along with a co-worker, we are trying to write a trigger to update the chatter on our Opportunities with the ProductCode from the line item. We are not having much success. We do have a working trigger

 

 

trigger LineItemToOpportunityFeedUpdate on OpportunityLineItem (after update) {
    List<FeedPost> posts = new List<FeedPost>();
    
    for(OpportunityLineItem newOLI : Trigger.new) {
        OpportunityLineItem oldOLI = Trigger.oldMap.get (newOLI.id);
        System.debug('New: '+newOLI.Part_Outcome__c+' Old: '+oldOLI.Part_Outcome__c);
        
        if(newOLI.Part_Outcome__c != oldOLI.Part_Outcome__c) {
            
            List<OpportunityFeed> opportunityFeedPosts = [SELECT Id, Type, FeedPost.Body
                                                            From OpportunityFeed
                                                            Where ParentID = :newOLI.OpportunityID
                                                            ORDER BY CreatedDate DESC];
            
                                                                     
            String bodyText = 'Socket outcome was changed from '+oldOLI.Part_Outcome__c+' to '+newOLI.Part_Outcome__c+'.';     
            
            //I would put in the '+lineitem.UnitPrice+' command before the .'; in line 19.
            
            if(opportunityFeedPosts.size() == 0 || opportunityFeedPosts[0].FeedPost.Body != bodyText) {
                //System.debug('OpportunityFeed Posts: '+opportunityFeedPosts[0]);
                
                FeedPost opportunityPost = new FeedPost ();
                opportunityPost.Type = 'LinkPost';
                opportunityPost.Title = 'Socket XYZ has been set to '+newOLI.Part_Outcome__c+'';
                opportunityPost.Body = bodyText;
                String id = String.valueOf(newOLI.id).substring(0,15);
                opportunityPost.LinkURL = 'https://cs2.salesforce.com/'+id;
                opportunityPost.ParentID = newOLI.opportunityid;
                posts.add(opportunityPost);
               }
            }
        }
        insert posts;
}

 

 

If you notice, we have a custom field called the part_outcome__c , which is updating, but we are trying to get the Product code and when we attempt to get the Product Code or part number on the chatter area;

 

Currently chatter using the part_outcome__c looks like this:

 

 

Can someone please help me correct this trigger so we can get the productcode on the chatter. Just for Clarification, our socket = ProductCode

 

 

We're creating a Chatter feed using our App by putting a trigger on an object but in some cases the feed is formatted as "<user A> to <user B>: <Message>" instead of just "user B>: <Message>.

User B is the owner of the object and we're posting the message into their Chatter feed.

User A is the authenticated user (through the API) that caused the trigger to execute.

 

Is there any way to avoid this?

  • April 07, 2010
  • Like
  • 0

Hi,

 

I'm trying to develop something quick to pull some FeedPosts and am looking at the Recipes provided.  The SOQL for pulling all your items specifies the following in the WHERE claus:

 

AND FeedPost.Body != ''

 

However, if I include that in my SOQL call below

 

 

query = "SELECT Id, CreatedById, CreatedBy.FirstName, CreatedBy.LastName, FeedPost.Body FROM NewsFeed WHERE CreatedById != '" + id + "' ORDER BY CreatedDate DESC, ID DESC LIMIT 20"

 

I get an error:

 

 

MALFORMED_QUERY: Illegal filter on NewsFeed

 

I actually get this anytime I try to filter on any part of the 'FeedBody' Object.  Thoughts/Ideas?  It is important to me to be able to filter on the Body (so that I can filter out Posts that are only Links, etc).

 

 

 

Message Edited by mcowger on 03-31-2010 09:31 PM

If I understand the other postings correctly, if we are an ISV building 5 related but stand-alone applications we need 5 separate DE orgs, one for each application/managed package.

 

Here's the problem:  What if there are shared custom objects and Apex classes that all 5 applications use?  A given customer may have 1, 2, 3, 4, or 5 of the applications installed.  Does not the prepending of each DE namespace result in redundant code for the shared objects and Apex classes?  Also, how would you prevent the creation of up to 5 tables for an effectively identical custom object when you really want all five applications reading and writing to the same single table via the same page, controllers, object, etc?

 

Said another way, how do you separate and reuse cross-application architectural code and the applications that use it in a multi-application, managed-package environment?

 

Thanks!

 

Dave

 

  • March 27, 2009
  • Like
  • 0

Hello all:

 

So my question concerns a complicated situation. I'm new enough to packaging that I'm not at all sure I'm going to state the problem accurately but I'll try.

 

I'm part of a team working on a Force.com app. The org in which we're working has a development sandbox, a test/QA environment, and a production environment. We're using the Force.com Eclipse IDE for pretty much everything, including migration from dev to test.

 

A few weeks ago we tried to push to production. We encountered an error that prevented our tests from running, and we're following up on that issue with SFDC so that's a separate converstion.

 

Here's the nub. To get our app deployed it was recommended we instead upload our package to production via the web interface. This seems to have worked, net the usual tinkering. We uploaded as an unmanaged package.(Side note: am I right in thinking this involved somehow funneling the app through the AppExchange?)

 

The problem is that now we can no longer deploy using our original package, the one recognized by the IDE and the one we use to keep our project definition together. What we've now been told by those who specialize in deployment in this org is that we can only deploy to production using Ant, and sending the deployer a listof all the changed components so that an Ant script can be pulled together that just updates those components.

 

I can tell there are things I still just don't "get" about packages and migration, and I know the above is a lot to wade through, but I'm curious whether any can tell me what was different about uploading the package via the web UI, and why our Eclipse IDE deployments apparently no longer work.

 

Any insight greatfully received.

 

-- Steve Lane

  • March 10, 2009
  • Like
  • 0
I want to create a new managed package but I already have one.  I usually just deprecate the existing package and then delete it.  However, the last package I created is not letting me deprecate the package, the button is greyed out.  Anyone know why that might be the case?

Shiztastic
Just signed up to sales force and wanted to install this automatic opt out application.

Got this error

Missing feature Apex Classes Installing this package requires the following feature and its associated permissions: Apex Classes

I am the administrator

Shame as this is my first experience with force.com

Any help would be appreciated

Nick
Hi all,

Is there any option that we could rollback the installed Managed Beta package over the Manage release package.

Note:(Condition).I need to work on the same DE org for testing where i have overwirte the DE org containing the Manage Release package with the Manage Beta package.i do not have option of choosing the new DE org.(i.e in this DE org it contains the workflow rule which i cant make in another new DE org)

So can anyone find solution for me except the solution of Salesforce support.

LAM.

Message Edited by lamichhane.deep on 12-22-2008 10:41 PM
Looks like we're having a similar issue to the others listed here. In talking with several support people, they didn't have any idea why it was happening, so it might be good to get a FAQ or something in the SF support script.

Error - 369304800-5376 (-2055400066)
Case - 02292310

Any suggestions?
  • December 09, 2008
  • Like
  • 0
Our customer gets the following error message when he tries to upgrade our managed package:
 
>>Your requested install failed. Please try this again.
None of the data or setup information in your Salesforce organization should have been affected by this error.
 
If this error persists, contact Support through your normal channels and reference number: 1908364176-1193 (-1966015486)<<
 
Does this number mean something to anyone ?
 
Hello,

The developer account for my company has 2 packages, neither of which have been published on the AppExchange.  The other day, I was experimenting with managed packages and namespace prefixes.  I selected one of the packages to be managed, and choose a suitable namespace prefix for it.  After doing this, I noticed that the namespace prefix was applied to both packages.

Knowing what I know now, I was wondering if it would be possible to change my company's namespace prefix to something that would better suit both packages (and potentially others at some point).

I suppose I could create another developer account and choose another namespace, but that is probably not a great thing to do.

Any suggestions?

  • November 13, 2008
  • Like
  • 0