• Chris - ARI
  • NEWBIE
  • 15 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 7
    Questions
  • 22
    Replies
Hi All,

I'm pretty sure I can kick this process off (the rule criteria) in  Process Builder. However I don't believe the rest can be done without Apex. Can you help me out?

Object: Task

Rule Critria: Status = 'Completed' AND Response Type (custom picklist field) = 'Good Response'
This will either happen on a lead or a contact.

Action: Delete all activities where Status != 'Completed' AND where Process Type (custom text field) = 'Decision Tree'
I want to delete only the activites on the same related lead or contact where the task was updated.
I want to be able to see what products have been selected on an opportunity at the account level. I have read that assets is the best way to do this but I am unsure of where to start. Any help is appreciated.
I am trying to create a new button which mimics the same exact features as the new task button. I want to use visualforce for this as well.

There are a few problems I came across which I can not seem to figure out.

1. Assigned To Field does not autopopulate.
2. Related to Account Field does not autopopulate.
3. Related to Contact Field does not autopopulate.
4. Upon saving the task it brings me to the Home tab instead of going back to the account or contact the task was created on.

How do I fix these issues?  Thanks to anyone who gives this a  shot!
I recently inherited a Salesforce org with almost no code coverage. I am trying to write some test classes for the triggers already in production. The test keeps failing with the below error and I think it is related to the trigger. Can someone shed some light on the below error? My developer skils are very basic.

Test Class:
@isTest
public class Test_OppWonChatter {
    static testMethod void insertNewOpportunity(){

        Opportunity o = new Opportunity();
        o.name = 'Test';
        o.AccountId = '0015500000GE3OS';
        o.StageName = 'Closed Won';
        o.CloseDate = date.today();
        o.Type = 'New Customers';
        
        insert o;
    }
}



Error:
Time Started8/22/2016 2:57 PM
ClassTest_OppWonChatter
Method NameinsertNewOpportunity
Pass/FailFail
Error MessageSystem.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, OppWonChatter: execution of AfterInsert

caused by: System.DmlException: Insert failed. First exception on row 0; first error: INVALID_CROSS_REFERENCE_KEY, invalid cross reference id: []

Trigger.OppWonChatter: line 31, column 1: []
Stack TraceClass.Test_OppWonChatter.insertNewOpportunity: line 12, column 1

Trigger:
trigger OppWonChatter on Opportunity (after insert, after update) {

String status;
String OppAccName;
String OppOwnerName;
String OppName;   
FeedItem post = new FeedItem();
    
    for(Opportunity o : Trigger.new) {
        if(o.OwnerId == '00560000001NLvS') { //It will not post record for for this user to group. Accountsys
            return;
        }
        else { 
            if(Trigger.isInsert ) { 
                if( o.IsWon == true ) { //This will be executed on new record insertion 
                    for (Opportunity oppty : [SELECT Account.Name, Owner.Name, Name FROM Opportunity WHERE Id =:o.Id] ) {
                        OppAccName = oppty.Account.Name;
                     OppName = oppty.Name;
                    
                        
                        OppOwnerName = oppty.Owner.Name;
                    }   
                    
                    status = OppOwnerName + ' just won ' + OppName + '!';

                                                             
                    post.ParentId = '0F960000000Xbrr';
                    post.Title = o.Name;   
                    post.Body = status;
                    
                    insert post;
                }
            }    
            else {
                if ( Trigger.isUpdate ) {
                    if( o.IsWon == true ) { //This will be executed on update to existing record
                        for (Opportunity oppty : [SELECT Account.Name, Owner.Name, Name FROM Opportunity WHERE Id =:o.Id] ) {
                            OppName = oppty.Name;
                            OppAccName = oppty.Account.Name;  
                            OppOwnerName = oppty.Owner.Name; 
                        }        
                        status = OppOwnerName + ' just won ' + OppName + '!';
                                            
                        post.ParentId = '0F960000000Xbrr';
                        post.Title = o.Name;
                        post.Body = status;
                        
                        insert post;      
                    }
                }
            }
        }
    }    
}

 
Test Class keeps failing. What is wrong here?
 
@isTest
public class Test_OppWonChatter {
    static testMethod void insertNewOpportunity(){
        
        Account a = new Account(Name = 'Test');
        
        insert a;
        
        
        Opportunity o = new Opportunity();
        o.name = 'Test';
        o.AccountId = a.Id;
        o.StageName = 'Closed Won';
        o.CloseDate = date.today();
        o.Type = 'New Customers';
        
        insert o;
    }
}

 
Im sure this is a simple mistake as I do not have much coding experience. It says my error is on line 5.

I am trying to update the field GUI on the account if it is blank. I want it to update with the Candian GUI if there is an accout populated in the related field "Canada_Account".
 
trigger Update_GUI on Account (before insert, before update) {
    for(Account acc : Trigger.new){
        if(acc.GUI__c = null){
            if(acc.Canada_Account__c != null){
                acc.GUI__c == acc.Canada_Account__r.GUI__c;
            }
        }
    }
}

 
Hi All,

I'm pretty sure I can kick this process off (the rule criteria) in  Process Builder. However I don't believe the rest can be done without Apex. Can you help me out?

Object: Task

Rule Critria: Status = 'Completed' AND Response Type (custom picklist field) = 'Good Response'
This will either happen on a lead or a contact.

Action: Delete all activities where Status != 'Completed' AND where Process Type (custom text field) = 'Decision Tree'
I want to delete only the activites on the same related lead or contact where the task was updated.
I recently inherited a Salesforce org with almost no code coverage. I am trying to write some test classes for the triggers already in production. The test keeps failing with the below error and I think it is related to the trigger. Can someone shed some light on the below error? My developer skils are very basic.

Test Class:
@isTest
public class Test_OppWonChatter {
    static testMethod void insertNewOpportunity(){

        Opportunity o = new Opportunity();
        o.name = 'Test';
        o.AccountId = '0015500000GE3OS';
        o.StageName = 'Closed Won';
        o.CloseDate = date.today();
        o.Type = 'New Customers';
        
        insert o;
    }
}



Error:
Time Started8/22/2016 2:57 PM
ClassTest_OppWonChatter
Method NameinsertNewOpportunity
Pass/FailFail
Error MessageSystem.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, OppWonChatter: execution of AfterInsert

caused by: System.DmlException: Insert failed. First exception on row 0; first error: INVALID_CROSS_REFERENCE_KEY, invalid cross reference id: []

Trigger.OppWonChatter: line 31, column 1: []
Stack TraceClass.Test_OppWonChatter.insertNewOpportunity: line 12, column 1

Trigger:
trigger OppWonChatter on Opportunity (after insert, after update) {

String status;
String OppAccName;
String OppOwnerName;
String OppName;   
FeedItem post = new FeedItem();
    
    for(Opportunity o : Trigger.new) {
        if(o.OwnerId == '00560000001NLvS') { //It will not post record for for this user to group. Accountsys
            return;
        }
        else { 
            if(Trigger.isInsert ) { 
                if( o.IsWon == true ) { //This will be executed on new record insertion 
                    for (Opportunity oppty : [SELECT Account.Name, Owner.Name, Name FROM Opportunity WHERE Id =:o.Id] ) {
                        OppAccName = oppty.Account.Name;
                     OppName = oppty.Name;
                    
                        
                        OppOwnerName = oppty.Owner.Name;
                    }   
                    
                    status = OppOwnerName + ' just won ' + OppName + '!';

                                                             
                    post.ParentId = '0F960000000Xbrr';
                    post.Title = o.Name;   
                    post.Body = status;
                    
                    insert post;
                }
            }    
            else {
                if ( Trigger.isUpdate ) {
                    if( o.IsWon == true ) { //This will be executed on update to existing record
                        for (Opportunity oppty : [SELECT Account.Name, Owner.Name, Name FROM Opportunity WHERE Id =:o.Id] ) {
                            OppName = oppty.Name;
                            OppAccName = oppty.Account.Name;  
                            OppOwnerName = oppty.Owner.Name; 
                        }        
                        status = OppOwnerName + ' just won ' + OppName + '!';
                                            
                        post.ParentId = '0F960000000Xbrr';
                        post.Title = o.Name;
                        post.Body = status;
                        
                        insert post;      
                    }
                }
            }
        }
    }    
}

 
Test Class keeps failing. What is wrong here?
 
@isTest
public class Test_OppWonChatter {
    static testMethod void insertNewOpportunity(){
        
        Account a = new Account(Name = 'Test');
        
        insert a;
        
        
        Opportunity o = new Opportunity();
        o.name = 'Test';
        o.AccountId = a.Id;
        o.StageName = 'Closed Won';
        o.CloseDate = date.today();
        o.Type = 'New Customers';
        
        insert o;
    }
}

 
Im sure this is a simple mistake as I do not have much coding experience. It says my error is on line 5.

I am trying to update the field GUI on the account if it is blank. I want it to update with the Candian GUI if there is an accout populated in the related field "Canada_Account".
 
trigger Update_GUI on Account (before insert, before update) {
    for(Account acc : Trigger.new){
        if(acc.GUI__c = null){
            if(acc.Canada_Account__c != null){
                acc.GUI__c == acc.Canada_Account__r.GUI__c;
            }
        }
    }
}

 
I have a related list on the Account page layout (see image) that shows the products that are associated with opportunities. (Accomplished via a lookup relationship on the Opportunity Product object) However, it shows the products from ALL Opportunities, and we only want to see these details for closed won Opps. What is the best way to get the products from open or lost Opps filtered out of this list? (We definitely want to use a related list solution and not Assets on the Account object.)

User-added image
Is there something special that I have to do to have ProcessBuilder findmy email templates?

Is it possible to filter out only contact related to an account in a case object. When a case is created from account, it has the account field in case populated with the account name/Id. I want to select contact and the lookup should only show contacts related to this account. Is this possible?
I have a filter criteria case: Account Name ID Equals Contact Name : Account Name : Account ID. Event then it is not working.

Hi:

   I want to re-create the Task Page in Visualforce and have the Whoid and what id filled in. Now, I can get this to work if I dont use the VF task page and use the standard task page. But I can not get it to work on the VF Page??/

Basically a user will click new task and it will open up this VF task page and have the whoid and whatid filled in automatically through URL. Do not know how to:

 

public PageReference Monitor(){

    moni = new List<History__c>(
            [SELECT  id,
            Student__c
            FROM History__c 
            where Student__c=:ApexPages.currentPage().getParameters().get('oppIdd')
            AND id=:ApexPages.currentPage().getParameters().get('oppIddc')
            ]);
 
    
   //PageReference newpage = new PageReference('/00T/e?who_id=' + monitorstudent[0].Student__c+ '&what_id=' + monitorstudent[0].Id + '&retURL=%2Fhome%2Fhome.jsp');
    PageReference newpage = new PageReference('/apex/Task?who_id=' + monitorstudent[0].Student__c+ '&what_id=' + monitorstudent[0].Id );

        newpage.setRedirect(true);
        return newpage; 
} 
<apex:page standardController="Task" sidebar="false">

    <apex:form >
        <apex:pageBlock title="Edit Task" id="thePageBlock" mode="edit">
            <apex:pageMessages />
            <apex:pageBlockButtons >
                <apex:commandButton value="Save" action="{!save}"/>
                <apex:commandButton value="Cancel" action="{!cancel}"/>                
            </apex:pageBlockButtons>
            <apex:actionRegion >
                <apex:pageBlockSection title="Basic Information" columns="1">
                <apex:inputField value="{!Task.Ownerid}"/>
                    <apex:pageBlockSectionItem >
                        <apex:outputLabel value="Subject"/>
                            <apex:inputField value="{!Task.Subject}"/>
                    </apex:pageBlockSectionItem>
                    <apex:inputField value="{!Task.whoid}"/>
                    <apex:inputField value="{!Task.whatid}"/>
                </apex:pageBlockSection>
            </apex:actionRegion>

        </apex:pageBlock>
    </apex:form>

</apex:page>

 

 

Please help me figure this out. Thanks

ETechCareers