• 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.

 

 

 

 

 

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.


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***********');
}
}
}