• KRISH9
  • NEWBIE
  • 0 Points
  • Member since 2012

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 12
    Questions
  • 8
    Replies

The following in the SOQL query for Users

 

List<User> u = [SELECT Id FROM User];

 

Am able to get the id to iterate. Now i would like to get the id of Group standard object

List<Group> g = [SELECT Id FROM Group];

 

List<EntitySubscription>   es1 = [select Id from  EntitySubscription where SubscriberId =: j and ParentId NOT IN :usr ]; 

 

am retriving all entity subscriptions whose subscriber id not in the list of users. It is working fine. Now i want to retrive the entity subscriptions whose subscriber id not in the group also. For that i am writing the query like as above 

 

List<EntitySubscription>   es1 = [select Id from  EntitySubscription where SubscriberId =: j and ParentId NOT IN :grp ]; 

 

Am getting the following error. 

 

Error: AutoDeleteSubscriptions2 Compile Error: Invalid bind expression type of SOBJECT:Group does not match domain of foreign key

 

Please any one can help me on this how to retrive the entity subscriptions whose subscriber id not in the group.

 

 

 

 

  • January 16, 2013
  • Like
  • 0

The following in the SOQL query for Users

 

List<User> u = [SELECT Id FROM User];

 

Am able to get the id to iterate. Now i would like to get the id of Group standard object

List<Group> g = [SELECT Id FROM Group];

 

List<EntitySubscription>   es1 = [select Id from  EntitySubscription where SubscriberId =: j and ParentId NOT IN :usr ]; 

 

am retriving all entity subscriptions whose subscriber id not in the list of users. It is working fine. Now i want to retrive the entity subscriptions whose subscriber id not in the group also. For that i am writing the query like as above 

 

List<EntitySubscription>   es1 = [select Id from  EntitySubscription where SubscriberId =: j and ParentId NOT IN :grp ]; 

 

Am getting the following error. 

 

Error: AutoDeleteSubscriptions2 Compile Error: Invalid bind expression type of SOBJECT:Group does not match domain of foreign key

 

Please any one can help me on this how to retrive the entity subscriptions whose subscriber id not in the group.

 

the group is containing other groups ,users,roles and subordinates all so how to check that one in this. Please give idea on this.

 

 

  • January 16, 2013
  • Like
  • 0

The following in the SOQL query for Users

 

List<User> u = [SELECT Id FROM User];

 

Am able to get the id to iterate. Now i would like to get the id of Group standard object

List<Group> g = [SELECT Id FROM Group];

 

List<EntitySubscription>   es1 = [select Id from  EntitySubscription where SubscriberId =: j and ParentId NOT IN :usr ]; 

 

am retriving all entity subscriptions whose subscriber id not in the list of users. It is working fine. Now i want to retrive the entity subscriptions whose subscriber id not in the group also. For that i am writing the query like as above 

 

List<EntitySubscription>   es1 = [select Id from  EntitySubscription where SubscriberId =: j and ParentId NOT IN :grp ]; 

 

Am getting the following error. 

 

Error: AutoDeleteSubscriptions2 Compile Error: Invalid bind expression type of SOBJECT:Group does not match domain of foreign key

 

Please any one can help me on this how to retrive the entity subscriptions whose subscriber id not in the group.

 

 

 

 

 

  • January 16, 2013
  • Like
  • 0

When ever am inserting record into "Emp_7_10__c" this custom object am inserting follow on the chatter. But i want to delete those follow from the chatter. But when am deleting follow from the chatter the corresponding records also deleting.

 

Any one give idea how to delete only follows on the chatter.

 

the following code am using to insert follow on the chatter:

-------------------------------------------------------------------------------


trigger SendNotification on Emp_7_10__c (after insert)
{
 if( Trigger.isInsert)
 {
  for (Emp_7_10__c e : Trigger.new)
  {
   if ( e.Id != null)
   {
    FeedItem post = new FeedItem();
    post.ParentId = e.Id;
    post.Title = e.Name;
    post.Body = 'My custom Chatter Notification';
    post.LinkUrl = 'google.com';
    insert post;    
  }
  }
 }
}

=====================================================================

The following code am trying to delete follow from the chatter. But records also deleting from the object.

 

Emp_7_10__c[] emp = [select Id from Emp_7_10__c];
delete emp;

  • December 02, 2012
  • Like
  • 0

when ever am inserting record am displaying the EntitySubscription to the record owner chatter. How to delete this added EntitySubscription from the user chatter.

 

If record CreatedDate > 90days i want to delete those EntitySubscription from the chatter.

 

Give me ideas on this. how to delete EntitySubscription from the chatter.

 

The following is the code am using to add "EntitySubscription" to the chatter.

 

trigger EntySubscription on Employee__c(after insert)
{
public List<AccountTeamMember> teammember;
if ( Trigger.isInsert)
{
for (Employee__cest: Trigger.new)
{
if ( est.Id != null)
{
Account ac = [select Id,Name from Account where Id =: est.Account__c];


teammember = [ select Id, UserID, AccountId from AccountTeamMember where AccountId =: ac.Id];
System.debug('****************Team members**************'+teammember);

if( teammember != null && teammember.size() > 0)
{
for(Integer i=0; i<teammember.size();i++)
{
System.debug('*********User ID*****'+teammember+'*******'+teammember[i].UserID);

User u = [SELECT Id,Name FROM User where Id =:teammember[i].UserId];
System.debug('************User Name***************'+u.Name);

EntitySubscription follow = new EntitySubscription (
parentId = est.Id,
subscriberid = teammember[i].UserId ) ; //your User Id
insert follow;
}
}
}
}
}
}

 

  • December 01, 2012
  • Like
  • 0

How to write SOQL query to get the records CreatedDate > 90days

 

 

  • December 01, 2012
  • Like
  • 0

one way is using trigger we can update the past records while inserting new record.

 

I want to know what are the other way we can do to achieve this funtionality.

  • November 28, 2012
  • Like
  • 0

When ever we insert new record updating the new record field value to some value.

And all the past records values to some value. Instead of trigger is there any way to do it?

 

 

  • November 28, 2012
  • Like
  • 0

Is there any chance to fire validation rule only updating record instead of both insert and updating records

  • November 26, 2012
  • Like
  • 0


Following scenarios i want to achieve:
-------------------------------------
1) when ever i inserted new record into object updating all the existing records Most_Recent_Estimate__c = 'FALSE' & latest Most_Recent_Estimate__c = 'TRUE'
2) Allowing user to update today records
3) Dont allow user to update past records.Display error message if updating past records

 

I want to achieve all the above scenarios.

 

1 & 2,3 are working individually but after combining both getting error

 

But for while inserting records am getting error becoz of the following line

 "   update est[i]; " 

 

Can any one give ideas how to achieve these both functionalities both insert and update. While inserting skipping the update    validation or any other thing how to do?

 

trigger TriggerOnEstimate on Estimate__c (before insert,before update) {
if(Trigger.isInsert)
{
List<Estimate__c> est = [select Most_Recent_Estimate__c,Estimate_Name__c from Estimate__c ];
Date d = Date.today();
for ( Estimate__c e : Trigger.new)
{
for (Integer i =0 ;i<est.size() ; i++)
{
est[i].Most_Recent_Estimate__c = 'FALSE';
update est[i];
}
e.Most_Recent_Estimate__c = 'TRUE';
}
}
for(Estimate__c e: Trigger.new)

{
if(Trigger.isUpdate && e.CreatedDate == Date.today())
{
}
if(Trigger.isUpdate && e.CreatedDate < Date.today() )
{
e.addError('***********Donot edit the estimate***********');
}
}
}

  • November 26, 2012
  • Like
  • 0

trigger TriggerOnEstimate on Estimate__c (before insert,before update) {
 if(Trigger.isInsert)
 {
  Date d = Date.today();  
  for ( Estimate__c e : Trigger.new)
  {
   List<Estimate__c> est = [select Most_Recent_Estimate__c,Estimate_Name__c from Estimate__c ];
   System.debug('******All Estimates****'+est+'***Size***'+est.size());
   
   
   for (Integer i =0 ;i<est.size() ; i++)
   {
    est[i].Most_Recent_Estimate__c  = 'FALSE';
    update est[i];
   }
  // update est;
   
   e.Most_Recent_Estimate__c = 'TRUE';   
   
  }  
 } 
 for(Estimate__c e: Trigger.new)
 
   {
    if(Trigger.isUpdate && e.CreatedDate == Date.today())
    {
    
    }
    if(Trigger.isUpdate && e.CreatedDate < Date.today() )
    {
     e.addError('***********Donot edit the estimate***********');
    }
   }
}

  • November 25, 2012
  • Like
  • 0

Please suggest me how to send chatter notifications as mail like workflow email alert. I have this requirement.Please give ideas on this ASAP

  • November 11, 2012
  • Like
  • 0

The following in the SOQL query for Users

 

List<User> u = [SELECT Id FROM User];

 

Am able to get the id to iterate. Now i would like to get the id of Group standard object

List<Group> g = [SELECT Id FROM Group];

 

List<EntitySubscription>   es1 = [select Id from  EntitySubscription where SubscriberId =: j and ParentId NOT IN :usr ]; 

 

am retriving all entity subscriptions whose subscriber id not in the list of users. It is working fine. Now i want to retrive the entity subscriptions whose subscriber id not in the group also. For that i am writing the query like as above 

 

List<EntitySubscription>   es1 = [select Id from  EntitySubscription where SubscriberId =: j and ParentId NOT IN :grp ]; 

 

Am getting the following error. 

 

Error: AutoDeleteSubscriptions2 Compile Error: Invalid bind expression type of SOBJECT:Group does not match domain of foreign key

 

Please any one can help me on this how to retrive the entity subscriptions whose subscriber id not in the group.

 

 

 

 

 

  • January 16, 2013
  • Like
  • 0

one way is using trigger we can update the past records while inserting new record.

 

I want to know what are the other way we can do to achieve this funtionality.

  • November 28, 2012
  • Like
  • 0


Following scenarios i want to achieve:
-------------------------------------
1) when ever i inserted new record into object updating all the existing records Most_Recent_Estimate__c = 'FALSE' & latest Most_Recent_Estimate__c = 'TRUE'
2) Allowing user to update today records
3) Dont allow user to update past records.Display error message if updating past records

 

I want to achieve all the above scenarios.

 

1 & 2,3 are working individually but after combining both getting error

 

But for while inserting records am getting error becoz of the following line

 "   update est[i]; " 

 

Can any one give ideas how to achieve these both functionalities both insert and update. While inserting skipping the update    validation or any other thing how to do?

 

trigger TriggerOnEstimate on Estimate__c (before insert,before update) {
if(Trigger.isInsert)
{
List<Estimate__c> est = [select Most_Recent_Estimate__c,Estimate_Name__c from Estimate__c ];
Date d = Date.today();
for ( Estimate__c e : Trigger.new)
{
for (Integer i =0 ;i<est.size() ; i++)
{
est[i].Most_Recent_Estimate__c = 'FALSE';
update est[i];
}
e.Most_Recent_Estimate__c = 'TRUE';
}
}
for(Estimate__c e: Trigger.new)

{
if(Trigger.isUpdate && e.CreatedDate == Date.today())
{
}
if(Trigger.isUpdate && e.CreatedDate < Date.today() )
{
e.addError('***********Donot edit the estimate***********');
}
}
}

  • November 26, 2012
  • Like
  • 0