• hpereira
  • NEWBIE
  • 165 Points
  • Member since 2013
  • Technical Lead
  • Waeg

  • Chatter
    Feed
  • 4
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 33
    Replies

Hey Guys,

 

I'm currently trying to go through all my code and make everyhing much more efficient..

 

Which means I'm trying to reduce the number of calls through statements etc.

 

I'm struggling to get my head around the MAP Class..

 

What I'm trying to do is Map All Accounts, but within my trigger I need to be able to call upon the specific account which matches Key__c from a custom object and return all account details.

 

I'm currently doing that with a query, but unsure how I can query a MAP to return results?

 

Any help always appreciated!


Regards,

 

Richard Hubbard

I created a VF email template.  However the link appears in the email but when you click on the link. The link does not work.

Not sure what is wrong with my code for the link. See code:

<apex:outputLink value="/!{relatedTo.opp}">{!relatedTo.Name}</apex:outputLink>

 Here is the first part of my VF email template for your reference.

<messaging:emailTemplate recipientType="User"relatedToType="Opportunity" subject="Channel Special Pricing Approval Request: {!relatedTo.name}">
<messaging:htmlEmailBody >       
    <html>
        <body>
         <STYLE type="text/css">
               TH {font-size: 14px; font-face: arial;background: #CCCCCC; border-width: 1;  text-align: center }
               TD  {font-size: 14px; font-face: verdana }
               TABLE {border: solid #CCCCCC; border-width: 1}
               TR {border: solid #CCCCCC; border-width: 1}
         </STYLE></p>
                  <font face="arial" size="3">
        <p>Dear Approver,</p><p>A new Channel Special Pricing Request has been submitted for your review and is pending your approval.The link provided will take you to the opportunity in Salesforce.com. If you are receiving this on your mobile devise, a summary of the opportunity details follows below the link.</b></p>
      
        <p>You can approve or deny this request from your mobile devise by replying to this message and typing approved or rejected in the first line of the email body. You may add any additional comments in the second and subsequent lines. The additional comments will be added to your approval or denial record.</p>
          <apex:outputLink value="/!{relatedTo.opp}">{!relatedTo.Name}</apex:outputLink>
        <br></br>
        <table border="0" >
                 <tr >
                     <th>Action</th><th> Product Name </th><th> Quantity </th><th> Disti Price $ </th><th> Discount %</th><th> Discount Price $ </th>
                 </tr>
    <apex:repeat var="opp" value="{!relatedTo.OpportunityLineItems}">
       <tr>
           <td><a href="https://na1-blitz01.soma.salesforce.com/{!opp.id}">View</a> | 
           <a href="https://na1-blitz01.soma.salesforce.com/{!opp.id}/e">Edit</a></td>
           <td>{!opp.PriceBookEntry.name}</td>
           <td>{!ROUND(opp.Quantity,0)}</td>
           <td>{!ROUND(opp.ListPrice,0)}</td>
           <td>{!ROUND(opp.Discount__c,0)}</td>
           <td>{!ROUND(opp.Approved_Unit_Price__c,0)}</td>
           </tr>
    
    </apex:repeat>                
       </table>
       <br/>” 

 

Hello,

 

I don't get any compile errors, but the thing that's supposed to happen just doesn't when I run this trigger. Basically, I have a contact lookup field on my Clinical_Intake_Object (Parent_Name_2), and when certain criteria on the Clinical lntake Object are met (clinician assigned, not canceled) I want to change the record type of the contact to "Household." Instead, this trigger just keeps the record type the same, and I don't know why.

 

Thank you!

 

trigger updateClinical2 on Clinical_Intake_Object__c (after update, after insert)
{
Map<Id, Contact> consMap = new Map<Id, Contact>();
Set<id> Ids = new Set <id>();
for (Clinical_Intake_Object__c tk: Trigger.new)
{
Ids.add(tk.Parent_Name_2__c);
}
Map<id, Contact> consMap2 = new Map<id, Contact>([SELECT Id FROM Contact WHERE Id in :Ids]);
for (Clinical_Intake_Object__c t: Trigger.new)
if (t.Parent_Name_2__c != null && t.Canceled__c!= true && t.Clinician_Assigned__c !=null && t.CMI_Appointment_Date__c !=null)
{
Contact c = consMap2.get(t.Parent_Name_2__c);
List<Contact> consList = [SELECT Name, Id FROM Contact WHERE Id in :Ids];

List<RecordType> rtypes = [SELECT Name, Id FROM RecordType WHERE sObjectType = 'Contact' and isActive = true];
Map<String, String> contactRecordTypes = new Map<String, String>{};
for(RecordType rt: rtypes)
    contactRecordTypes.put(rt.Name, rt.Id);

c.RecordTypeId = contactRecordTypes.get('Household Contact');  
upsert consMap.values();
consMap.put(c.Id,c);

}}

 

Hi I'm trying to write test cases using isTest annotation

first of all i have initialized my visualforce page.

than initialized the controller

and iam calling each methods in controller

 

but in my code coverage is only 85% only....... i know 75% code coverage is enough for deploy code in production organization but iam expecting 100% code coverage here is my code please let me any suggesions

 

Here is mine Controller

 

   public class MyQueryController{

   public Set<String>myQueryResults { get; Public set; }  

   public List<Fund_Management__c> getUniquedata(){

   myQueryResults= new Set<String>();  

    List<Fund_Management__c> query=[SELECT Fund_Name__c FROM Fund_Management__c];

    System.debug('Results'+query);  9    for(Fund_Management__c results : query){  

    myQueryResults.add(results.Fund_Name__c); 

   }  

    return query;

    }  

  }

 

highlighted area is not get covered anybody knows to get code coverage for that area..... and also let me know how to increase code coverage for code included in conditional statements like  for, if, else conditions

 

 

 

And here is mine test class

 

@isTest
Private class MyQueryControllerTest{
    Static testmethod void UnitTest(){
    Set<String> myQueryResults = new Set<String>{};
    List<Fund_Management__c> query=[SELECT Fund_Name__c FROM Fund_Management__c];
    //initialized the vf page here
    PageReference pageref = Page.MyQueryPage;
    Test.setCurrentPageReference(pageref);
    //initialized the controller
    MyQueryController myqc = new MyQueryController();
    //calling methods in controller
    myqc.getUniquedata();
    }
}

 

Hi Folks,

     Iam trying to run a test class but it's getting failed due to this trigger. The error says

 

System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, BmiCount: execution of AfterInsert

caused by: System.QueryException: Non-selective query against large object type (more than 100000 rows). Consider an indexed filter or contact salesforce.com about custom indexing.
Even if a field is indexed a filter might still not be selective when:
1. The filter value includes null (for instance binding with a list that contains null)
2. Data skew exists whereby the number of matching rows is very large (for instance, filtering for a particular foreign key value that occurs many times)

Trigger.BmiCount: line 27, column 1: []

 

Here is my trigger

 

trigger BmiCount on BigMachines__Quote__c (after insert,after delete) {
    
    Set<Id> optyIds = new Set<Id>();
    
    
    Map<Id,Integer> bmiCountMap = new Map<Id,Integer>();
    List<BigMachines__Quote__c>  bmqList = new List<BigMachines__Quote__c>();
    
    if(Trigger.isInsert){
        bmqList = Trigger.new;
    }
    else if(Trigger.isDelete){
        bmqList = Trigger.old;  
    }
    
    for(BigMachines__Quote__c bm : bmqList){
        bmiCountMap.put(bm.BigMachines__Opportunity__c,0);
        optyIds.add(bm.BigMachines__Opportunity__c);
    }
    
    List<BigMachines__Quote__c> bmQuotes = [Select Id, BigMachines__Opportunity__c from BigMachines__Quote__c where BigMachines__Opportunity__c IN :optyIds];
    List<Opportunity> optyList = [Select id, bmi_count__c from Opportunity where Id IN :optyIds];
    
    for(BigMachines__Quote__c bm :bmQuotes){
        bmiCountMap.put(bm.BigMachines__Opportunity__c,bmiCountMap.get(bm.BigMachines__Opportunity__c)+1);
    }
    
    for(Opportunity opty : optyList){
        
        opty.bmi_count__c = bmiCountMap.get(opty.Id);
    }
    
    update optyList;
  }

 

 

Any help is appreciated!!

I'm using a List of Custom Object to display in VF page and changing the values on the page itself.

After that clicking a button to call a custom save function which updating the record, but the new value is not recorded.

 

There is some problem with get set.

 

I declared list like :-

 

List<Kart__C> MyKart {get; set; }

 

Anybody faced the same issue? please help me.

Hey Guys,

 

I'm currently trying to go through all my code and make everyhing much more efficient..

 

Which means I'm trying to reduce the number of calls through statements etc.

 

I'm struggling to get my head around the MAP Class..

 

What I'm trying to do is Map All Accounts, but within my trigger I need to be able to call upon the specific account which matches Key__c from a custom object and return all account details.

 

I'm currently doing that with a query, but unsure how I can query a MAP to return results?

 

Any help always appreciated!


Regards,

 

Richard Hubbard

I created a VF email template.  However the link appears in the email but when you click on the link. The link does not work.

Not sure what is wrong with my code for the link. See code:

<apex:outputLink value="/!{relatedTo.opp}">{!relatedTo.Name}</apex:outputLink>

 Here is the first part of my VF email template for your reference.

<messaging:emailTemplate recipientType="User"relatedToType="Opportunity" subject="Channel Special Pricing Approval Request: {!relatedTo.name}">
<messaging:htmlEmailBody >       
    <html>
        <body>
         <STYLE type="text/css">
               TH {font-size: 14px; font-face: arial;background: #CCCCCC; border-width: 1;  text-align: center }
               TD  {font-size: 14px; font-face: verdana }
               TABLE {border: solid #CCCCCC; border-width: 1}
               TR {border: solid #CCCCCC; border-width: 1}
         </STYLE></p>
                  <font face="arial" size="3">
        <p>Dear Approver,</p><p>A new Channel Special Pricing Request has been submitted for your review and is pending your approval.The link provided will take you to the opportunity in Salesforce.com. If you are receiving this on your mobile devise, a summary of the opportunity details follows below the link.</b></p>
      
        <p>You can approve or deny this request from your mobile devise by replying to this message and typing approved or rejected in the first line of the email body. You may add any additional comments in the second and subsequent lines. The additional comments will be added to your approval or denial record.</p>
          <apex:outputLink value="/!{relatedTo.opp}">{!relatedTo.Name}</apex:outputLink>
        <br></br>
        <table border="0" >
                 <tr >
                     <th>Action</th><th> Product Name </th><th> Quantity </th><th> Disti Price $ </th><th> Discount %</th><th> Discount Price $ </th>
                 </tr>
    <apex:repeat var="opp" value="{!relatedTo.OpportunityLineItems}">
       <tr>
           <td><a href="https://na1-blitz01.soma.salesforce.com/{!opp.id}">View</a> | 
           <a href="https://na1-blitz01.soma.salesforce.com/{!opp.id}/e">Edit</a></td>
           <td>{!opp.PriceBookEntry.name}</td>
           <td>{!ROUND(opp.Quantity,0)}</td>
           <td>{!ROUND(opp.ListPrice,0)}</td>
           <td>{!ROUND(opp.Discount__c,0)}</td>
           <td>{!ROUND(opp.Approved_Unit_Price__c,0)}</td>
           </tr>
    
    </apex:repeat>                
       </table>
       <br/>” 

 

Hello All, 

 

I am trying to develop a simple IF statement logic based on the outcome of a Task status.  In this case I am looking for all Tasks with a subject line of "Lost Contact Follow Up Call".  Then, depending on what the Task Status is, further action should be taken.

 

 

Here is my code:

trigger SD_Member_Lost_Contact on Task (after insert, after update) {
/*
Automatically update the "Enrollment Progress Status" field, based upon the "Status" field 
of the last Member Task
*/

// Tasks that meet criteria, and new tasks to create
Task[] qualifiedTasks = new Task[0], newTasks = new Task[0];

// Date example with the dt1 variable being set to Today's Date plus 1 day.
Date dt1=DateTime.now().addDays(1).date();
Date rt1=DateTime.now().addDays(1).date();

    
// Map of SD Members
   Map<Id,SD_Member__c> members = new Map<Id,SD_Member__c>();

// Find qualifying tasks
   for(Task record:Trigger.new)
        if(Record.subject =='Lost Contact Follow Up Call' &&
           record.isclosed == True)
           qualifiedtasks.add(record);
    
   // Obtain member ID values
   for(Task record:qualifiedtasks)
        members.put(record.whatid,null);
   
   // If there are any membes to query, do so and pull the following fields.
   if(!members.isempty())
        members.putall([select id, CareCoach__c from SD_Member__c where id in :members.keyset()]);


for(Task record:qualifiedtasks) {
    

    /* IF the task is closed with the following value: Completed – No More Calls this Cycle
    / THEN terminate workflow and no more calls made */
    If (record.Status == 'Completed – No More Calls this Cycle'){}
  
    /* IF the task is closed with the following values:
        Member Hung Up
        Reached Target – Call Later
        Reached Target – No Interest
        Reached Target – Requested Info
        Reached Target – Sent to Care Coach
        Reached Target – Thinking About It
       THEN:
       a) create an immediate task for the Care Coach with the subject "Change Status to In Treatment" 
       and put the following in the comment  “Successful Contact – change status in eOT to in treatment.  
       See call notes for disposition details.”
       b) terminate workflow and now more calls made */
          
      else If (record.Status == 'Member Hung Up'||
               record.Status == 'Reached Target – Call Later'||
               record.Status == 'Reached Target – No Interest'||
               record.Status == 'Reached Target – Requested Info'||
               record.Status == 'Reached Target – Sent to Care Coach'||
               record.Status == 'Reached Target – Thinking About It'){
          Task T1 = New Task(subject='Successful Contact – change status in eOT to in treatment',
                             Status = 'Not Started',
                             whatid = members.get(record.whatid).id,
                             ownerid= members.get(record.whatid).CareCoach__c,
                             ActivityDate=dt1,
                             IsReminderSet=True, 
                             ReminderDateTime=rt1,
                             Description = 'See call notes for disposition details.');
          Insert T1;}
          
      else {
	       SD_Member__c SDM = New SD_Member__c (id=members.get(record.whatid).id, Lost_Contact_Follow_Up__c=True);
           Update SDM;
           }	}
   
    }  

 

 The issue I an having is I do not beleive I have my IF logic correct.  For example: if the Task Status is " Completed – No More Calls this Cycle"

    /* IF the task is closed with the following value: Completed – No More Calls this Cycle
    / THEN terminate workflow and no more calls made */
    If (record.Status == 'Completed – No More Calls this Cycle'){}

 

  then nothing should happen, but for some reason the code instead still executes my ELSE clause:

 

      else {
	       SD_Member__c SDM = New SD_Member__c (id=members.get(record.whatid).id, Lost_Contact_Follow_Up__c=True);
           Update SDM;
           }

 

 Not sure why, but any feedback is welcomed.

 

Regards,

 

MarlTroutBum

 

Hi ,

 

   I have a requirement where I need to send the mail to the Level 1 Appover after the Level 2 Approver has approved the record. 

 

I have twelve L1 approvers but any one of the twelve can approve the record, can anyone please provide me any pointers on how Can I get the Id of the user who has approved the record. 

 

 

Thanks,

Karthik

 

I have a page with a previous and next button.when i click on next button than showing a loading message image in center but problem is that image showing break on next and previous button.

 

we should a method which can delay between loading message and form submission

I think we can use  delay function java script function but how i dont know.

 

 

There are two SFDC orgs. I should have a button in the standard page of all the records "Clean this record" on the record detail page in one of the orgs. if the user finds and data mismatch or null fields in the records they will hit the custom button in the detail page of the record. Which will share the record with another organisation. So the user will receive the record from the another org and clean the record and re share the record wih the original org. i dugged the possibilty of using salesforce to salesforce connetions. every thing seems OK. Except they need the button in the original org in its record detail page. so can we send the record via salesforce to salesforce connection on a click of abutton in a record detail page. 

Hello all,

 

My org is used globally and I need to be able to calculate the number of days to close a case based on business days, but also take into consideration the holidays of each country (approx. 25 countries). Currently I have a formula field (as shown below), but it only contains US Holidays. Is it possible to add criteria into the existing formula so that IF Country = Australia, then calculate based on those dates, or IF Country = France, then calculate based on those specific dates? Or would a separate field be needed per country? Apex coding? There must be some way to do this, I just don't know what the solution is? There must be other orgs out there with a similar issue and hopefully someone has found a solution. Any help is greatly appreciated!

 

Thank you,

Wendy

 

Customer_Close_Date__c - DATEVALUE(Date_Issue_Received__c)

- IF ( AND(Customer_Close_Date__c >= DATEVALUE("2010-01-01"), DATEVALUE(Date_Issue_Received__c) <= DATEVALUE("2010-01-01")) , 1, 0)
- IF ( AND(Customer_Close_Date__c >= DATEVALUE("2010-05-31"), DATEVALUE(Date_Issue_Received__c) <= DATEVALUE("2010-05-31")) , 1, 0)
- IF ( AND(Customer_Close_Date__c >= DATEVALUE("2010-09-06"), DATEVALUE(Date_Issue_Received__c) <= DATEVALUE("2010-09-06")) , 1, 0)
- IF ( AND(Customer_Close_Date__c >= DATEVALUE("2010-11-25"), DATEVALUE(Date_Issue_Received__c) <= DATEVALUE("2010-11-25")) , 1, 0)
- IF ( AND(Customer_Close_Date__c >= DATEVALUE("2010-11-26"), DATEVALUE(Date_Issue_Received__c) <= DATEVALUE("2010-11-26")) , 1, 0)
- IF ( AND(Customer_Close_Date__c >= DATEVALUE("2010-12-24"), DATEVALUE(Date_Issue_Received__c) <= DATEVALUE("2010-12-24")) , 1, 0)

- CASE( MOD(DATEVALUE(Date_Issue_Received__c) - DATEVALUE( "1985-06-24" ) , 7) , 0
, CASE( MOD( Customer_Close_Date__c - DATEVALUE (Date_Issue_Received__c), 7 ),1,0,2,0,3,0,4,0,5,1,6,2,0 ), 1
, CASE( MOD( Customer_Close_Date__c - DATEVALUE (Date_Issue_Received__c), 7 ),0,0,1,0,2,0,3,0,4,0,5,2,2 ), 2
, CASE( MOD( Customer_Close_Date__c - DATEVALUE (Date_Issue_Received__c), 7 ),0,0,1,0,2,0,3,1,2), 3
, CASE( MOD( Customer_Close_Date__c - DATEVALUE (Date_Issue_Received__c), 7 ),0,0,1,0,2,1,2), 4
, CASE( MOD( Customer_Close_Date__c - DATEVALUE (Date_Issue_Received__c), 7 ),0,0,1,1,2), 5
, CASE( MOD( Customer_Close_Date__c - DATEVALUE (Date_Issue_Received__c), 7 ),0,1,2), 6
, CASE( MOD( Customer_Close_Date__c - DATEVALUE (Date_Issue_Received__c), 7 ),6,2,1)
, 666 )
- ( FLOOR( ( Customer_Close_Date__c - DATEVALUE (Date_Issue_Received__c) ) / 7 ) * 2 )

Is there a way to use a trigger to set the default value of a date field on a custom object based on the value of another field on the page?

Hello,

 

I don't get any compile errors, but the thing that's supposed to happen just doesn't when I run this trigger. Basically, I have a contact lookup field on my Clinical_Intake_Object (Parent_Name_2), and when certain criteria on the Clinical lntake Object are met (clinician assigned, not canceled) I want to change the record type of the contact to "Household." Instead, this trigger just keeps the record type the same, and I don't know why.

 

Thank you!

 

trigger updateClinical2 on Clinical_Intake_Object__c (after update, after insert)
{
Map<Id, Contact> consMap = new Map<Id, Contact>();
Set<id> Ids = new Set <id>();
for (Clinical_Intake_Object__c tk: Trigger.new)
{
Ids.add(tk.Parent_Name_2__c);
}
Map<id, Contact> consMap2 = new Map<id, Contact>([SELECT Id FROM Contact WHERE Id in :Ids]);
for (Clinical_Intake_Object__c t: Trigger.new)
if (t.Parent_Name_2__c != null && t.Canceled__c!= true && t.Clinician_Assigned__c !=null && t.CMI_Appointment_Date__c !=null)
{
Contact c = consMap2.get(t.Parent_Name_2__c);
List<Contact> consList = [SELECT Name, Id FROM Contact WHERE Id in :Ids];

List<RecordType> rtypes = [SELECT Name, Id FROM RecordType WHERE sObjectType = 'Contact' and isActive = true];
Map<String, String> contactRecordTypes = new Map<String, String>{};
for(RecordType rt: rtypes)
    contactRecordTypes.put(rt.Name, rt.Id);

c.RecordTypeId = contactRecordTypes.get('Household Contact');  
upsert consMap.values();
consMap.put(c.Id,c);

}}

 

Hi I'm trying to write test cases using isTest annotation

first of all i have initialized my visualforce page.

than initialized the controller

and iam calling each methods in controller

 

but in my code coverage is only 85% only....... i know 75% code coverage is enough for deploy code in production organization but iam expecting 100% code coverage here is my code please let me any suggesions

 

Here is mine Controller

 

   public class MyQueryController{

   public Set<String>myQueryResults { get; Public set; }  

   public List<Fund_Management__c> getUniquedata(){

   myQueryResults= new Set<String>();  

    List<Fund_Management__c> query=[SELECT Fund_Name__c FROM Fund_Management__c];

    System.debug('Results'+query);  9    for(Fund_Management__c results : query){  

    myQueryResults.add(results.Fund_Name__c); 

   }  

    return query;

    }  

  }

 

highlighted area is not get covered anybody knows to get code coverage for that area..... and also let me know how to increase code coverage for code included in conditional statements like  for, if, else conditions

 

 

 

And here is mine test class

 

@isTest
Private class MyQueryControllerTest{
    Static testmethod void UnitTest(){
    Set<String> myQueryResults = new Set<String>{};
    List<Fund_Management__c> query=[SELECT Fund_Name__c FROM Fund_Management__c];
    //initialized the vf page here
    PageReference pageref = Page.MyQueryPage;
    Test.setCurrentPageReference(pageref);
    //initialized the controller
    MyQueryController myqc = new MyQueryController();
    //calling methods in controller
    myqc.getUniquedata();
    }
}

 

Hi,

 

My scenarion: There is a field f1 in Account page which user's of Profile say P1 can not edit(Field is not read-only) because we have used validation rule to stop them from editing. What bussiness wants is that there are some users of P1 profile which have permission set. If any user with this permissin set is changing the record of field f1 then validation should not trigger. I can not find any permission sets in insert field option for a validation. Is there any way I can use permission sets in validation rule.

 

Any help will be appreciated. Thank in advance.

 

With Regards,

Mayank Pant