• babranno
  • NEWBIE
  • 0 Points
  • Member since 2011

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 11
    Questions
  • 17
    Replies

I am desperate for some help.  I have a trigger and help class for the Task object.  It was originally written by our implementer but it appears that he failed to bulkify the trigger and helper class.  I have been trying to hack my way through fixing this with no luck and my company won't give me the money to hire someone to fix it.  I would appreciate any help I could get. 

 

This trigger and helper class is preventing me from updating 100,000+ tasks. 

 

Trigger

 

trigger TaskTrigger on Task (after insert, after update)
{
if(trigger.isAfter) TaskActions.UpdateLastActivityDate(trigger.new);
}

 

Helper Class

 

public with sharing class TaskActions 
{
  static public void UpdateLastActivityDate(List<Task> triggerTasks)
  {
    Set<Id> whatIds = new Set<Id>();
    Set<Id> whoIds = new Set<Id>();
    Set<Id> ownerIds = new Set<Id>();
    for(Task triggerTask:triggerTasks)
    {
      if(!whatIds.contains(triggerTask.WhatId)) whatIds.add(triggerTask.WhatId);
      if(!whoIds.contains(triggerTask.WhoId)) whoIds.add(triggerTask.WhoId);
      if(!ownerIds.contains(triggerTask.OwnerId)) ownerIds.add(triggerTask.OwnerId);
    }
    if(whatIds.size()>0&&ownerIds.size()>0)
    {
      Map<Id,User> ownerMap = new Map<Id,User>([SELECT Id, Profile.Name FROM User WHERE Id IN :ownerIds]);

      Map<Id,Contact> contactMap = new Map<Id,Contact>([SELECT Id, AccountId FROM Contact WHERE Id IN :whoIds]);
      for(Contact contact:contactMap.values()) { if(!whatIds.contains(contact.AccountId)) whatIds.add(contact.AccountId); }

      Map<Id,Applications__c> applicationMap = new Map<Id,Applications__c>([SELECT Id, Dealer__c FROM Applications__c WHERE Id IN :whatIds]);
      for(Applications__c application:applicationMap.values()) { if(!whatIds.contains(application.Dealer__c)) whatIds.add(application.Dealer__c); }

      Map<Id,Contract> contractMap = new Map<Id,Contract>([SELECT Id, AccountId FROM Contract WHERE Id IN :whatIds]);
      for(Contract contract:contractMap.values()) { if(!whatIds.contains(contract.AccountId)) whatIds.add(contract.AccountId); }

      Map<Id,Account> accountMap = new Map<Id,Account>([SELECT Id, Last_Activity_Date_ACA__c, Last_Activity_Date_AF__c, Last_Activity_Date_AFN__c FROM Account WHERE Id IN :whatIds]);

      Map<Id,Account> accountUpdateMap = new Map<Id,Account>();
      for(Task triggerTask:triggerTasks) 
      {
        Account account = accountUpdateMap.get(triggerTask.WhatId);
        if(account==null) account = accountMap.get(triggerTask.WhatId);
        if(account==null)
        {
          Applications__c application = applicationMap.get(triggerTask.WhatId);
          if(application!=null) account = accountMap.get(application.Dealer__c);
        }
        if(account==null)
        {
          Contract contract = contractMap.get(triggerTask.WhatId);
          if(contract!=null) account = accountMap.get(contract.AccountId);
        }
        if(account==null)
        {
          Contact contact = contactMap.get(triggerTask.WhoId);
          if(contact!=null) account = accountMap.get(contact.AccountId);
        }
        User owner = ownerMap.get(triggerTask.OwnerId);

        if(account!=null&&owner!=null)
        {
          if(owner.Profile.Name.Contains('ACA')||Test.isRunningTest()) account.Last_Activity_Date_ACA__c = triggerTask.LastModifiedDate.Date();
          if(owner.Profile.Name.Contains('AFN')||Test.isRunningTest()) account.Last_Activity_Date_AFN__c = triggerTask.LastModifiedDate.Date();
          if((!owner.Profile.Name.Contains('AFN')&&owner.Profile.Name.Contains('AF'))||Test.isRunningTest()) account.Last_Activity_Date_AF__c = triggerTask.LastModifiedDate.Date();

          //for testing only
          //account.Last_Activity_Date_ACA__c = triggerTask.LastModifiedDate.Date();
          //account.Last_Activity_Date_AFN__c = triggerTask.LastModifiedDate.Date();
          //account.Last_Activity_Date_AF__c = triggerTask.LastModifiedDate.Date();

          accountUpdateMap.put(account.Id,account);
        }
      }
      if(accountUpdateMap!=null&&accountUpdateMap.values().size()>0) update accountUpdateMap.values();
    }
  }

  static private testMethod void testAccountActions()
  {
    Account account = [SELECT Id, OwnerId FROM Account ORDER BY LastModifiedDate DESC LIMIT 1];
    Applications__c application = [SELECT Id, OwnerId FROM Applications__c WHERE Dealer__c != null ORDER BY LastModifiedDate DESC LIMIT 1];
    Contract contract = [SELECT Id, OwnerId FROM Contract WHERE AccountId != null ORDER BY LastModifiedDate DESC LIMIT 1];
    Contact contact = [SELECT Id, OwnerId FROM Contact WHERE AccountId != null ORDER BY LastModifiedDate DESC LIMIT 1];

    List<Task> tasks = new List<Task>();
    tasks.add(new Task(WhatId=account.Id,OwnerId=UserInfo.getUserId()));
    tasks.add(new Task(WhatId=application.Id,OwnerId=UserInfo.getUserId()));
    tasks.add(new Task(WhatId=contract.Id,OwnerId=UserInfo.getUserId()));
    tasks.add(new Task(WhoId=contact.Id,OwnerId=UserInfo.getUserId()));
    Test.StartTest();
    insert tasks;
    tasks = [SELECT Id, WhatId, WhoId, LastModifiedDate, OwnerId FROM Task WHERE Id IN:tasks];
    UpdateLastActivityDate(tasks);
    Test.StopTest();
  }
}

I wanted to see if anyone has run into this issue before.  We use rightfax for our e-mail server.  I need to be able to direct any e-mails/mass e-mails to a special address so that they can then be routed to our fax server.  Has anyone had any experience or know if it is possible to write a trigger that when an e-mail/mass e-mail is sent out of salesforce that it changes the To: e-mail address to one that we need the messages to go to along with modifying the header to the special syntax needed.

 

So essentially the user would do their normal e-mail message that they want to be a blast fax and then when they hit send my trigger would modify the To: address to route it to a special e-mail account and modifies the header so that when our account receives the e-mail it is then redirected to our fax server.

 

Thanks for any help.

 

Bladen

I have an apex trigger that checks to see if it is a new record and then updates a field and then is supposed to start an approval process.  If the record is being updated the it checks the old and new value of two fields and determines if they are the same.  If not it updates a field and then kicks off an approval process.  The issue I am running into on both an insert or update is that it cannot save the field that I am updating and then execute the approval process because the approval process locks the record.  Do I need a separate before insert,before update trigger that updates the field and then kick off the after insert,after update trigger to start the approval process.  I have included by trigger below.  I appreciate any help.

 

trigger ACHSubmitForApproval on ACH_Information__c (after insert,after update) {

If(Trigger.isInsert){

//Update ACH Information Changed

for(ACH_Information__c ach: Trigger.new){

ach.ACH_Information_Changed__c = TRUE;
// create the new approval request to submit
Approval.ProcessSubmitRequest req = new Approval.ProcessSubmitRequest();
req.setComments('Submitted for approval. Please approve.');
req.setObjectId(ach.Id);
// submit the approval request for processing
Approval.ProcessResult result = Approval.process(req);
// display if the reqeust was successful
System.debug('Submitted for approval successfully: '+result.isSuccess());}}
else{
If(Trigger.isUpdate){

for(ACH_Information__c ach: Trigger.new){

if((Trigger.oldMap.get(ach.id).Bank_Account__c != ach.Bank_Account__c) || (Trigger.oldMap.get(ach.id).Bank_Routing__c != ach.Bank_Routing__c)){

ach.ACH_Information_Changed__c = TRUE;
// create the new approval request to submit
Approval.ProcessSubmitRequest req = new Approval.ProcessSubmitRequest();
req.setComments('Submitted for approval. Please approve.');
req.setObjectId(ach.Id);
// submit the approval request for processing
Approval.ProcessResult result = Approval.process(req);
// display if the reqeust was successful
System.debug('Submitted for approval successfully: '+result.isSuccess());}
}
}
}
}

I am trying to create a task for someone listed on a custom object called Applications__c.  The user on the custom object is a lookup field to the User object.  Below is my query.  I have tried this several different ways all shown below, but each time I get an error when I try to save.  I have put the error below.  Any help would be appreciated.

 

 

Error

Error: Compile Error: Illegal assignment from Schema.SObjectField to Id at line 3 column 1

 

Trigger Version 1

 

trigger UWTask on Applications__c (before insert, before update, after insert, after update) {

 

ID s = Applications__c.Application_Underwriter__r.Id;
User uw = [Select Id from User Where Id = :s];


if(Applications__c.UW_Committed_Deal__c == 'True' && Applications__c.UW_Committed_Deal__c == 'False')
{Task t = new task();
t.Subject = 'UW App Follow-up';
t.OwnerID = uw;
t.ActivityDate = Date.today() + 1;
t.WhatId = Applications__c.ID;
t.RecordTypeId = '012E0000000PQRaIAO';
insert t;
}

}

 

Trigger Version 2

trigger UWTask on Applications__c (before insert, before update, after insert, after update) {

 

if(Applications__c.UW_Committed_Deal__c == 'True' && Applications__c.UW_Committed_Deal__c == 'False')

{Task t = new task();
t.Subject = 'UW App Follow-up';
t.OwnerID = Applications__c.Application_Underwriter__r.Id;
t.ActivityDate = Date.today() + 1;
t.WhatId = Applications__c.ID;
t.RecordTypeId = '012E0000000PQRaIAO';
insert t;
}

}


American Credit Acceptance located in Spartanburg, SC is looking for a Salesforce Administrator.  A qualified candidate will be required to work on premises in Spartanburg.  You can apply via the career builder link below or by forwarding your resume to Dana Gottman, dana.gottman@acacceptance.com.  Thank you.

 

http://www.careerbuilder.com/JobSeeker/Jobs/JobDetails.aspx?IPath=ILKGV0A&ff=21&APath=2.31.0.0.0&job_did=JHM1VG5W9H2DCMCG5ZN

 

Job Description

 

The Salesforce.com Administrator is responsible for leading the scoping, ongoing administration of and training on applications in American Credit Acceptance’s database of record, implemented on the Salesforce.com platform.  The database is currently used by American Credit Acceptance manage all sales within the organization.

 

Responsibilities

  • Administration
    • Manage  American Credit Acceptance’s database of record, implemented on the Salesforce.com platform, for all organization users
      • Perform basic administration of  American Credit Acceptance’s Salesforce.com instance
    • Regularly perform database de-duping and cleanup procedures
    • Manage ongoing support requests and administrative needs of users
    • Develop reports, dashboards, and processes to continuously monitor data quality and integrity
  • Training and Documentation
    • Develop training plans, materials, and documentation for database users, keep materials up-to-date, coordinate new user and ongoing training sessions worldwide
    • Develop and communicate a schedule for future database releases/enhancements
    • Monitor user adoption rates and respond as needed (additional training sessions, communication, modifications, or other resources) to improve
    • Assist users with report design and management
  • Planning
    • Define, communicate, and manage a change management (release) process to develop and implement new applications and updates to existing applications
  • Process Discovery and Management
    • Work with various functions and end users to identify, document, and communicate standard business processes as they related to the database
    • Work with development team to maintain, track and enhance American Credit Acceptance’s sales activities
    • Work with management to identify new and creative opportunities to leverage the database to support additional business processes or functions
  • Platform Integration
    • Work with online team to integrate web and online initiatives into the database
  • Vendor Management
    • Manage outsourced Salesforce.com implementation partners as required
    • Manage ongoing relationship with Salesforce.com and the Salesforce.com Foundation
  • Other responsibilities as defined

 

 Requirements

Basic Qualifications

  • Excellent project management skills
  • Experience with SFDC administration and implementation – 2yrs minimum
  • Proficient in data manipulation (Excel, Access, FileMaker Pro)
  • Knowledge of donor databases and database integration for websites useful
  • Bachelor’s Degree preferred
  • Ability to work in a fast paced, entrepreneurial environment
  • Ability to work independently or in a group
  • Ability to prioritize and manage multiple responsibilities
  • Flexibility and openness to change
  • Communicating clearly and concisely to individuals from various backgrounds
  • Influencing others in both verbal and written mediums
  • Entrepreneurial spirit
  • Hunger to learn and grow

 

Key Skills

  • Ability to administer Salesforce.com
  • Data manipulation and cleaning
  • Understanding Integration scenarios and design
  • Strong documentation and training skills
  • Interface with staff developing strategy as technical advisor

Does anyone know a validation rule that would prevent users from editing a field except through lead conversion.  We are trying to force a process and keep certain users from skipping the lead conversion/merging process and just jumping to editing the exisitng account.  These users need to be able to edit these fields but the first time the field is populated it needs to be done through lead conversion.  I appreciate any help/ideas.

 

Bladen

I am looking for some help on some code.  I am trying to auto number a numeric field and also check for duplicates and prevent them.  I took some code that was originally written for our implentation of SF and tweated it for the new object but I am new to apex and I am not sure what is going wrong.  I have included the code below along with the trigger.  I have tried playing with it but I cannot get it to populate the field with the auto number.  Any help would be appreciated.  Thank you.

 

Class

 

public without sharing class ProjectActions 
{
  static public void AssignRequestNumber(List<PPM_Project__c> triggerProjects)
  {
      integer maxRequestNumber = 0;
      AggregateResult[] results = [SELECT MAX(Request_Number__c) maxRequestNumber FROM PPM_Project__c];
      if (results!=null&&results.size() > 0) 
      {
        maxRequestNumber = integer.valueOf(results[0].get('maxRequestNumber'));
        }
        if(maxRequestNumber!=null && maxRequestNumber > 0)
        {
          for( PPM_Project__c project : triggerProjects)
          {
            if(PPM_Project__c.Request_Number__c == null )
            {
              maxRequestNumber = maxRequestNumber + 1;
              }
          }
        }
    }
  
  
  static public void DedupRequestNumbers(List<PPM_Project__c> triggerProjects)
  {
      Set<Decimal> requestNumbers = new Set<Decimal>();
      for(PPM_Project__c project : triggerProjects)
      {
        requestNumbers.add(project.Request_Number__c);
      }

      List<PPM_Project__c> maybeDupProjects = [Select Id, Request_Number__c From PPM_Project__c WHERE Request_Number__c IN :requestNumbers ORDER BY CreatedDate];
      
      List<PPM_Project__c> dupProjects = new List<PPM_Project__c>(); 
      Set<Decimal> nonDupRequestNumbers = new Set<Decimal>();
      for(PPM_Project__c maybeDupProject : maybeDupProjects)
      {
        if(nonDupRequestNumbers.contains(maybeDupProject.Request_Number__c))
        {
          dupProjects.add(maybeDupProject);
        }
        else
        {
          nonDupRequestNumbers.add(maybeDupProject.Request_Number__c);
        }
      }
      
      if(dupProjects!=null&&dupProjects.size()>0)
      {
        integer maxRequestNumber = 0;
        AggregateResult[] results = [SELECT MAX(Request_Number__c) maxRequestNumber FROM PPM_Project__c];
  
        if (results!=null&&results.size() > 0) 
        {
          maxRequestNumber = integer.valueOf(results[0].get('maxRequestNumber'));
          }
  
          if(maxRequestNumber!=null && maxRequestNumber > 0)
          {
            for( PPM_Project__c project : dupProjects)
              {
system.debug('\nmaxRequestNumber='+maxRequestNumber);          
                maxRequestNumber = maxRequestNumber + 1;
                }
            
          }
          update dupProjects;
      }
    
  
  
  }

  static private testMethod void testProjectActions()
  {
    
    PPM_Project__c project1 = new PPM_Project__c();
    project1.Name = 'TestAccount';


    PPM_Project__c project2 = new PPM_Project__c();
    project2.Name = 'TestAccount';


    PPM_Project__c project3 = new PPM_Project__c();
    project3.Name = 'TestAccount';


    List<PPM_Project__c> projects = new List<PPM_Project__c>();
    projects.add(project1);
    projects.add(project2);
    projects.add(project3);

    Test.StartTest();
  
    insert projects;

    system.debug('\nproject2.Request_Number__c='+project2.Request_Number__c);    
    system.debug('\nproject2.Request_Number__c='+project2.Request_Number__c);    
    ProjectActions.AssignRequestNumber(projects);

    
    update projects;

    Test.stopTest();
  }

}

 

 

Trigger 

 

trigger ProjectTrigger on PPM_Project__c (after insert, after update, before insert, before update)
{
 if (trigger.isBefore && trigger.isInsert) ProjectActions.AssignRequestNumber(trigger.new);
 if (trigger.isAfter && trigger.isInsert) ProjectActions.DedupRequestNumbers(trigger.new);
} 

I am looking for some help on populating a last activity date field.  I know that SF already records a last activity but we have several buisness lines that deal with one customer and we need a last activity date for each business line.  I know this will require a trigger to find the last activity by the assigned owners profile but I am not sure where to even start.  Any help would be appreciated.  Thank you.

I have a unique situation.  We have essentially three business lines that are competing against each other in some aspects of each business.  Because of this competition we want to limit who can follow who so that they are not able to read what is going on in each business.  I would appreciate any help in coming up with a way to automate this process.  Rather than having to set a corporate policy that will be difficult to enforce.  I saw the app on the app exchange but unfortunately it does not allow to unfollow people based on roles.  Thank you.

 

 

Bladen 

I have a unique situation.  We have essentially three business lines that are competing against each other in some aspects of each business.  Because of this competition we want to limit who can follow who so that they are not able to read what is going on in each business.  I would appreciate any help in coming up with a way to automate this process.  Rather than having to set a corporate policy that will be difficult to enforce.  I saw the app on the app exchange but unfortunately it does not allow to unfollow people based on roles.  Thank you.

 

Bladen

I am pretty new to salesforce and I am struggling to create a validation rule.  I want to use the ISCHANGED function with a phone or fax number.  So if the phone or fax number is changed on an account then it triggers a field update on a custom object.  The workflow keeps telling me that I cannot use ISCHANGED with a phone or fax number.  Does anyone have a work around?  Thanks for the help.

 

Bladen

I am desperate for some help.  I have a trigger and help class for the Task object.  It was originally written by our implementer but it appears that he failed to bulkify the trigger and helper class.  I have been trying to hack my way through fixing this with no luck and my company won't give me the money to hire someone to fix it.  I would appreciate any help I could get. 

 

This trigger and helper class is preventing me from updating 100,000+ tasks. 

 

Trigger

 

trigger TaskTrigger on Task (after insert, after update)
{
if(trigger.isAfter) TaskActions.UpdateLastActivityDate(trigger.new);
}

 

Helper Class

 

public with sharing class TaskActions 
{
  static public void UpdateLastActivityDate(List<Task> triggerTasks)
  {
    Set<Id> whatIds = new Set<Id>();
    Set<Id> whoIds = new Set<Id>();
    Set<Id> ownerIds = new Set<Id>();
    for(Task triggerTask:triggerTasks)
    {
      if(!whatIds.contains(triggerTask.WhatId)) whatIds.add(triggerTask.WhatId);
      if(!whoIds.contains(triggerTask.WhoId)) whoIds.add(triggerTask.WhoId);
      if(!ownerIds.contains(triggerTask.OwnerId)) ownerIds.add(triggerTask.OwnerId);
    }
    if(whatIds.size()>0&&ownerIds.size()>0)
    {
      Map<Id,User> ownerMap = new Map<Id,User>([SELECT Id, Profile.Name FROM User WHERE Id IN :ownerIds]);

      Map<Id,Contact> contactMap = new Map<Id,Contact>([SELECT Id, AccountId FROM Contact WHERE Id IN :whoIds]);
      for(Contact contact:contactMap.values()) { if(!whatIds.contains(contact.AccountId)) whatIds.add(contact.AccountId); }

      Map<Id,Applications__c> applicationMap = new Map<Id,Applications__c>([SELECT Id, Dealer__c FROM Applications__c WHERE Id IN :whatIds]);
      for(Applications__c application:applicationMap.values()) { if(!whatIds.contains(application.Dealer__c)) whatIds.add(application.Dealer__c); }

      Map<Id,Contract> contractMap = new Map<Id,Contract>([SELECT Id, AccountId FROM Contract WHERE Id IN :whatIds]);
      for(Contract contract:contractMap.values()) { if(!whatIds.contains(contract.AccountId)) whatIds.add(contract.AccountId); }

      Map<Id,Account> accountMap = new Map<Id,Account>([SELECT Id, Last_Activity_Date_ACA__c, Last_Activity_Date_AF__c, Last_Activity_Date_AFN__c FROM Account WHERE Id IN :whatIds]);

      Map<Id,Account> accountUpdateMap = new Map<Id,Account>();
      for(Task triggerTask:triggerTasks) 
      {
        Account account = accountUpdateMap.get(triggerTask.WhatId);
        if(account==null) account = accountMap.get(triggerTask.WhatId);
        if(account==null)
        {
          Applications__c application = applicationMap.get(triggerTask.WhatId);
          if(application!=null) account = accountMap.get(application.Dealer__c);
        }
        if(account==null)
        {
          Contract contract = contractMap.get(triggerTask.WhatId);
          if(contract!=null) account = accountMap.get(contract.AccountId);
        }
        if(account==null)
        {
          Contact contact = contactMap.get(triggerTask.WhoId);
          if(contact!=null) account = accountMap.get(contact.AccountId);
        }
        User owner = ownerMap.get(triggerTask.OwnerId);

        if(account!=null&&owner!=null)
        {
          if(owner.Profile.Name.Contains('ACA')||Test.isRunningTest()) account.Last_Activity_Date_ACA__c = triggerTask.LastModifiedDate.Date();
          if(owner.Profile.Name.Contains('AFN')||Test.isRunningTest()) account.Last_Activity_Date_AFN__c = triggerTask.LastModifiedDate.Date();
          if((!owner.Profile.Name.Contains('AFN')&&owner.Profile.Name.Contains('AF'))||Test.isRunningTest()) account.Last_Activity_Date_AF__c = triggerTask.LastModifiedDate.Date();

          //for testing only
          //account.Last_Activity_Date_ACA__c = triggerTask.LastModifiedDate.Date();
          //account.Last_Activity_Date_AFN__c = triggerTask.LastModifiedDate.Date();
          //account.Last_Activity_Date_AF__c = triggerTask.LastModifiedDate.Date();

          accountUpdateMap.put(account.Id,account);
        }
      }
      if(accountUpdateMap!=null&&accountUpdateMap.values().size()>0) update accountUpdateMap.values();
    }
  }

  static private testMethod void testAccountActions()
  {
    Account account = [SELECT Id, OwnerId FROM Account ORDER BY LastModifiedDate DESC LIMIT 1];
    Applications__c application = [SELECT Id, OwnerId FROM Applications__c WHERE Dealer__c != null ORDER BY LastModifiedDate DESC LIMIT 1];
    Contract contract = [SELECT Id, OwnerId FROM Contract WHERE AccountId != null ORDER BY LastModifiedDate DESC LIMIT 1];
    Contact contact = [SELECT Id, OwnerId FROM Contact WHERE AccountId != null ORDER BY LastModifiedDate DESC LIMIT 1];

    List<Task> tasks = new List<Task>();
    tasks.add(new Task(WhatId=account.Id,OwnerId=UserInfo.getUserId()));
    tasks.add(new Task(WhatId=application.Id,OwnerId=UserInfo.getUserId()));
    tasks.add(new Task(WhatId=contract.Id,OwnerId=UserInfo.getUserId()));
    tasks.add(new Task(WhoId=contact.Id,OwnerId=UserInfo.getUserId()));
    Test.StartTest();
    insert tasks;
    tasks = [SELECT Id, WhatId, WhoId, LastModifiedDate, OwnerId FROM Task WHERE Id IN:tasks];
    UpdateLastActivityDate(tasks);
    Test.StopTest();
  }
}

I have an apex trigger that checks to see if it is a new record and then updates a field and then is supposed to start an approval process.  If the record is being updated the it checks the old and new value of two fields and determines if they are the same.  If not it updates a field and then kicks off an approval process.  The issue I am running into on both an insert or update is that it cannot save the field that I am updating and then execute the approval process because the approval process locks the record.  Do I need a separate before insert,before update trigger that updates the field and then kick off the after insert,after update trigger to start the approval process.  I have included by trigger below.  I appreciate any help.

 

trigger ACHSubmitForApproval on ACH_Information__c (after insert,after update) {

If(Trigger.isInsert){

//Update ACH Information Changed

for(ACH_Information__c ach: Trigger.new){

ach.ACH_Information_Changed__c = TRUE;
// create the new approval request to submit
Approval.ProcessSubmitRequest req = new Approval.ProcessSubmitRequest();
req.setComments('Submitted for approval. Please approve.');
req.setObjectId(ach.Id);
// submit the approval request for processing
Approval.ProcessResult result = Approval.process(req);
// display if the reqeust was successful
System.debug('Submitted for approval successfully: '+result.isSuccess());}}
else{
If(Trigger.isUpdate){

for(ACH_Information__c ach: Trigger.new){

if((Trigger.oldMap.get(ach.id).Bank_Account__c != ach.Bank_Account__c) || (Trigger.oldMap.get(ach.id).Bank_Routing__c != ach.Bank_Routing__c)){

ach.ACH_Information_Changed__c = TRUE;
// create the new approval request to submit
Approval.ProcessSubmitRequest req = new Approval.ProcessSubmitRequest();
req.setComments('Submitted for approval. Please approve.');
req.setObjectId(ach.Id);
// submit the approval request for processing
Approval.ProcessResult result = Approval.process(req);
// display if the reqeust was successful
System.debug('Submitted for approval successfully: '+result.isSuccess());}
}
}
}
}

I am trying to create a task for someone listed on a custom object called Applications__c.  The user on the custom object is a lookup field to the User object.  Below is my query.  I have tried this several different ways all shown below, but each time I get an error when I try to save.  I have put the error below.  Any help would be appreciated.

 

 

Error

Error: Compile Error: Illegal assignment from Schema.SObjectField to Id at line 3 column 1

 

Trigger Version 1

 

trigger UWTask on Applications__c (before insert, before update, after insert, after update) {

 

ID s = Applications__c.Application_Underwriter__r.Id;
User uw = [Select Id from User Where Id = :s];


if(Applications__c.UW_Committed_Deal__c == 'True' && Applications__c.UW_Committed_Deal__c == 'False')
{Task t = new task();
t.Subject = 'UW App Follow-up';
t.OwnerID = uw;
t.ActivityDate = Date.today() + 1;
t.WhatId = Applications__c.ID;
t.RecordTypeId = '012E0000000PQRaIAO';
insert t;
}

}

 

Trigger Version 2

trigger UWTask on Applications__c (before insert, before update, after insert, after update) {

 

if(Applications__c.UW_Committed_Deal__c == 'True' && Applications__c.UW_Committed_Deal__c == 'False')

{Task t = new task();
t.Subject = 'UW App Follow-up';
t.OwnerID = Applications__c.Application_Underwriter__r.Id;
t.ActivityDate = Date.today() + 1;
t.WhatId = Applications__c.ID;
t.RecordTypeId = '012E0000000PQRaIAO';
insert t;
}

}


I am pretty new to salesforce and I am struggling to create a validation rule.  I want to use the ISCHANGED function with a phone or fax number.  So if the phone or fax number is changed on an account then it triggers a field update on a custom object.  The workflow keeps telling me that I cannot use ISCHANGED with a phone or fax number.  Does anyone have a work around?  Thanks for the help.

 

Bladen

a1O/e?
CF00NC00000052E9C={!Quote.Name}&
CF00NC00000052E9C={!Quote.Id}&
CF00NC00000052E4q={!QuoteLineItem.LineNumber}&
CF00NC00000052E4q={!QuoteLineItem.Id}&
CF00NC00000052E68={!Quote.End_User__c}&
CF00NC00000052E68={!Quote.End_UserId__c}&
save=x

This is my custom button, but only the Quote Line Item lookup is populating.  I am stumped as to what I am doing wrong.  

Clarification (14 minutes ago)

 

Right, it's a little tedious to do each one, I won't neccessarily need a custom object on every line item within a quote.  That's why I thought this button would do the trick and enough information could be pre-populated then it would lessen the tedious work. 

I changed the a1O/e? to /a1O/e?retURL={!QuoteLineItem.Id}& but it didn't make a difference. 

Would it matter that the look up on the quote line item is Master-Detail and on the Custom object is just a lookup?  That's the only difference I can find between my Contact-Account/Custom Object example and this current example.

Clarification (28 minutes ago)

 

But the quote line item has the Quote lookup on it's record (it's a Master-Detail).  So the last situtation where I did this was on a Contact record, I am pulling Contact and Account fields and lookup to a custom object.  Isn't that the same thing?

Clarification (50 minutes ago)

 

Of course, sorry about that!  We use the out-of-the-box quotes and quote line items that Salesforce provides.  I have created a custom object that I want to create off of the quote line item record.  So this custom button resides within the Quote Line Item object.  In my custom object, I have three lookups - Account, Quote & Quote Line Item.  All three of these lookups are also either on the Quote Line Item or Quote page, so I thought I could pull them through easy. I thought I had done something similar to this recently on a different object.

HELP!

 

Hello most excellent Apex development community-

 

I'm looking for an example of how you would go about assigning a task to a related user on a record who is NOT the owner of the record when certain conditions apply.  If anybody could help with this challenge, I would certainly appreciate it!

 

conditions would be

 

Record.Stage is Stage2 AND field X is complete, assign a Task with subject "Please make phone call within 24 hours" to a RELATED USER (Record.Related_User__c).

 

Thanks,

Aaron

The following formula will calculate the number of working days (inclusive) between 2 dates. A working day is defined as Monday to Friday. Even if the start or end dates are a weekend, these are accommodated.

IF(AND((5 - (CASE(MOD( Start_Date__c - DATE(1900, 1, 6), 7), 0, 0, 1, 5, 2, 5, 3, 4, 4, 3, 5, 2, 6, 1, 0)) < (CASE(MOD(  End_Date__c  - DATE(1900, 1, 6), 7), 0, 0, 1, 0, 2, 1, 3, 2, 4, 3, 5, 4, 6, 5, 0)) ),
((( End_Date__c  -   Start_Date__c ) + 1) < 7)),
((CASE(MOD(  End_Date__c  - DATE(1900, 1, 6), 7), 0, 0, 1, 0, 2, 1, 3, 2, 4, 3, 5, 4, 6, 5, 0)) - (5 - (CASE(MOD(  Start_Date__c  - DATE(1900, 1, 6), 7), 0, 0, 1, 5, 2, 5, 3, 4, 4, 3, 5, 2, 6, 1, 0)))),
(((FLOOR((( End_Date__c  -  Start_Date__c ) - (CASE(MOD(  Start_Date__c  - DATE(1900, 1, 6), 7), 0, 0, 1, 6, 2, 5, 3, 4, 4, 3, 5, 2, 6, 1, 0))) / 7)) * 5) +
(CASE(MOD(  Start_Date__c  - DATE(1900, 1, 6), 7), 0, 0, 1, 5, 2, 5, 3, 4, 4, 3, 5, 2, 6, 1, 0)) +
(CASE(MOD(  End_Date__c  - DATE(1900, 1, 6), 7), 0, 0, 1, 0, 2, 1, 3, 2, 4, 3, 5, 4, 6, 5, 0))))


The Start Date and End Date fields are custom in the above example and can be replaced as required. If use of a DateTime field is required then the DATEVALUE function will be required.

I also recommend a simple field validation rule is added to check that the End Date is after the Start Date.
  • January 05, 2009
  • Like
  • 2