• Richard Valencia
  • NEWBIE
  • 10 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 5
    Replies
I have a process flow that is kicked of when the contact record's "Active" checkbox is marked from true to false. This flow does a few things like removing the email/phone number, It also marks the first name with two asterisk to help identify contacts that are no longer active in searches/look-ups. 
 
The issue that we are facing is that users are adding the asterisks to the first name field and not following the process. So now we have Contacts with asterisks indicated they are no longer with the company but the active checkbox is still set to true. The Checkbox should be the source of truth when it come to this process. 
 
The Ask: 
Need help with a Validation rule that prevents users from updating the first name field with an asterisk if the contact is still marked as active. 
 
Thank you in advance Community! 
I'm currently moving my team over to lighting and I'm needing help with converting a custom Java button that can not be converted by the Salesforce Converter tool. 

My custom button lives in a Custom object and is placed on the Related list. The buttom currently allows users to make the checkbox = ture and and then select the "Complete" button(JS) which will then mark all the selected records as "Completed" this is currenlty working in Classic but not avliable in lighting. 
User-added imageJava code for classic button: 

{!REQUIRESCRIPT("/soap/ajax/36.0/connection.js")};
{!REQUIRESCRIPT("/soap/ajax/36.0/apex.js")};
var records1 = {!GETRECORDIDS($ObjectType.Milestone1_Task__c)}; 
var newRecords = [];
var taskRec = sforce.connection.query('select id,name,Task_Stage__c from Milestone1_Task__c where id in (\'' + records1.join('\',\'') + '\')' );

var tasks = taskRec.getArray("records"); 
var arrayLength = tasks.length;
if(records1==null || records1=='') { 
  alert('No records selected'); 

else{
    for(var i=0;i<arrayLength;i++){
       var tsk = new sforce.SObject("Milestone1_Task__c");
       tsk.Id = tasks[i].Id;
       tsk.Task_Stage__c = 'Completed';
       newRecords.push(tsk);
    }
    
    result = sforce.connection.update(newRecords); 
        window.location.reload();
}

User-added image
ery new to Triggers and hoping this is a simple replacement of text in the code we already have working in the Account object that was built when we had a Dev support.

What I'm trying to do is make my trigger that I already have work the same way but for cases. When we build Cases we relate it to the account via a lookup and that then brings in the Account Manager, what we need to happen is that whenever the account manager creates either a New task, New Event, Log a call, Mail Merge, or Send an Email it updates the "Last Activity Date" field in the Account object. Here's the Triggers I have for tasks and events:

public class TaskTriggerHandler {
    public static void updateAccountLastActivityDate(){
        List<Task> tskList = (Task[])Trigger.New;
    Set<Id> tskIds = new Set<Id>();
    List<Account> accountsToUpdate = new List<Account>();
    for(Task tsk : tskList){
        system.debug('Account id '+tsk.AccountId);
            tskIds.add(tsk.AccountId);
    }
    List<Account> accList= [Select id,Account_Manager__c,Last_Activity_Date__c,Account_Status__c  from Account where id IN :tskIds];
        system.debug('accList: '+accList);
    if(accList.size() > 0){
        for(Account acc : accList){
            if(acc.Account_Manager__c == UserInfo.getUserId() && acc.Account_Status__c == 'Active' || Test.isRunningTest()){
               acc.Last_Activity_Date__c = Date.today();
              accountsToUpdate.add(acc);   
            }
        }    
    }
    if(accountsToUpdate.size() > 0){
        update accountsToUpdate;
    }
    }
}

public class EventTriggerHandler {
    public static void updateAccountLastActivityDate(){
    List<Event> evtList = (Event[])Trigger.New;
    Set<Id> evtIds = new Set<Id>();
    List<Account> accountsToUpdate = new List<Account>();
    for(Event evt : evtList){
        
        evtIds.add(evt.AccountId);
    }
    List<Account> accList= [Select id,Account_Manager__c,Last_Activity_Date__c,Account_Status__c  from Account where id IN :evtIds];
    if(accList.size() > 0){
        for(Account acc : accList){
            if(acc.Account_Manager__c == UserInfo.getUserId() && acc.Account_Status__c == 'Active' || Test.isRunningTest()){
                acc.Last_Activity_Date__c = Date.today();
                accountsToUpdate.add(acc);
            }
        }    
    }
    if(accountsToUpdate.size() > 0){
        update accountsToUpdate;
    }
    }
}

As a user when trying to upload an attachment in any object i need to be remind of a document that should NOT be inculded. 

example: 

While in an account, when I select add attach file, i would like a reminder that states "Please remove any documents with customer credit card numbers"  

I'm currently moving my team over to lighting and I'm needing help with converting a custom Java button that can not be converted by the Salesforce Converter tool. 

My custom button lives in a Custom object and is placed on the Related list. The buttom currently allows users to make the checkbox = ture and and then select the "Complete" button(JS) which will then mark all the selected records as "Completed" this is currenlty working in Classic but not avliable in lighting. 
User-added imageJava code for classic button: 

{!REQUIRESCRIPT("/soap/ajax/36.0/connection.js")};
{!REQUIRESCRIPT("/soap/ajax/36.0/apex.js")};
var records1 = {!GETRECORDIDS($ObjectType.Milestone1_Task__c)}; 
var newRecords = [];
var taskRec = sforce.connection.query('select id,name,Task_Stage__c from Milestone1_Task__c where id in (\'' + records1.join('\',\'') + '\')' );

var tasks = taskRec.getArray("records"); 
var arrayLength = tasks.length;
if(records1==null || records1=='') { 
  alert('No records selected'); 

else{
    for(var i=0;i<arrayLength;i++){
       var tsk = new sforce.SObject("Milestone1_Task__c");
       tsk.Id = tasks[i].Id;
       tsk.Task_Stage__c = 'Completed';
       newRecords.push(tsk);
    }
    
    result = sforce.connection.update(newRecords); 
        window.location.reload();
}

User-added image
ery new to Triggers and hoping this is a simple replacement of text in the code we already have working in the Account object that was built when we had a Dev support.

What I'm trying to do is make my trigger that I already have work the same way but for cases. When we build Cases we relate it to the account via a lookup and that then brings in the Account Manager, what we need to happen is that whenever the account manager creates either a New task, New Event, Log a call, Mail Merge, or Send an Email it updates the "Last Activity Date" field in the Account object. Here's the Triggers I have for tasks and events:

public class TaskTriggerHandler {
    public static void updateAccountLastActivityDate(){
        List<Task> tskList = (Task[])Trigger.New;
    Set<Id> tskIds = new Set<Id>();
    List<Account> accountsToUpdate = new List<Account>();
    for(Task tsk : tskList){
        system.debug('Account id '+tsk.AccountId);
            tskIds.add(tsk.AccountId);
    }
    List<Account> accList= [Select id,Account_Manager__c,Last_Activity_Date__c,Account_Status__c  from Account where id IN :tskIds];
        system.debug('accList: '+accList);
    if(accList.size() > 0){
        for(Account acc : accList){
            if(acc.Account_Manager__c == UserInfo.getUserId() && acc.Account_Status__c == 'Active' || Test.isRunningTest()){
               acc.Last_Activity_Date__c = Date.today();
              accountsToUpdate.add(acc);   
            }
        }    
    }
    if(accountsToUpdate.size() > 0){
        update accountsToUpdate;
    }
    }
}

public class EventTriggerHandler {
    public static void updateAccountLastActivityDate(){
    List<Event> evtList = (Event[])Trigger.New;
    Set<Id> evtIds = new Set<Id>();
    List<Account> accountsToUpdate = new List<Account>();
    for(Event evt : evtList){
        
        evtIds.add(evt.AccountId);
    }
    List<Account> accList= [Select id,Account_Manager__c,Last_Activity_Date__c,Account_Status__c  from Account where id IN :evtIds];
    if(accList.size() > 0){
        for(Account acc : accList){
            if(acc.Account_Manager__c == UserInfo.getUserId() && acc.Account_Status__c == 'Active' || Test.isRunningTest()){
                acc.Last_Activity_Date__c = Date.today();
                accountsToUpdate.add(acc);
            }
        }    
    }
    if(accountsToUpdate.size() > 0){
        update accountsToUpdate;
    }
    }
}

As a user when trying to upload an attachment in any object i need to be remind of a document that should NOT be inculded. 

example: 

While in an account, when I select add attach file, i would like a reminder that states "Please remove any documents with customer credit card numbers"