• Bobby Bosler
  • NEWBIE
  • 0 Points
  • Member since 2011

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 5
    Replies

Hello,

 

I am a new Salesforce Admin trying to develop our nonprofit's database for production by January. I am trying to deploy the below into production, however dont know how to write a test class and was hoping someone could help. I tried looking at the beginner's guide, but I don't even have a solid base in JS or C# to begin understanding their guide. Furthermore, I'm not sure where or how to apply the tests: in the Sandbox or Production? Here's the code:

 

Here is my class:

 

public class ContactCopyUtil {
  public static boolean isRecursive = false;

  @future
  public static void copyFrom(set<id> oppids) {
    isRecursive = true;
    List<Opportunity> opps = new List<opportunity>();
    for(Opportunity o:[select id,primary_contact__c,(select id,role,contactid from opportunitycontactroles where isprimary=true) from opportunity where id in :oppids])
      if(o.opportunitycontactroles<>null &&
         o.opportunitycontactroles.size()==1 &&
         o.opportunitycontactroles[0].contactid<>o.primary_contact__c)
        opps.add(new Opportunity(id=o.id,
          primary_contact__c=o.opportunitycontactroles[0].contactid));
    update opps;
  }
}

 Here's the trigger:

 

trigger PrimaryContactCopy on Opportunity(after insert, after update) {
  if(!ContactCopyUtil.isRecursive)
    ContactCopyUtil.copyFrom(Trigger.newmap.keyset());
}

 

 

Hello,

 

I am a new Salesforce Admin trying to develop our nonprofit's database for production by January. I am trying to deploy the below into production, however dont know how to write a test class and was hoping someone could help. I tried looking at the beginner's guide, but I don't even have a solid base in JS or C# to begin understanding their guide. Furthermore, I'm not sure where or how to apply the tests: in the Sandbox or Production? Here's the code:

 

Here is my class:

 

public class ContactCopyUtil {
  public static boolean isRecursive = false;

  @future
  public static void copyFrom(set<id> oppids) {
    isRecursive = true;
    List<Opportunity> opps = new List<opportunity>();
    for(Opportunity o:[select id,primary_contact__c,(select id,role,contactid from opportunitycontactroles where isprimary=true) from opportunity where id in :oppids])
      if(o.opportunitycontactroles<>null &&
         o.opportunitycontactroles.size()==1 &&
         o.opportunitycontactroles[0].contactid<>o.primary_contact__c)
        opps.add(new Opportunity(id=o.id,
          primary_contact__c=o.opportunitycontactroles[0].contactid));
    update opps;
  }
}

 Here's the trigger:

 

trigger PrimaryContactCopy on Opportunity(after insert, after update) {
  if(!ContactCopyUtil.isRecursive)
    ContactCopyUtil.copyFrom(Trigger.newmap.keyset());
}

 

 

I've written a trigger in my sandbox to copy the primary contact Role and ID values into 2 opportunity custom fields but it's not firing and I just cant figure out why.

 

Any help would be appreciated, I'm sure it's an oversight on my part.

 

Trigger PrimaryContactCopy on Opportunity(before insert,before update){
OpportunityContactRole Roles = new OpportunityContactRole();
for(Opportunity opp:Trigger.new){
Roles = [select Id,IsPrimary,ContactId, Role from OpportunityContactRole where IsPrimary=True AND opportunity.id=:opp.Id];
opp.Name__c = Roles.ContactId;
opp.Email__c = Roles.Role;
update opp;
 } 
}

 

  • December 13, 2010
  • Like
  • 0

I thought this would be a solved issue, as it's a fundamental business process for thousands of different businesses that log calls and emails via Tasks.

 

Please let me know if I'm missing something obvious, but there seems to be a serious problem with how to measure incoming and out going calls.

 

When logging a call, we have a "Type" a "Subject".

 

There is a standard SFDC field on Activities called "Call Type"

 

Typically Business have incoming and outgoing (or internal) calls and emails, 

 

So this field "Call Type" has the non editable values of "Inbound, Outbound, Internal"

 

When a user is logging a call - they should create the "Subject" the "Type" should be Call/email/etc and the "Call Type" should be as above.

 

For some strange reason when in the edit page of creating a Task "Call Type" is a locked, blank, non editable field. There is no help entry information on this field.

 

I can only assume that it knows if an email is "Inbound, Outbound, Internal" But this has nothing to do with Phone calls being logged by users. 

 

Is this some feature that is used with a CTI adapter for Call Center?

 

If a CTI adapter is not being used how should incoming/outgoing calls be logged?

 

If I change the values of the "Type" from "Call, Email" to "Call in, Call out, Email In, Email Out" then when creating a custom report type of something as standard as Accounts with Activities, it will not allow me to access the "Type" field, but the "Call Type" field is available for use.

 

So reporting on Activities, the way Activities are best practice to be used, is in direct contradiction here.

 

I would have thought this would be solved years ago as it's an essential business process. What am I missing? Is it broken? Or do most people just throw together an inefficient unclear way of logging calls and reporting on them?

 

If the "Call Type" was an editable pick list - this seems logical and would work for thousands of Businesses.

 

Instead my best bet seems to recreate the Call Type pick list as a custom field with exactly the same values - which makes reporting problematic as there is 2 identical field names. Perhaps I should call the custom field "Actual Call Type" or Call Type Proper" - What is a user to to think when viewing this field? Maybe "Communication Direction" is a better name for my custom field. 

 

 

Message Edited by Cloudbox on 04-01-2010 11:44 PM