• Sagar Lakhani
  • NEWBIE
  • 55 Points
  • Member since 2016

  • Chatter
    Feed
  • 2
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 23
    Replies
  • December 14, 2016
  • Like
  • 0
Hello,

I'm trying to create a trigger or a process builder to update an account status field when an opportunity populated on lookup field in account changed.
In fact I have a lookup field to opportunity on my account name's "Main_opportunity__c" and I want to update the account status when this "Main opportunity" is closed won.

Thanks to your answer
Thomas
Hello,

I have a custom object like below:
CustomObject1__c
   CustomField1__c (Picklist, values: Val1, Val2, Val3)
   CustomField2__c (Text: 100 char)
   CustomField3__c (Tex Area)

I have a visualforce page whcih displays the 3 input fields above like below
 
<apex:inputField value="{!CustomObject1__c.CustomField1__c }" />
<apex:inputField value="{!CustomObject1__c.CustomField2__c }" />
<apex:inputField value="{!CustomObject1__c.CustomField3__c}" />
Use case
1) When the CustomField1__c is changed to Val1, i want the below things to happen
> the CustomField2__c is updated to "recordtypename+username+val1"
>the CustomField3__c is updated to
 "the user name is username, record type name isrecordtypename and the value selected is Val1
Date:
Time:
 "
Thanks for suggestions !

 
trigger TasksonLeads on Lead (after update) {

    for (Lead l : Trigger.new) {  
        
        if (l.status == 'Awaiting First Call Attempt' 
        && l.aux_reporting_min_req_mql_tasks__c == false
        && l.aux_reporting_first_assigned__c == true
        && l.aux_scoring_first_attempt__c == false
        && l.min_req_mql_landlord__c == null)
    
            {
        
                Task Landlord = new Task();
            
                    String userId = UserInfo.getUserId();
        
                    Landlord.Subject = '1. Is it a landlord?';
                    Landlord.Priority = 'Normal';
                    Landlord.Status = 'Open';
                    Landlord.OwnerId = userId;
                    Landlord.WhatId = l.Id;
                   
                insert Landlord;
                
             }
        
        }
        
}

How can I put the Task in the correct Lead ?

It's giving me this error :

User-added image

Thanks!
Hi,
I have following After Update Trigger... I have to write test class for same...
Please some one help me..?

trigger AccountChanged on Asset (after update) {

    List<Opportunity> OppList= new List<Opportunity>();
   
    for (Asset newAsset : Trigger.new) {

                                        // If account of equipment is changed..
        if ( newAsset.AccountId != Trigger.oldMap.get( newAsset.Id ).AccountId ){    
            
                                        //Create new Opportunity for Sales i.e. OEM Record Type...
            Opportunity newOpp1 = new Opportunity();
            
            Id oppRecordTypeId1 = Schema.SObjectType.Opportunity.getRecordTypeInfosByName().get('OEM').getRecordTypeId();
            newOpp1.RecordTypeId = oppRecordTypeId1;
            
            
            newOpp1.Asset__c = newAsset.id;
            newOpp1.Name = 'New Sales Opportunity';
            newOpp1.AccountId = newAsset.AccountId;
            newOpp1.StageName = 'Qualification';
            newOpp1.CloseDate = system.today();
            

            OppList.add(newOpp1);
            
          
                                            //Create new Opportunity for Parts i.e. Parts Record Type...
            Opportunity newOpp2 = new Opportunity();
            
            Id oppRecordTypeId2 = Schema.SObjectType.Opportunity.getRecordTypeInfosByName().get('Parts').getRecordTypeId();
            newOpp2.RecordTypeId = oppRecordTypeId2;
            
            
            newOpp2.Asset__c = newAsset.id;
            newOpp2.Name = 'New Parts Opportunity';
            newOpp2.AccountId = newAsset.AccountId;
            newOpp2.StageName = 'Qualification';
            newOpp2.CloseDate = system.today();
            

            OppList.add(newOpp2);
            
            If(OppList.Size()>0){
            Insert OppList;
            }
        }

    }
}
  • December 14, 2016
  • Like
  • 0
Hello,

I'm trying to create a trigger or a process builder to update an account status field when an opportunity populated on lookup field in account changed.
In fact I have a lookup field to opportunity on my account name's "Main_opportunity__c" and I want to update the account status when this "Main opportunity" is closed won.

Thanks to your answer
Thomas

Does anyone know how? there is no standard controller for Tasks...