• Vicia
  • NEWBIE
  • 0 Points
  • Member since 2012

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

Dears,

As I know customer portal users can access activities,but I don't know whether they can create activities?

If it does, please tell me how to do it ,

Best guards.

  • July 11, 2013
  • Like
  • 0

/*

Purpose: When there is nobody in Account Team,Users can not create contact under the account.

*/

trigger Contact_CanNotCreatetheContact on Contact (before insert) {

    for(Contact con:Trigger.new){

        List atmList = [SELECT UserId FROM AccountTeamMember  WHERE AccountId =:con.AccountId];

        if(atmList == NULL){

            Contact conOld = Trigger.newMap.get(con.Id);

            conOld.addError('There is no Account Team Member,you can not create account children!');

        }

   }

}

 

Here is my code,When, I create the contact under account with no account team member,there is no error message and nothing happend,Finally,I just save the new record.

 

Could you help my find the problem?

 

Thanks and best regards!

  • October 25, 2012
  • Like
  • 0

trigger OnAccount_ConfirmToChange on Account (before update) {
      List<Account> accList = [select Id,Name,(select AccountId,Name from Contacts) from account where Id =                   :Trigger.newMap.keySet()];
// Map<Id,Contact> conMap = new Map<Id,Contact>([select Id from Contact where AccountId in: accList.Id]);
     List<Contact> conList = [select Name,isAccountChanged__c from Contact where AccountId in: accList];
     for(Account acc:accList){
         for(Contact con:conList){
             if(conList.size() > 0){
                 if(con.isAccountChanged__c == false){
                 Account ar = Trigger.oldMap.get(acc.Id);
                 ar.addError('Only if the isAccountChanged is checked,You can modify the account!');
                }
           }
       }
    }
}

Hi, as the code abrove. I want to add a error message on updated account when its contact's field isAccountChanged__c  is false.But I get the error "System.FinalException: SObject row does not allow errors" ,could you help me?

  • September 05, 2012
  • Like
  • 0

trigger OnAccount_ConfirmToChange on Account (before update) {
  List<Account> accList = [select Id,Name,(select AccountId,Name from Contacts) from account where Id =                 :Trigger.newMap.keySet()];
// Map<Id,Contact> conMap = new Map<Id,Contact>([select Id from Contact where AccountId in: accList.Id]);
List<Contact> conList = [select Name,isAccountChanged__c from Contact where AccountId in: accList];
for(Account acc:accList){
for(Contact con:conList){
if(conList.size() > 0){
if(con.isAccountChanged__c == false){
Account ar = Trigger.oldMap.get(acc.Id);
ar.addError('Only if the isAccountChanged is checked,You can modify the account!');
}
}
}
}
}

  • September 05, 2012
  • Like
  • 0

i have to picklistfield 1, is from__c , in tis field data is HYD, BAN,PUNE
and 2. is to__c in this picklist data is BAN,PUNE,HYD,  , And another field is fare__c
now if i select from__c, to__c picklist values then i want field update for rare__c is 2500/-
so how can do this pls send me

/*

Purpose: When there is nobody in Account Team,Users can not create contact under the account.

*/

trigger Contact_CanNotCreatetheContact on Contact (before insert) {

    for(Contact con:Trigger.new){

        List atmList = [SELECT UserId FROM AccountTeamMember  WHERE AccountId =:con.AccountId];

        if(atmList == NULL){

            Contact conOld = Trigger.newMap.get(con.Id);

            conOld.addError('There is no Account Team Member,you can not create account children!');

        }

   }

}

 

Here is my code,When, I create the contact under account with no account team member,there is no error message and nothing happend,Finally,I just save the new record.

 

Could you help my find the problem?

 

Thanks and best regards!

  • October 25, 2012
  • Like
  • 0