• theAlchemist2889
  • NEWBIE
  • 0 Points
  • Member since 2014


  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 5
    Questions
  • 3
    Replies
I am creating a custom chatter page in Visualforce (kinda reinventing the wheel) by using Connect API. I am able to get the list of feeds for the user using the following connect API call:
feedElementPage = ConnectApi.ChatterFeeds.getFeedElementsFromFeed(null, ConnectApi.FeedType.News, 'me');

When I am trying to display on page I am using Parent property of feedelement to display the user. It works fine when the parent is a user but in case of chatter post in a group, the parent is the group in which the chatter post is made. How can I get the name of the user who created the post in the group to display on page?

I looked into the documentation and could not find the relevant field on feedeleemnt. Also, CreatedBy field is not accessible for feedelement.
<apex:column width="18%">
          <apex:facet name="header">Sender</apex:facet> 
          <a href="/{!feedElement.parent.id}">{!feedElement.parent.name} </a> 
​</apex:column>
The above code displays User's name in case the post is by a user and group name in case its a group post. I need the name of user who posted in group. e.g. Posted in <groupname> by <username>
I am working on a requirement where we have set up partner community and set up users with 'partner community user' and their cloned profiles. We have a custom filed on user Named 'Status'. When the user is created their 'Status' will be inactive. Then they will go to community login (custom) page and login and go to EULA page and when they click on 'Submit' button they should be able to update their Status to 'Activation Pending'

Now, my issue is that that in the controller of EULA Page I am not able to get the Status field on user even though it is there in my Query to update the status.

My Query is:
[SELECT Id,Status__c ,FullPhotoUrl From User WHERE Id =:userId];

But In the debug logs what I get is:
User: User:{CurrencyIsoCode=EUR, FullPhotoUrl=/profilephoto/005/F, Id=005q0000000KVGYAA4}


i.e. The Status is not being returned by Query.

I understand it could be because community users dont have access on some User object fields. In that case, is there any workaround?

Any help is appreciated.

Thanks.
We have written a de-duplication logic for contact records where we call a batch job from trigger (Yes, it sounds weird but the only thing that seems to work as we have variable criteria for each account). To overcome batch schedule limit of 5, we are using data loader with bulk API enabled and the natch size set to 1000 so that we can upload 5000 records successfully without hitting the 5 batch job limit. When I am testing with 3000 thousand contact records, let say they are named from Test0001 to Test3000 I am observing a strange behavior.

For 3000 records, 3 batch jobs start to run (as batch size is 1000). I am passing the newly inserted records in parameters to the stateful batch class. What I expect is that 1000 records will be passed for each of the 3 batch jobs and they will be compared to existing records for duplicates (which I query in start method of batch) but I only get Test0001 to Test0200 i.e. from batch of 1000 records inserted via data loader API only FIRST 200 records are passed in parameter to the batch class and rest 800 are not. This is something strance as it means only first 200 records are processes if I insert using a batch size of 1000 through data loader with Bulk API enabled.

Has anyone of you encountered this issue or have any ideas to share on how to deal with it? I can share code as well but I think the question is more conceptual. Any help is much appreciated.

Thanks
Hi,

I have a VF page and controller. On the VF page I need to show a popup (Javascrpit confirmation box). This popoup should be shown on when a certain variable in controller is true. To achieve this I first call an actionfunction on 'Onclick' of button which updates the variable to true of false based on controller varibales. Now i call another function on onclick which checks the value of the variable updated by actionfunction. The problem here is I am not getting the updated value in my second javascript function. How to overcome/achieve this? Any help is appreciated. 
I am working on a module which will de-duplicate contact records on insert/update but I am hitting into Apex CPU time limit exceeded error. I understand that to overcome it we need to optimize code a little but in the following code block there seems very little scope of optimizing it. Any help will be appreciated.

On Account we have a mulipicklist from where we can select the fields based on which the uniqueness of the contacts under this account will be defined. It can be different for difference account. The following code is a part of a handler class for trigger in which we have a map of old contact list with account Id as key (mapOfAccountIdWithItsContact) and a map with new contact list and account as key (newContactWithAccountMap) we iterate over these maps based on set of account whose contacts we have get in triiger. We have a map to stroe Lisst of fields to be used for contact uniqueness for each account (mapOfAccountWithFilters).

Here is the code snippet:

for(String accountId : accountIdSet){
            if(newContactWithAccountMap.get(accountId) != null){
                for(Contact newContact : newContactWithAccountMap.get(accountId)){
                    for(Contact oldContact : mapOfAccountIdWithItsContact.get(accountId)){
                        //Check for duplication only in the respective account, also this should not apply on insertion of Office contact
                        matchingContactFound = false;
                        if(oldContact.id != newContact.id){  //while insert, newContact's id will be null and while update it will verify that it is not matching itself with its old record. 
                            for(String filterFieldName : mapOfAccountWithFilters.get(accountId)){
                                if(oldContact.get(filterFieldName) == newContact.get(filterFieldName)){
                                    matchingContactFound = true;
                                    //If match is found update last de duplication date to today on old contact
                                    oldContact.Last_De_Duplication_Date__c = System.Today();
                                    oldContactsToUpdateSet.add(oldContact);
                                }else{
                                    matchingContactFound = false;
                                    break; //get another "old contact"
                                }
                            }
                        }
                        if(matchingContactFound){

                            //stop it from being inserted
                            duplicateContactSet.add(newContact.Id);
                            //newContact.addError('Contact cannot be inserted because a contact is already present based on the Master Target Identifier at client level.');
                            break; //get another "new contact"
                        }

                    }
                }
            }
        }



Any help in avoiding 4 loops or an alternate approach will be greatly appreciated. Thanks in advance.
I need to show chatter feed on custom visualforce page simmilar to standard chatter feed.

Below is the chatter feed which i  am trying to show on my vf page.

User-added image
public ConnectApi.FeedElementPage getfeedItemPage() {
        ConnectApi.FeedElementPage feedItemPage ;
        if(entityId != null && entityId != ''){
            feedItemPage= ConnectApi.ChatterFeeds.getFeedElementsFromFeed(Network.getNetworkId(), ConnectApi.FeedType.UserProfile, entityId)  ;
        for(ConnectApi.FeedElement fe : feedItemPage.elements){
                system.debug('+++fes.parent++++'+fe.parent); 
                 }
        }
       
         return feedItemPage;
        
    }
Visualforce code 
<div class="row">
        <div class="col-md-6">
            <apex:repeat value="{!feedItemPage.elements}" var="feedItem">
                              
                <div class="media">
                    <a class="pull-left" href="{!$Page.userProfile}?uid={!feedItem.parent['id']}" target="_blank">
                       
                        <!-- <img class="media-object" src="User Image" />-->
                    </a>
                    <div class="media-body">
                        <h4 class="media-heading">
                            <apex:repeat value="{!feedItem.header.messageSegments}" var="segment">
                              
                                <apex:outputPanel rendered="{!(segment.type == EntityLinkSegmentType)}">
                                    
                                    <a href="{!$Page.UserProfile}?uid={!segment['reference'].id}" target="_blank">
                                        <img src="{!segment['motif'].smallIconUrl}"/>
                                        {!segment.text}
                                    </a>
                                </apex:outputPanel>
                                <apex:outputPanel rendered="{!(segment.type == TextSegmentType)}">
                                    {!segment.text}
                                </apex:outputPanel>
                                <apex:outputPanel layout="none" rendered="{!segment.type == MentionSegmentType}">
                                    <a href="{!$Page.UserProfile}?uid={!segment['record'].id}" target="_blank">@{!segment['record'].name}</a>
                            </apex:outputPanel>
                            </apex:repeat>    
                         </h4>
                                
                        <apex:repeat value="{!feedItem.body.messageSegments}" var="segment">
                            <apex:outputPanel layout="none" rendered="{!segment.type == TextSegmentType}">
                                {!segment.text}
                            </apex:outputPanel>
                            <apex:outputPanel layout="none" rendered="{!segment.type == MentionSegmentType}">
                                <a href="{!$Page.UserProfile}?uid={!segment['record'].id}" target="_blank">@{!segment['record'].name}</a>
                            </apex:outputPanel>
                        </apex:repeat>
                        <apex:repeat value="{!feedItem.capabilities.comments.page.items}" var="comment">
                          
                            <div class="media">
                                <a class="pull-left" href="{!$Page.userProfile}?uid={!comment.parent.id}" target="_blank">
                                    <img class="media-object" src="{!comment.user.photo.smallPhotoUrl}" alt="{!comment.user.firstname}"/>
                                </a>
                                <div class="media-body">
                                    <h4 class="media-heading">
                                        <a href="{!$Page.userProfile}?uId={!comment.user.id}" target="_blank">
                                            {!comment.user.firstname} {!comment.user.lastname}
                                        </a>  
                                    </h4>
                                    <apex:repeat value="{!comment.body.messageSegments}" var="segment">
                                        <apex:outputPanel layout="none" rendered="{!segment.type == TextSegmentType}">
                                            {!segment.text}
                                        </apex:outputPanel>
                                        <apex:outputPanel layout="none" rendered="{!segment.type == MentionSegmentType}">
                                            <a href="{!$Page.UserProfile}?uId={!segment['record'].id}">@{!segment['record'].name}</a>
                                        </apex:outputPanel>
                                    </apex:repeat>
                                </div>
                            </div>
                        </apex:repeat>
                    </div>
                </div>
            </apex:repeat>
        </div>
Issue -- I am not able to get the user Id and picture.(Marked by red arrow in pic)

Though when i am running my page and checking the debug log i am able to show the user details in debug log-
+++fes.parent++++ConnectApi.UserSummary[buildVersion=33.0, additionalLabel=null, communityNickname=amitcoh1.4333333638497007E12, companyName=SPN, displayName=Amit Singh, firstName=Amit, id=00528000000Jw2NAAS, isActive=true, isInThisCommunity=true, lastName=Singh, motif=ConnectApi.Motif[buildVersion=33.0, color=34BECD, largeIconUrl=/img/icon/profile64.png, mediumIconUrl=/img/icon/profile32.png, smallIconUrl=/img/icon/profile16.png], mySubscription=null, name=Amit Singh, photo=ConnectApi.Photo[buildVersion=33.0, fullEmailPhotoUrl=https://ap2.salesforce.com/ncsphoto/DZ3K8U2-znZz0Tg2cW1h__QotriCshvQ5vGSl0YwjMOySlRLBv53qpnE7UwU_9Ay, largePhotoUrl=https://c.ap2.content.force.com/profilephoto/729280000000DC7/F, photoVersionId=729280000000DC7AAM, smallPhotoUrl=https://c.ap2.content.force.com/profilephoto/729280000000DC7/T, standardEmailPhotoUrl=https://ap2.salesforce.com/ncsphoto/DZ3K8U2-znZz0Tg2cW1h__QotriCshvQ5vGSl0YwjMMDhDDbaFZVpVomaJ0EHoSF, url=/services/data/v33.0/chatter/users/00528000000Jw2NAAS/photo], reputation=null, title=null, type=User, url=/services/data/v33.0/chatter/users/00528000000Jw2NAAS, userType=Internal]
In API Version 31.0 We use ConnectAPI.actor class to get user details.But after API V 32.0 this class is not available.
I Found some link also how can we show the chatter feed on vf page but those are based on API v 31.
http://appirio.com/category/tech-blog/2014/01/chatter-apex/

Can anyone help me to get the user detail from ConnectAPI.feedElement  in API 34.0 ?

Thanks
Amit Singh
 
I am working on a requirement where we have set up partner community and set up users with 'partner community user' and their cloned profiles. We have a custom filed on user Named 'Status'. When the user is created their 'Status' will be inactive. Then they will go to community login (custom) page and login and go to EULA page and when they click on 'Submit' button they should be able to update their Status to 'Activation Pending'

Now, my issue is that that in the controller of EULA Page I am not able to get the Status field on user even though it is there in my Query to update the status.

My Query is:
[SELECT Id,Status__c ,FullPhotoUrl From User WHERE Id =:userId];

But In the debug logs what I get is:
User: User:{CurrencyIsoCode=EUR, FullPhotoUrl=/profilephoto/005/F, Id=005q0000000KVGYAA4}


i.e. The Status is not being returned by Query.

I understand it could be because community users dont have access on some User object fields. In that case, is there any workaround?

Any help is appreciated.

Thanks.
We have written a de-duplication logic for contact records where we call a batch job from trigger (Yes, it sounds weird but the only thing that seems to work as we have variable criteria for each account). To overcome batch schedule limit of 5, we are using data loader with bulk API enabled and the natch size set to 1000 so that we can upload 5000 records successfully without hitting the 5 batch job limit. When I am testing with 3000 thousand contact records, let say they are named from Test0001 to Test3000 I am observing a strange behavior.

For 3000 records, 3 batch jobs start to run (as batch size is 1000). I am passing the newly inserted records in parameters to the stateful batch class. What I expect is that 1000 records will be passed for each of the 3 batch jobs and they will be compared to existing records for duplicates (which I query in start method of batch) but I only get Test0001 to Test0200 i.e. from batch of 1000 records inserted via data loader API only FIRST 200 records are passed in parameter to the batch class and rest 800 are not. This is something strance as it means only first 200 records are processes if I insert using a batch size of 1000 through data loader with Bulk API enabled.

Has anyone of you encountered this issue or have any ideas to share on how to deal with it? I can share code as well but I think the question is more conceptual. Any help is much appreciated.

Thanks