• KhaledZero
  • NEWBIE
  • 120 Points
  • Member since 2013

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

Hi,
I want be at least 75 % of cover of the code of my class
My class to be tested :

    Public static void blockChange(FeedItem item){
     List<CollaborationGroup> MyGroup = [Select Name From CollaborationGroup where Id = :item.ParentId LIMIT 1];
            if(MyGroup.size() >0){
                if(MyGroup.get(0).Name.toUpperCase().contains('#INACTIF')){
                        item.addError('this is inactive group');
                }
            }    
    }
    Public static void blockChange(FeedItem item, FeedComment comment){
     List<CollaborationGroup> MyGroup = [Select Name From CollaborationGroup where Id = :item.ParentId LIMIT 1];
            if(MyGroup.size() >0){
                if(MyGroup.get(0).Name.toUpperCase().contains('#INACTIF')){
                        comment.addError('this is inactive group');
                }
            }    
    }
}

 My Test Class:

@isTest(SeeAllData=true)
public class InactiveGroups_ClassTest{
    static testMethod void myUnitTest() {
        Group gp= new Group();
        gp.Name ='#inactif';
     FeedItem item = new FeedItem();
  item.ParentId = gp.Id;       
        FeedComment comment = new FeedComment();
        Test.startTest();
        InactiveGroups_Class.blockChange(item);
        InactiveGroups_Class.blockChange(item, comment);
        Test.stopTest();   
    }
}

 Thx.

 

 

Hey,

I want block change of some values in User with a trigger.

values to block:

LastName, FirstName ,Alias , Username ,Email, CompanyName, Department, Division ,UserRoleId ,Phone ,Extension ,Fax ,MobilePhone ,EmployeeNumber ,Street ,City, PostalCode  ,Country

 

trigger:

trigger UserBlockChange on User (before update) {
    
    if(trigger.IsUpdate){
    		
        
    }

}

 Thx.

Hi,

I want block posts, comments and Likes in a group whith trigger where group.Name.conatins('inactif')

 

thx

Hi,

how i can use trriger to disable comments ans likes in a posts of an group

ps:
when i want bloc posts in an group i use 

trigger GroupReadOnly on FeedItem (before insert, before delete)

 thx.

Hi,

I want write my query whith SOQL:

Selecte User.Username, CollaborationGroup.Name, CollaborationGroup.LastModifiedDate 
From User, CollaborationGroup
Where User.Id = CollaborationGroup.OwnerID AND CollaborationGroup.LastModifiedDate < 2013-04-20T14:00:00.000Z

 thx.

Hi,

when i execute Force.com IDE I have this message:

http://hpics.li/0aa48b5

 

thx

Hi,

I want get : User.Username , User.Id , CollaborationGroup.Name, CollaborationGroup.LastFeedModifiedDate Where CollaborationGroup.OwnerId =User.Id 

User.Username , User.Id , CollaborationGroup.Name, CollaborationGroup.LastFeedModifiedDate Where CollaborationGroup.OwnerId =User.Id  

 But I don't know how we can do the join whith User and CollaborationGroup

thx

Hi,

 

how can i do to add a value for my custom field?

 

thx

Hello,

 

i want get a liste of users and list  groups of each user whith LastFeedModifiedDate > 30 day

 

SELECT gp.LastFeedModifiedDate, gp.Name, gp.OwnerId, user.Id, user.Username 
FROM CollaborationGroup gp, User user
WhERE gp.LastFeedModifiedDate > 30 AND gp.OwnerId = user.Id 

can you help me beacause my query it not work  

thx

Hi,

using apex code in salsesForce

CollaborationGroup gp = [Select OwnerId, Id From CollaborationGroup Where Name = 'Group_ReadOnly'];

 

how to get the list of managers of a group?

Thx.

Hi,

 

how to create a read-only group + like + comment and not being able to post for members except admin and owner
* how to use triggers on the FeedItem in this group?.

 

 

i tried whith this code but it not work:

 

trigger:_______________________________________

 

 

trigger GroupReadOnly on FeedItem (after insert) {    
    
    CollaborationGroup gp = [Select OwnerId, Id From CollaborationGroup Where Name = 'Group_ReadOnly'];
    
    List<FeedItem> feedItems = new List<FeedItem>();
    
    for(FeedItem item : trigger.new){
        if(item.ParentId == gp.Id)
        {
            feedItems.add(item);
        }      
    }
   if(feedItems.size() >0) GroupReadOnlyClass.FilterFeedItems(feedItems);
}

 

class:_______________________________________

 

public class GroupReadOnlyClass{    
    public static void FilterFeedItems(List<FeedItem> feedItems){
        
        Id[] listFeedItemToDelete = new Id[]{};
        CollaborationGroup gp = [Select OwnerId, Id From CollaborationGroup Where Name = 'Group_ReadOnly'];
        
        for(FeedItem item :feedItems){
            if(item.ParentId == gp.Id)
             {
                if(item.InsertedById != gp.OwnerId){
                    listFeedItemToDelete.add(item.Id);
                }        
            }
        }
        if (listFeedItemToDelete.size() > 0 )
        {
           DeleteFeedItems.DeleteFeedItems(listFeedItemToDelete);
        }
    }
}

 

 

class delete:________________________

 

 

public class DeleteFeedItems
{
 @future
 public static void DeleteFeedItems(Id[] listFeedItemToDelete)
 {
   if (listFeedItemToDelete.size() > 0 )
   {
     List<FeedItem > feedItems= [Select Id FROM FeedItem where Id=: listFeedItemToDelete];
     if ( feedItems != null)
     {
       delete feedItems;
       System.Debug(feedItems.size() + ' Feeds deleted !');
     }
   }
 }
}

 

 

thx.

 

Hi,
I want be at least 75 % of cover of the code of my class
My class to be tested :

    Public static void blockChange(FeedItem item){
     List<CollaborationGroup> MyGroup = [Select Name From CollaborationGroup where Id = :item.ParentId LIMIT 1];
            if(MyGroup.size() >0){
                if(MyGroup.get(0).Name.toUpperCase().contains('#INACTIF')){
                        item.addError('this is inactive group');
                }
            }    
    }
    Public static void blockChange(FeedItem item, FeedComment comment){
     List<CollaborationGroup> MyGroup = [Select Name From CollaborationGroup where Id = :item.ParentId LIMIT 1];
            if(MyGroup.size() >0){
                if(MyGroup.get(0).Name.toUpperCase().contains('#INACTIF')){
                        comment.addError('this is inactive group');
                }
            }    
    }
}

 My Test Class:

@isTest(SeeAllData=true)
public class InactiveGroups_ClassTest{
    static testMethod void myUnitTest() {
        Group gp= new Group();
        gp.Name ='#inactif';
     FeedItem item = new FeedItem();
  item.ParentId = gp.Id;       
        FeedComment comment = new FeedComment();
        Test.startTest();
        InactiveGroups_Class.blockChange(item);
        InactiveGroups_Class.blockChange(item, comment);
        Test.stopTest();   
    }
}

 Thx.

 

 

Hi,

how i can use trriger to disable comments ans likes in a posts of an group

ps:
when i want bloc posts in an group i use 

trigger GroupReadOnly on FeedItem (before insert, before delete)

 thx.

Hi,

I want write my query whith SOQL:

Selecte User.Username, CollaborationGroup.Name, CollaborationGroup.LastModifiedDate 
From User, CollaborationGroup
Where User.Id = CollaborationGroup.OwnerID AND CollaborationGroup.LastModifiedDate < 2013-04-20T14:00:00.000Z

 thx.

Hi,

I want get : User.Username , User.Id , CollaborationGroup.Name, CollaborationGroup.LastFeedModifiedDate Where CollaborationGroup.OwnerId =User.Id 

User.Username , User.Id , CollaborationGroup.Name, CollaborationGroup.LastFeedModifiedDate Where CollaborationGroup.OwnerId =User.Id  

 But I don't know how we can do the join whith User and CollaborationGroup

thx

Hi,

 

how can i do to add a value for my custom field?

 

thx

Hello,

 

i want get a liste of users and list  groups of each user whith LastFeedModifiedDate > 30 day

 

SELECT gp.LastFeedModifiedDate, gp.Name, gp.OwnerId, user.Id, user.Username 
FROM CollaborationGroup gp, User user
WhERE gp.LastFeedModifiedDate > 30 AND gp.OwnerId = user.Id 

can you help me beacause my query it not work  

thx

Hi,

 

how to create a read-only group + like + comment and not being able to post for members except admin and owner
* how to use triggers on the FeedItem in this group?.

 

 

i tried whith this code but it not work:

 

trigger:_______________________________________

 

 

trigger GroupReadOnly on FeedItem (after insert) {    
    
    CollaborationGroup gp = [Select OwnerId, Id From CollaborationGroup Where Name = 'Group_ReadOnly'];
    
    List<FeedItem> feedItems = new List<FeedItem>();
    
    for(FeedItem item : trigger.new){
        if(item.ParentId == gp.Id)
        {
            feedItems.add(item);
        }      
    }
   if(feedItems.size() >0) GroupReadOnlyClass.FilterFeedItems(feedItems);
}

 

class:_______________________________________

 

public class GroupReadOnlyClass{    
    public static void FilterFeedItems(List<FeedItem> feedItems){
        
        Id[] listFeedItemToDelete = new Id[]{};
        CollaborationGroup gp = [Select OwnerId, Id From CollaborationGroup Where Name = 'Group_ReadOnly'];
        
        for(FeedItem item :feedItems){
            if(item.ParentId == gp.Id)
             {
                if(item.InsertedById != gp.OwnerId){
                    listFeedItemToDelete.add(item.Id);
                }        
            }
        }
        if (listFeedItemToDelete.size() > 0 )
        {
           DeleteFeedItems.DeleteFeedItems(listFeedItemToDelete);
        }
    }
}

 

 

class delete:________________________

 

 

public class DeleteFeedItems
{
 @future
 public static void DeleteFeedItems(Id[] listFeedItemToDelete)
 {
   if (listFeedItemToDelete.size() > 0 )
   {
     List<FeedItem > feedItems= [Select Id FROM FeedItem where Id=: listFeedItemToDelete];
     if ( feedItems != null)
     {
       delete feedItems;
       System.Debug(feedItems.size() + ' Feeds deleted !');
     }
   }
 }
}

 

 

thx.

 

Hi,

 

Do you know a possibility in Chatter for creating a group in which several people can post but all people can read?

 

Regards

  • November 27, 2012
  • Like
  • 0