• vaani kr
  • 5 Points
  • Member since 2021

  • Chatter
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
  • 6
Hi everyone!!

How to do with trigger?

Change contact owner on new record through trigger when industry = agriculture.
i'm having several problems with invalid emails on my org, i don't want to create validation rule. I want to create a method to check if the email is with the wrong syntax.

I'll leave some examples of the email I'm having problems.

the end of the emails are invalid, usually the BR is missing or it has numbers after the .com.br

  1. When the status of  Case is "Closed" then only the System Admin profile user should be able to edit the record. ( Use Custom Settings)
How to write a formula field fetching the first 3 digit of text field

Thanks in advance
Have some very simple code. Basically when a custom object (sales area) is updated, I want all the related opportunities the not won/lost opps that are related to it to be updated as well (which for most sales areas, is just 5-6 opps atm since this is a new process). I've tried a few dozen ways to get around the error in the title, have moved my update out of a for look as well as the select statement, but cannot for the life of me understand what I'm doing wrong?
trigger SalesAreaRelatedOpportunityUpdate on Sales_Area__c (after update) {
    List<ID> salesAreaId = new List<ID>(); 
        for (Sales_Area__c sa : Trigger.new){
        List <Opportunity> updateOps=[SELECT Id FROM Opportunity WHERE IsClosed=False AND (Sales_Area__c in :salesAreaId OR Secondary_Sales_Area__c in  :salesAreaId)];
        update updateOps;
Hi All,

I want to display number of contacts associated with an account using triggers.

for this I had created a lookup field like noofcontacts__c in account  object. and Wrote code as

trigger numberofcontacts on contact(after insert, after update, after delete) {
    Map<Id, List<Contact>> AcctContactList = new Map<Id, List<Contact>>();
    Set<Id> AcctIds = new Set<Id>();   
    List<schema.Account> AcctList = new List<schema.Account>();
    List<schema.Contact> ConList = new List<schema.Contact>();
    if(trigger.isInsert || trigger.isUPdate) {
        for(Contact Con : trigger.New) {
    if(trigger.isDelete) {
        for(Contact Con : trigger.Old) {
    if(AcctIds.size() > 0){
        ConList = [SELECT Id, AccountId FROM Contact WHERE AccountId IN : AcctIds];
        for(Contact Con : ConList) {
                AcctContactList.put(Con.AccountId, new List<Contact>());
        AcctList = [SELECT noofContacts__c FROM Account WHERE Id IN : AcctIds];
        for(Account Acc : AcctList) {
            List<schema.Contact> ContList = new List<schema.Contact>();
            ContList = AcctContactList.get(Acc.Id);
            Acc.Number_of_Contacts__c = ContList.size();
        update AcctList;   

 I am   getting an error as "Variable doesnot exist:id".

Kindly support and suggest.