• Mahesh D
  • ALL STAR
  • 6127 Points
  • Member since 2008
  • Technical Architect

  • Chatter
    Feed
  • 169
    Best Answers
  • 0
    Likes Received
  • 10
    Likes Given
  • 0
    Questions
  • 1385
    Replies
Hello All,
I have been going in circles with this code for 2 days and received some help but I am still at a loss.  The code below looks for Contracts where the checkbox Automatic_renewal__c = TRUE AND the field Contract_End_Date_Current__c = Yesterday.  I have tried to create a test class with data  but my test coverage is '0'.  All of the Contracts are associated to an Account.  So can I jsut have a single account with multiple Contracts assoicated to it?  What is the best way to confirm that the contract data was created with the desired date?  
Any help would be greatly appreciated.
Cheers,
M

 Global class ContractUpdateContractRenewalStartDate implements Schedulable {
    // Allow tests to see the variable, but not "normal" code
    @TestVisible Date contractdate = System.today().addDays(-1);
       
        global void execute(SchedulableContext sc) {
         list<Contract> Contractupdate = [SELECT Id, Contract_Start_Date_Current__c,Contract_End_Date_Current__c FROM Contract WHERE              Automatic_renewal__c = TRUE AND Contract_End_Date_Current__c =: contractdate ];
       
         for(Contract c: Contractupdate)
       {
            c.Contract_Start_Date_Current__c = System.today();
        }
        update Contractupdate;
    } 
}
Hi
I have an Insert trigger (after insert) on object Reservation Terrain than update Terrain Disponible object.
I have to update the Terrain_Disponible.Available field to "NO", and update Terrain_Disponible.Date_reserve field to Reservation_Terrain.Date_de_reservation value

Here is the schema

User-added image

Here the code with an error at line 13
trigger TRG_Reservation2 on Reservation_Terrain__c (after insert) {
    Set<Id> tdIdSet = new Set<Id>();
    for(Reservation_Terrain__c rt: Trigger.new) {
        if(rt.Terrain_Disponible__c != null)
            tdIdSet.add(rt.Terrain_Disponible__c);
    }
   
    if(!tdIdSet.isEmpty()) {
        List<Terrain_Disponible__c> tdList = [SELECT Id, Name, Available__c, Date_reserve__c FROM Terrain_Disponible__c WHERE Id IN: tdIdSet];
       
        for(Terrain_Disponible__c td: tdList) {
            td.Available__c = 'NO';
            td.Date_reserve__c = Date_de_reservation__c.new;  <-- The error line
        }
        update tdList;
    }
}

Could you give me a hand?

thank you

 
trigger InvoiceSum on Invoice_Items__c (after insert, after update)
    {
     Set<Id> InvIds = new Set<Id>();   
     for(Invoice_Items__c ii :trigger.new)
     { InvIds.add(ii.InvoiceFK__c); }

        List<Invoice__c> InvRecs = [Select id, Ammount__c from Invoice__c where id in : InvIds ];
       
       for(Invoice__c inv : InvRecs)
        {
          //inv.Ammount__c= [Select sum(Invoice_items__r.Amount__c) from Invoice_Items__c ];
           Decimal total=0;
        //   for (Invoice_items__c iit: inc.Invoice_items__c)
          inv.Ammount__c =inv.Invoice_items__r.Amount__c;
            update inv;
        }
     
    }
Invoice__c is parent object and Invoice_item__c is child, I have to sum the all line items amount and display on Invoice__c record. Please help.
public class TotalExpenseComputation { 
   
   
 
    /*
     * The totalExpense method calculates the total of all the approved expenses as well as the amount left
     *
     * for both the marketing and sales budget.
     * */
public static void totalExpense(Expense__c[] expenses)
{
    //Query to get  Initial Amount,Total Expense and Remaining Amount field from respective budgets.
 
    List<Budget__c> typeList = new List<Budget__c>();
   
for(Budget__c[] b:[SELECT Name,Initial_Amount__c,Total_Expenses__c,Remaining_Amount__c,Type__c FROM Budget__c])
{
for(Expense__c exp:expenses)
    {
        if(exp.Type__c.equals('Marketing')&& exp.Budget_LookUp__c.equals(b.Name))
        {
             if(exp.Status__c.equals('Approved'))
             {
                
              b.Total_Expenses__c= exp.Amount__c+b.Total_Expenses__c;
               b.Remaining_Amount__c=b.Initial_Amount__c-b.Total_Expenses__c;
               typeList.add(b);
                
             }
              
        }
       
        if(exp.Type__c.equals('Sales')&& exp.Budget_LookUp__c.equals(b.Name))
        {
            if(exp.Status__c.equals('Approved'))
            {
              
                b.Total_Expenses__c  =exp.Amount__c+b.Total_Expenses__c;
                b.Remaining_Amount__c=b.Initial_Amount__c-b.Total_Expenses__c;
              typeList.add(b);
               
              }
        }
       
    }update typeList;}
   
 
I am new in Salesforce
When I insert an object, I want to update a record of another object.
So I use a trigger after insert

My code
trigger TRG_Reservation on Reservation_Field__c (after insert) {
 Available_Field__c a = [SELECT Name FROM Available_Field__c WHERE Name = :name];
      a.available_flag = 'NO';
      update a;
}

Thanks for your help

​colin
Here is the sample code I'm trying to run.  When I requery the contact record for account.name, it returns null.  Does anyone know why this is?

@isTest public class TestSampleInsert {
public static testMethod void testMyController() {        
Account someAccount = new Account(Name = 'Test Account', Website = 'http://www.somesite.com');
insert someAccount;

Contact someContact = new contact(FirstName = 'Tim', lastName = 'Joes', Email = 'test@test.com', Account = someAccount);
insert someContact;

// Requery contact for field data
Contact contactRequery = [SELECT ID, FirstName, LastName, Email, Account.Name from Contact where ID = :someContact.id limit 1];

// This fails!  Account.name is null
System.AssertEquals(contactRequery.account.name, 'Test Account');
}
I am trying to write apex code for the Activities/Task object.

We have a custom picklist field titled "Task Results".

I want to have whatever is selected in "Task Results" to automaticcaly append/add-to whatever is typed into the Task Subject in parenthesis.

For example, if Subject is "Call" and someone selected "Inbound" from the Task Results picklist, I want the Subject to then be changed to "Call (Inbound)".

Please let me know if that makes sense. 
Hey Guys,

Can any body help me how can i send an email alert to a user(opportunity owner), of all my existing opportunities if the closed date has passed todays date. i tried to write a work flow but it does not work for the exsisting records. how can i over come this and send an emai notification to the user if todays date is passed.

Thanks in advance,
Virinchi.
I created the following apex class to count opportunities, show min and max values - having them displayed in a visualforce component/page.
I'm having several issues to start the test class, can anybody please show me how to do it? Maybe I created the class in a wrong way, obviously it works on Sandbox and I cannot deploy to production.
 
public with sharing class CountBubbles {
    
    private ApexPages.StandardController stdCtrl;
    public List<Opportunity> allAccounts{get;set;}
    public Integer srNo            {get;set;}
    public Id recId              {get;set;}  
    public boolean isSaved          {get;set;} 
    Opportunity acc;    
    public Opportunity minSource {get; private set;}
    public Opportunity maxSource {get; private set;}
    public Opportunity minQualify {get; private set;}
    public Opportunity maxQualify {get; private set;}

    
	public Integer getTOTAL_Opps_Source() {
        Integer counter = [ Select count() from Opportunity WHERE StageName = 'Source' AND CloseDate <= Next_N_DAYS:365 
        and CloseDate >= Last_N_DAYS:365];
        return counter;
    }
    //Get total opps qualify phase
    public Integer getTOTAL_Opps_Qualify() {
        Integer counter = [ Select count() from Opportunity WHERE StageName = 'Qualify' AND CloseDate <= Next_N_DAYS:365 
        and CloseDate >= Last_N_DAYS:365];
        return counter;
    }
   
public CountBubbles(ApexPages.StandardController std)
   {
   	
  
  ID qid = std.getRecord().Id;

     try { minSource = [SELECT Id,Name,StageName,Opportunity_Probability__c FROM Opportunity 
              Where StageName = 'Source' AND CloseDate <= Next_N_DAYS:365 
          and CloseDate >= Last_N_DAYS:365 ORDER BY Opportunity_Probability__c ASC limit 1];
     } catch (exception e) {
          
     }
     try { maxSource = [SELECT Id,Name,StageName,Opportunity_Probability__c FROM Opportunity 
              Where StageName = 'Source' AND CloseDate <= Next_N_DAYS:365 
          and CloseDate >= Last_N_DAYS:365 ORDER BY Opportunity_Probability__c DESC limit 1];  
     } catch (exception e) {
      
     }
     try { minQualify = [SELECT Id,Name,StageName,Opportunity_Probability__c FROM Opportunity 
              Where StageName = 'Qualify' AND CloseDate <= Next_N_DAYS:365 
          and CloseDate >= Last_N_DAYS:365 ORDER BY Opportunity_Probability__c ASC limit 1];
     } catch (exception e) {
      
     }
     try { maxQualify = [SELECT Id,Name,StageName,Opportunity_Probability__c FROM Opportunity 
              Where StageName = 'Qualify' AND CloseDate <= Next_N_DAYS:365 
          and CloseDate >= Last_N_DAYS:365 ORDER BY Opportunity_Probability__c DESC limit 1];  
     } catch (exception e) {
      
     } 
  
  }   
}


Thank you!
Ronaldo.
Hello All

Im having a few issues with an Apex class im calling using the process builder.
The following code is creating the OLI ok, but only when a specific pricebook is assigned to the Opp.
Essentially im unable to find a way to set the pricebook to the one that is already assigned to the Opp, as currently its just using the first active pricebook it finds that the product is present in. Resulting in the following error; "pricebook entry is in a different pricebook than the one assigned to the opportunity".
 
Public class AutoCreateProduct
{
    @InvocableMethod
    public static void ProductAssign(List<Id> OppIds)
    {
     List<OpportunityLineItem> oliList = new List<OpportunityLineItem>();

    List<PriceBookEntry> priceBookList = [SELECT Id, Product2Id, Product2.Id, Product2.Name FROM PriceBookEntry WHERE Product2Id='01ta0000003vqHeAAI' AND PriceBook2.isActive=true LIMIT 1]; 

OpportunityLineItem oli = new OpportunityLineItem
(OpportunityId=OppIds[0], PricebookEntryId=priceBookList[0].Id, Quantity = 1);

    oliList.add(oli);
    insert oliList;
   }
}

Just some extra info, as im sure im not doing this in the best manner.
Im currently tasked with setting up fully automatic Lead conversion, and iv completed everystep up to this.
So leads are automatically converted in accounts, contacts and opps and have a pricebook assigned to them.

I have custom fields on the opportunity that will effect the prodcuts that will be added aswell as products that are in multiple pricebooks.
This last step is casing me no end of trouble, and iv not even added in any logic yet for the custom fields.

Thank you in advance for any help that can be offered.
Regards
James
 
  • April 13, 2016
  • Like
  • 0
Hi,

I have a requirement inwhich There is a field of type Picklist "BU__C" which is present on both User and Task object.Now when a user create a contact record,when he creates a task,value of "BU__C" of User should be stamp to the "BU__C" in Task.
e.g.If Value "BU__c" of user is "ABC" then in task "BU__C" must be stamp with the value as "ABC".

I have to solve this by writing a apex class not a trigger.
Can somebody help me how to do it via apex sharing class?
It would be better if it explains with example
Hi,

I have a rquirement to format a time which is given in HH:MM format (24-hour clock) into the user's locale. I assumed that there would be a fromat() method as the DateTime class does, but it does not exist.

Any ideas how I can do this?

Thanks
please let me know about Actionfunction and actionsupport in VF pages
Hello All,
I have a requirement where i need to send an email notification to the contract owner 30 days before the contract end date , when the contract role is 'SA/EB?TA' etc.Any suggestion  with an example very much appreciated.
Hi, 
I need to write a trigger on lead object. This trigger will return all the record IDs of any new lead records / created. I need to further  filter the IDs and exclude all converted lead records. I guess I need to use a SOQL query in this trigger? Please let me know the best way to fulfilment this requirement using code. I'm new to Apex and Salesforce. Any samples will help a lot. Thanks

Hi Anything Wrong In My Trigger ,When I am Trying To Deploy a Test Class(In Test Class Ii am Just Inserting  Account,Oppurtunity,Cardapplication objcet) I am Getting This Below Error:
System.LimitException: Too many SOQL queries: 101 
Stack Trace: Trigger.UpdateEngagement: line 13, column 1
trigger UpdateEngagement on Opportunity (after insert, after update, before update) 
{
    if(Trigger.isInsert || (Trigger.isUpdate && Trigger.isAfter))
    {
        map<Id, string> mpOpp = new map<Id, string>();
        for(Opportunity o: Trigger.New)
        {
            mpOpp.put(o.AccountId, o.StageName);
        }
        
        If(mpOpp != null && mpOpp.size()>0)
        {
            List<Account> lstAcc = [select  EngagementCode__c, id from Account where id in :mpOpp.KeySet()];
            for(Account a: lstAcc)
            {
                a.EngagementCode__c = mpOpp.get(a.id);
            }
            update lstAcc;
        }
    }

    // New code added to Update the Incentive Options dependent field on stage change - by Vivek
 /*   if(Trigger.isUpdate && Trigger.isBefore)
    {
    
system.debug('@@1Before Incentive offer + Incentive'+Trigger.Old[0].Incentive__c);
        for(Opportunity OppNew : Trigger.New)
        {
            for(Opportunity OppOld : Trigger.Old)
            {
                if(OppNew.StageName != 'Product Recommendation' && OppOld.Incentive__c!='')
                {
                
system.debug('@@2Copying Incentive offer'+OppOld.Incentive__c);
                    OppNew.Incentive__c = OppOld.Incentive__c;
                }
            }
        }     
    } */
}
Hello World!

Reservation is an object that stores demographic information, which has 2 master-details to Features and Hotels, which contain items for each reservation. When a reservation is updated (from dataloader, usually 2k+ a time), I want the Features and Hotels children to be deleted, since new records will be uploaded after reservations. The following trigger is what I have, but I have a feeling it's not "bulkified" because I'm getting errors that IDs are already in the process when upserting via dataloader. Can someone help me "bulkify" this or let me know where I went wrong? Thanks!

(PS - Reservation_Number__c is the lookup to Reservation on each object). 
 
trigger ReservationsRemoveChildren on Reservation__c (after update) {

	List<Reservation__c> reservations = new List<Reservation__c>{};

	Set<Id> ids = new Set<Id>();
    for(Reservation__c r : Trigger.new) {
    delete [SELECT Id from Feature__c where Reservation_Number__c IN :ids];
    delete [SELECT Id from Hotel__c where Reservation_Number__c in :ids];        
	}
}

 
Hi everyone, 
Would you know if there is a recording for this webinar? Intro to Force.com (February 26, 2016 - 10AM PST) I did a search but couldn't find anything. I am looking to take the Platform Developer I Certification soon and was looking for all the info i can get my hands on. I'm also using Trailhead and the documentation available but i think the webinars can be quite helpful. 
Thank you!
Could you please advise me how to write test class for below


trigger Dcalup on Account (after update) {

  for (Account myacc : Trigger.old) {
    if (myacc.StrPhr_Do_Not_Call_Group_Practice__c == True) {
      List<Account> Dccall = [SELECT StrPhr_Do_Not_Call_Group_Practice__c from Account where Phone= :myacc.Phone];                
      if (Dccall.size() > 0)        
       for (Account a : Dccall ) {
         a.StrPhr_Do_Not_Call_Group_Practice__c = True;
        update a;
}      
             }                            
    }
  }
want to add new user using Apex  I have try for it but new user dosnt get display with other user
Hi, When I try to depoly the "deployUnpackaged" package i keep getting this errors even when the value is true:
1.  objects/Account.object (Account.APTS_DPLStatus__c) -- Error: The entity: Account does not have history tracking enabled (line 80, column 13)
<fields>
        <fullName>APTS_DPLStatus__c</fullName>
        <externalId>false</externalId>
        <label>DPL Status</label>
        <picklist>
            <picklistValues>
                <fullName>Cleared</fullName>
                <default>false</default>
            </picklistValues>
            <picklistValues>
                <fullName>Pending</fullName>
                <default>true</default>
            </picklistValues>
            <picklistValues>
                <fullName>Denied</fullName>
                <default>false</default>
            </picklistValues>
            <picklistValues>
                <fullName>System Not Reachable</fullName>
                <default>false</default>
            </picklistValues>
            <restrictedPicklist>true</restrictedPicklist>
            <sorted>false</sorted>
        </picklist>
        <trackFeedHistory>false</trackFeedHistory>
        <trackHistory>true</trackHistory>
        <type>Picklist</type>
    </fields>


 
Hi All,
What is the right solution for following the Trigger?
trigger TestSLTV on Service_Work_Order__c (after insert, after update)
{
    
    if (Trigger.isAfter && (Trigger.isInsert || Trigger.isUpdate))
    {
        Set<String> setStrVINNumber = new Set<String>();
        Set<String> setStrVINNumber1 = new Set<String>();
         Set<String> setStrVINNumber2 = new Set<String>();
        // Set<Date> setStrVINNumber3 = new Set<Date>();
        Map<String, Decimal> mapStrVINNumToTotal = new Map<String, Decimal>();
        List<Vehicle__c> lstVehicleToUpdate = new List<Vehicle__c>();
        List<Vehicle_Ownership__c> lstAVOToUpdate = new List<Vehicle_Ownership__c>();
        List<Contact_Vehicle_Ownership__c> lstCVOToUpdate = new List<Contact_Vehicle_Ownership__c>();
        // iterate over SWOs and collect VIN numbers
          if (trigger.isAfter && trigger.isUpdate) 
    {
       system.debug('------------1');
        for(Contact Objcont: Trigger.New)
        {
               setStrVINNumber.add(Objcont.Id);
            
           for( Contact_Vehicle_Ownership__c ObjCVO : [select VIN__c,Name,Contact_name__c,Relationship_Start_Date__c,
                                                       Relationship_End_Date__c
                                                       from Contact_Vehicle_Ownership__c
                                                       where Contact_name__c IN :setStrVINNumber  AND Relationship_End_Date__c=Null ])
            {
                 setStrVINNumber1.add(ObjCVO.VIN__c);
                            
               // for( Vehicle__c ObjVeh: [select Name from Contact_Vehicle_Ownership__c where Name IN:setStrVINNumber1 ])
                                   for( Service_Work_Order__c ObjSWO1 : [SELECT sum(Test_Total_Work_Order_Cost_ExGST__c)activesum
                                                                FROM Service_Work_Order__c 
                                                                WHERE Workorder_VIN_Number__c IN:setStrVINNumber1])
                                       
                                   {
                                       
                                       integer abc='activesum';
                                   }
            }                       
                
            
            
            
            
             for( Contact_Vehicle_Ownership__c ObjCVO : [select VIN__c,Name,Contact_name__c,Relationship_Start_Date__c,
                                                       Relationship_End_Date__c
                                                       from Contact_Vehicle_Ownership__c
                                                       where Contact_name__c IN :setStrVINNumber  AND Relationship_End_Date__c!=Null ])
            {
                
                mapStrVINNumToTotal.put((String)objCVO.get(VIN__c),(Date)objCVO.get(Relationship_Start_Date__c),(Date)objCVO.get(Relationship_End_Date__c));
                // setStrVINNumber4.add(ObjCVO.VIN__c);
                // setStrVINNumber2.add(ObjCVO.Relationship_Start_Date__c);
                 //setStrVINNumber3.add(ObjCVO.Relationship_Start_Date__c);
                
               // for( Vehicle__c ObjVeh: [select Name from Contact_Vehicle_Ownership__c where Name IN:setStrVINNumber1 ])
                                   for( Service_Work_Order__c ObjSWO1 : [SELECT SUM(Test_Total_Work_Order_Cost_ExGST__c)
                                        FROM Service_Work_Order__c 
                                        WHERE Workorder_VIN_Number__c IN:mapStrVINNumToTotal.get(ObjCVO.VIN__c) AND  Service_Date__cIN:mapStrVINNumToTotal.get(ObjCVO.Relationship_Start_Date__c) AND Service_Date__cIN:mapStrVINNumToTotal.get(ObjCVO.Relationship_End_Date__c)] )
                                       
                                   {
                                       
                                       integer xyz='activesum';
                                   }
            }  
            
            
        }
        Objcont.Service_life_time= abc + xyz;
        
        
    }}}
            

Please ask me for more detail about this operation.

Thanks,
Karthik
Hello All,
I have been going in circles with this code for 2 days and received some help but I am still at a loss.  The code below looks for Contracts where the checkbox Automatic_renewal__c = TRUE AND the field Contract_End_Date_Current__c = Yesterday.  I have tried to create a test class with data  but my test coverage is '0'.  All of the Contracts are associated to an Account.  So can I jsut have a single account with multiple Contracts assoicated to it?  What is the best way to confirm that the contract data was created with the desired date?  
Any help would be greatly appreciated.
Cheers,
M

 Global class ContractUpdateContractRenewalStartDate implements Schedulable {
    // Allow tests to see the variable, but not "normal" code
    @TestVisible Date contractdate = System.today().addDays(-1);
       
        global void execute(SchedulableContext sc) {
         list<Contract> Contractupdate = [SELECT Id, Contract_Start_Date_Current__c,Contract_End_Date_Current__c FROM Contract WHERE              Automatic_renewal__c = TRUE AND Contract_End_Date_Current__c =: contractdate ];
       
         for(Contract c: Contractupdate)
       {
            c.Contract_Start_Date_Current__c = System.today();
        }
        update Contractupdate;
    } 
}
Hi
I have a requirement as follows
In Account List View Page, I have added a custom button (fetch_Names) which will fetch all account names followed with contact details and opportunity details.
I have written the code for this.
<apex:page standardController="Account"
           recordSetVar="accounts"
           tabStyle="Account"
           sidebar="false">
 
 <apex:pageBlock >
          <apex:repeat value="{!accounts}" var="a">
          
<apex:pageBlockSection title="{!a.name}">

</apex:pageBlockSection>

  <apex:relatedList list="Contacts" subject="{!a.Id}"/>
  
<apex:relatedList list="Opportunities" subject="{!a.Id}" />

</apex:repeat>      
     </apex:pageBlock>
         
</apex:page>
Its working in the sense it displays only a few accounts but not all the accounts.
so I miss out on many account with related contacts.

How to to make sure it display all the accounts names?

thanks
pooja
 
Hi 
I am creating a pdf of Invoice Page. Now I want to hide some fields on table on pdf depending on picklist value (Rating__c).

I have created a table which denotes the Quantity,Name,Price,Total On the PDF Page.
This is My Table. :


 <table cellpadding="2" cellspacing="0" style="width:100%;">
                    <tr style="font-size:16px;height:32px;Font-family:Verdana,Arial;" >  

                        <td style="width:7%;background-color:#707070;border-left:1px solid;border-top:1px solid;border-right:none;border-bottom:1px solid;text-align:center;">Quantity</td>
                        <td style="width:15%;background-color:#707070;border-left:1px solid;border-top:1px solid;border-right:1px solid;border-bottom:1px solid;text-align:center;">Item</td>                        
                        <td style="width:27%;background-color:#707070;border-left:none;border-top:1px solid;border-right:1px solid;border-bottom:1px solid;text-align:center;">Description</td> 
                        <td style="width:12%;background-color:#707070;border-left:none;border-top:1px solid;border-right:1px solid;border-bottom:1px solid;text-align:center;">Unit Price</td>
                        <td style="width:12%;;background-color:#707070;border-left:none;border-top:1px solid;border-right:1px solid;border-bottom:1px solid;text-align:center;">Total</td>   

                    </tr> 
                    <apex:repeat value="{!retriveInvoiceInfo}" var="inv" id="theRepeat"> 
                
                    <tr style="font-size:16px;height:300px;vertical-align:text-top;Font-family:Verdana,Arial;"> 
                        <td style="border-left:1px solid;border-top:none;border-right:none;border-bottom:none;text-align:center;"><apex:outputText value="{!invoiceData.Quantity__c}"/></td>
                        <td style="border-left:1px solid;border-top:none;border-right:1px solid;border-bottom:none;text-align:center;"><apex:outputText value="${!unitprice}" rendered="{!IF(unitprice==NUll || unitprice==0,false,true)}"/></td> 
                        <td style="border-left:none;border-top:none;border-right:1px solid;border-bottom:none;text-align:center;"><apex:outputText value="{!inv.Product_Name_del__c}"/></td>           
                        <td style="border-left:none;border-top:none;border-right:1px solid;border-bottom:none;text-align:center;"><apex:outputText value="{!orderDiscount}" /></td> 
                        <td style="border-left:0.1px solid;border-top:none;border-right:1px solid;border-bottom:none;text-align:center;"><apex:outputText value="${!inv.Total_Amount_In_INR__c}" rendered="{!IF(inv.Total_Amount_In_INR__c==NUll || inv.Total_Amount_In_INR__c==0,false,true)}"/></td> 
                    </tr> 
                        
                    <tr style="font-size:16px;height:18px;Font-family:Verdana,Arial;">
                        <td style="border-left:none;border-top:1px solid;border-right:none;border-bottom:none"></td>                        
                        <td style="border-left:none;border-top:1px solid;border-right:none;border-bottom:none"> </td> 
                        <td style="border-left:none;border-top:1px solid;border-right:1px solid;border-bottom:none"> </td>           
                        <td style="border-left:none;border-top:1px solid;border-right:1px solid;border-bottom:1px solid;text-align:right;" >Subtotal</td> 
                        <td style="border-left:none;border-top:1px solid;border-right:1px solid;border-bottom:1px solid;text-align:center;"><apex:outputText value="${!inv.Subtotal_in_INR__c}" rendered="{!IF(inv.Subtotal_in_INR__c==NUll || inv.Subtotal_in_INR__c==0,false,true)}"/></td> 
                    </tr>
                   
                   <tr style="font-size:14px;height:14px;Font-family:Verdana,Arial;">
                        <td style="border-left:none;border-top:none;border-right:none;border-bottom:none"></td>                         
                        <td style="border-left:none;border-top:none;border-right:none;border-bottom:none"></td> 
                        <td style="border-left:none;border-top:none;border-right:1px solid;border-bottom:none"></td>             
                        <td style="border-left:none;border-top:none;border-right:1px solid;border-bottom:1px solid;text-align:right;">ServiceTax </td> 
                        <td style="border-left:none;border-top:none;border-right:1px solid;border-bottom:1px solid;text-align:center;"><apex:outputText value="${!inv.Indian_Service_Tax_Amount__c}" rendered="{!IF(inv.Currency__c=='INR' || inv.Indian_Service_Tax_Amount__c==0,false,true)}"/></td> 
                    
                    </tr>
                        
                        <tr style="font-size:14px;height:14px;Font-family:Verdana,Arial;">
                        <td style="border-left:none;border-top:none;border-right:none;border-bottom:none"></td>                         
                        <td style="border-left:none;border-top:none;border-right:none;border-bottom:none"></td> 
                        <td style="border-left:none;border-top:none;border-right:1px solid;border-bottom:none"></td>             
                        <td style="border-left:none;border-top:none;border-right:1px solid;border-bottom:1px solid;text-align:right;">Excise tax</td> 
                        <td style="border-left:none;border-top:none;border-right:1px solid;border-bottom:1px solid;text-align:center;"><apex:outputText value="${!inv.Swachh_Bharat_Cess__c}" rendered="{!IF(inv.Swachh_Bharat_Cess__c==NUll || inv.Swachh_Bharat_Cess__c==0,false,true)}"/></td> 
                    </tr>
                        
                    <tr style="font-size:14px;height:14px;Font-family:Verdana,Arial;">
                        <td style="border-left:none;border-top:none;border-right:none;border-bottom:none"></td>                         
                        <td style="border-left:none;border-top:none;border-right:none;border-bottom:none"> </td> 
                        <td style="border-left:none;border-top:none;border-right:1px solid;border-bottom:none"></td>             
                        <td style="border-left:none;border-top:none;border-right:1px solid;border-bottom:1px solid;text-align:right;"><b>Total Amount</b></td> 
                        <td style="border-left:none;border-top:none;border-right:1px solid;border-bottom:1px solid;text-align:center;"><apex:outputText value="${!inv.Total_Amount_In_INR__c}" rendered="{!IF(inv.Total_Amount_In_USD__c==NUll || inv.Total_Amount_In_USD__c==0,false,true)}"/></td> 
                    </tr>
                        
                    <tr style="font-size:14px;height:14px;Font-family:Verdana,Arial;">
                        <td style="border-left:none;border-top:none;border-right:none;border-bottom:none"></td>                         
                        <td style="border-left:none;border-top:none;border-right:none;border-bottom:none"> </td> 
                        <td style="border-left:none;border-top:none;border-right:1px solid;border-bottom:none"></td>             
                        <td style="border-left:none;border-top:none;border-right:1px solid;border-bottom:1px solid;text-align:right;"><b>Paid</b></td> 
                        <td style="border-left:none;border-top:none;border-right:1px solid;border-bottom:1px solid;text-align:center;"><apex:outputText value="${!inv.Total_Amount_In_INR__c}" rendered="{!IF(inv.Total_Amount_In_USD__c==NUll || inv.Total_Amount_In_USD__c==0,false,true)}"/></td> 
                    </tr>
                    
                    </apex:repeat> 
                   
                </table>
                
             
        </td>


In the above code i have highlighted the two fields that i want to hide when picklist value is changed.

How to achieve this...?

Can anyone help me out of this....!
  • May 03, 2016
  • Like
  • 0
Hi,

Below is my Apex Trigger and Test Class i have writte, the trigger is only showing 67% code coverage. Am i missing something here ?
 
trigger LeadandContactfieldsinTask on Task (after insert) {
 Set<Id> leadids = new Set<Id>();
   Set<Id> contactids = new Set<Id>();
    List<Task> taskstoupdate = new list<Task>();
     String FName = 'Sathiya';
    //Fetch only Leads which follow criteria
    for(Lead ld : [ SELECT Id, company, Leadsource, Rating, Title, sales_offering__c  FROM lead WHERE Owner.FirstName!= :FName])
        {
            leadids.add(ld.Id);
    }
    
    //Fetch only Leads which follow criteria
    for(Contact cts : [SELECT Id, Account.Name, LeadSource, Rating__c, Title, Sales_Offering__C from Contact])
    
        {
            contactids.add(cts.Id);
    }
    
    //Iterate over all Leads and modify Tasks for them + Add to a list variable 
    for(Lead ld : [SELECT Id, company, Leadsource, Rating, Title, sales_offering__c, (SELECT Id, Company_Account__c, Lead_Source__c,   Qualification__c, Solution_of_Interest__c, Title__c   FROM Tasks) from Lead Where Id IN : leadids])
    
     {
        for(Task t : ld.Tasks) {
        
            t.Company_Account__c = ld.company;
            t.Lead_Source__c = ld.Leadsource;
            t.Qualification__c=ld.Rating;
            t.Title__c= ld.Title;
            t.Solution_Of_Interest__c = ld.Sales_Offering__C;
            taskstoupdate.add(t);
        }
    }
    
    
    for(Contact cts : [SELECT Id, Account.Name, LeadSource, Rating__c, Title, Sales_Offering__C, (SELECT Id, Company_Account__c, Lead_Source__c,   Qualification__c, Solution_of_Interest__c, Title__c   FROM Tasks) from contact Where Id IN : contactids])
    
    {
        for(Task t : cts.Tasks)
    {
            t.Company_Account__c = cts.Account.Name;
            t.Lead_Source__c = cts.Leadsource;
            t.Qualification__c=cts.Rating__c;
            t.Title__c= cts.Title;
            t.Solution_Of_Interest__c = cts.Sales_Offering__C;
            taskstoupdate.add(t);
    
    }
        
    }
    
    //Update Tasks
    if(taskstoupdate.size()>0) {
        update taskstoupdate;
    }
    
}

Test Class - 
@isTest
private class LeadandContactfieldsinTask {

    static testMethod void myUnitTest() {
    
    
    
    Lead l1 = new Lead(
        LastName = 'Last',
        Title='CEO',
        Company='ABC Corp',
        Leadsource = 'webinar',
        Rating='Hot',
        Sales_offering__c = 'Quality',
        ownerid = '005700000012VFZ');      
       
        insert  (l1);  
        string l1Id = l1.id;
        
  Account ACC = new Account(
        name = 'ABC Corp',
        Ownerid='005700000012VFZ',
        Type = 'Prospect');
   
   Insert (Acc); 
       string accId = acc.Id;  
       string AccName = acc.Name;
        
   Contact c1 = new Contact(
        LastName = 'last',
        AccountID = ACC.ID,
        Title = 'CEO',
        LeadSource = 'Webinar',
        Rating__C = 'Hot',
        Sales_Offering__C='HEOR');
        insert (c1);
        string c1Id = c1.Id;
        
        test.startTest();
          
        Task tsk1 = new Task(
            Subject = 'Test task for Lead',
            Status = 'Not Started',
            Priority = 'High',
            Type_of_Correspondence__c ='call',
            Whoid= l1.id);
        insert (tsk1);
        
        Task tsk2 = new Task(
            Subject = 'Test for Contact Task',
            Status = 'Not Started',
            Priority = 'High',
            Type_of_Correspondence__c = 'call',
            whoid = c1.Id);
         insert (tsk2);  
        
        
    }
}

 
Hello All,

So far I've had experience writing Apex Triggers & the Test Classes. I am looking for some pointers that will help me modify the test class, which will give me a better coverage of the Apex Class. I've always written Test classes separately, and not within the class. It was written by our previous developer that is a part of the syncing (salesforce & remedy).

I am open to either modify the existing class/test class or just write a separate test class that will give me a better code coverage( Current 29%). The lines not covered by the test class are highlighted in Bold, Italic.

Below is the complete Class and the Test class within:


global class WS_RemedyEW{
 WebService static list<list<String>> getRemedyEW(String serialNumber, String SONumber){

    fxExtendedWarranty.FX_Extended_WarrantySoap syncRem = new  fxExtendedWarranty.FX_Extended_WarrantySoap();
    fxExtendedWarranty.AuthenticationInfo syncRemAuth = new fxExtendedWarranty.AuthenticationInfo();
    syncRemAuth.userName = 'mthomas';
    syncRemAuth.password= 'tinu@1980';
    syncRem.parameters = syncRemAuth;
    try{              
        fxExtendedWarranty.getListValues_element[] getResponce = syncRem.OpGetList('','','','','','','','','','','','','','','','','',serialNumber,SONumber,'');

        list<list<string>> ewDetails = new list<list<string>>();
        
        for(fxExtendedWarranty.getListValues_element ewItem: getResponce){
            list<string> ewElement = new list<string>();
            ewElement.add(ewItem.Serial_Number);
            ewElement.add(ewItem.SO_Number);
            ewElement.add(ewItem.CommencementMonth);
            ewElement.add(ewItem.CommencementYear);
            ewElement.add(ewItem.Company_Name);
            ewElement.add(ewItem.Customer_Company_Name);
            ewElement.add(ewItem.CustomerName);
            ewElement.add(ewItem.Dealer);            
            ewElement.add(ewItem.ExpirationMonth);
            ewElement.add(ewItem.ExpirationYear);
            ewElement.add(ewItem.Full_EW);
            ewElement.add(ewItem.HW_EW);
            ewElement.add(ewItem.Part_Number);
            ewElement.add(ewItem.PONumber);
            ewElement.add(ewItem.Product);
            ewElement.add(ewItem.ProductName);
            ewElement.add(ewItem.SW_FW_EW);
            ewElement.add(ewItem.ADV_EW);
            if (string.valueof(ewItem.POS_Date).length() > 0) {ewElement.add(ewItem.POS_Date.substring(0,10));} else {ewElement.add(ewItem.POS_Date);}
            ewDetails.add(ewElement);            
        }
       return ewDetails;        

     }catch(Exception e){   
        //Write to the error log file
    }  
  return null;
 }
   private static testMethod void myTest() {
    getRemedyEW('MSN%','1');
  }
}
Hi
I have an Insert trigger (after insert) on object Reservation Terrain than update Terrain Disponible object.
I have to update the Terrain_Disponible.Available field to "NO", and update Terrain_Disponible.Date_reserve field to Reservation_Terrain.Date_de_reservation value

Here is the schema

User-added image

Here the code with an error at line 13
trigger TRG_Reservation2 on Reservation_Terrain__c (after insert) {
    Set<Id> tdIdSet = new Set<Id>();
    for(Reservation_Terrain__c rt: Trigger.new) {
        if(rt.Terrain_Disponible__c != null)
            tdIdSet.add(rt.Terrain_Disponible__c);
    }
   
    if(!tdIdSet.isEmpty()) {
        List<Terrain_Disponible__c> tdList = [SELECT Id, Name, Available__c, Date_reserve__c FROM Terrain_Disponible__c WHERE Id IN: tdIdSet];
       
        for(Terrain_Disponible__c td: tdList) {
            td.Available__c = 'NO';
            td.Date_reserve__c = Date_de_reservation__c.new;  <-- The error line
        }
        update tdList;
    }
}

Could you give me a hand?

thank you

 
As per my recent response to this post, newer versions of Data Loader (certainly v26.0 and newer) can be installed silently (i.e. without the need for user intervention).

The installer for v36.0 has added an additional option to install for just the current user or to install for all users.

Data Loader Setup - Select install type

For a silent install, Is there a way to override the Single User default and install for All users
trigger InvoiceSum on Invoice_Items__c (after insert, after update)
    {
     Set<Id> InvIds = new Set<Id>();   
     for(Invoice_Items__c ii :trigger.new)
     { InvIds.add(ii.InvoiceFK__c); }

        List<Invoice__c> InvRecs = [Select id, Ammount__c from Invoice__c where id in : InvIds ];
       
       for(Invoice__c inv : InvRecs)
        {
          //inv.Ammount__c= [Select sum(Invoice_items__r.Amount__c) from Invoice_Items__c ];
           Decimal total=0;
        //   for (Invoice_items__c iit: inc.Invoice_items__c)
          inv.Ammount__c =inv.Invoice_items__r.Amount__c;
            update inv;
        }
     
    }
Invoice__c is parent object and Invoice_item__c is child, I have to sum the all line items amount and display on Invoice__c record. Please help.
public class TotalExpenseComputation { 
   
   
 
    /*
     * The totalExpense method calculates the total of all the approved expenses as well as the amount left
     *
     * for both the marketing and sales budget.
     * */
public static void totalExpense(Expense__c[] expenses)
{
    //Query to get  Initial Amount,Total Expense and Remaining Amount field from respective budgets.
 
    List<Budget__c> typeList = new List<Budget__c>();
   
for(Budget__c[] b:[SELECT Name,Initial_Amount__c,Total_Expenses__c,Remaining_Amount__c,Type__c FROM Budget__c])
{
for(Expense__c exp:expenses)
    {
        if(exp.Type__c.equals('Marketing')&& exp.Budget_LookUp__c.equals(b.Name))
        {
             if(exp.Status__c.equals('Approved'))
             {
                
              b.Total_Expenses__c= exp.Amount__c+b.Total_Expenses__c;
               b.Remaining_Amount__c=b.Initial_Amount__c-b.Total_Expenses__c;
               typeList.add(b);
                
             }
              
        }
       
        if(exp.Type__c.equals('Sales')&& exp.Budget_LookUp__c.equals(b.Name))
        {
            if(exp.Status__c.equals('Approved'))
            {
              
                b.Total_Expenses__c  =exp.Amount__c+b.Total_Expenses__c;
                b.Remaining_Amount__c=b.Initial_Amount__c-b.Total_Expenses__c;
              typeList.add(b);
               
              }
        }
       
    }update typeList;}
   
 
I have a method which creates Map<String,Object> by querying a object. I need to pass this value to a future method which has callout. Since callout method does not accept Sobject type as parameter, i need to convert this Map<String,Object> to Map<String,String>. 

Appreciate any insights on this issue

List<SObject> listObjectRecords = database.query('select ' + cusFields + ' from '+ objName + ' WHERE ID = \'' + objId + '\'');
 for(SObject sObj : listForMap) {
Map<String,Object> mapObj = (Map<String,Object>)Json.deserializeUntyped(Json.serialize(sObj));
}



 
We have a salesforce instance with multiple applications. This setup allows the admin role the ability to configure everything in  every app. Howeever, I have a new customer that wants admin rights to be able to configure their own app e.g. manage users, layouts etc.  How can I accomplish this? I'm thinking I need to set up a new SF instance or is there a way to use the existing instance and just restrict configuration to his application by creating a custom role?
During the maintenance window yesterday, April 3rd, Trailhead and some other SF resources were routing to a custom HTTP 500 page that indicated a general system failure. I think it would be better it clearly stated it was a maintenance window, and possibly give an estimate of when the site would be back up. Can someone inside SF look into this ?
Hi. I'm trying to get the current machin name (ip address) of the pc, with the Custom Button or Link, using "execute javascript".
I tried several things, but didn't succeed, Help?
thanks  :)
 
I am trying to create a validation rule to enforce users to fill out a lookup field based on a multi-select. Here is the trick

Multi-Select has 3 options(A,B,C) and we have 3 different lookups called A,B,C

If I select A from the picklist then I have to fill out lookup A
If I select B then fill out lookup B
If I select C then fill out lookup C 

However,

if I select A,B fill out lookup A,B
if I select A,C - then lookup A, C
if I select B,C - then lookup B,C 

Any thoughts how I can write this validation?

 
Hi all,

I'm getting the following error with a Detail Page Button that runs an apex class.

User-added image

Here is the apex class:
 
global class logHearingResult{
    
  WebService static Id changePriority(Id currentCase) {
   
    //new set to hold current case Ids
    Set<Id> caseIds = new Set<Id>();
    
    //add current case Id to above set (currentCase is passed from javascript button)
    caseIds.add(currentCase);
    
      
    //new list to hold cases with the current case's Id
    List<Case> results = [
        select Id, Priority
        from Case
        where Id in :caseIds
    ];    
    
    //set caseIdToReturn to first Id in results list (this is just for test where popup from button displays current case Id)
    id caseIdToReturn = results.get(0).Id;
    
    List<Hearing_Result__c> resultsToInsert = new List<Hearing_Result__c>();  
    
    //work based on current case
    for (Case c : results){
        c.Priority = 'High';
        Hearing_Result__c ins = new Hearing_Result__c (ContactID__c = c.ContactId);
        resultsToInsert.add(ins);
    }
    
    insert resultsToInsert;
    update results;
    return caseIdToReturn;
      
  }
    
}
On line 27, I am assigning the ContactID__c value to the same contact ID that is associated with the current case. This is why I'm confused by the error.

Is it because I'm using a List to store the values to be inserted (and this can't hold the assigned ID)?

Thanks!
Hi all,

I have a scenario.. I have a Picklist Some__c. based on the Picklist value i need to display the Interest Rates like 10%, 11%, 12%, etc.. Here i need to display for one Picklist there are different interest rates.. For Example: For 'A' picklist value i need to display 10% and 12%.

How can i achieve this.

Help on this. Thanks in advance.. 
I am having issues with Creating  an Apex class that returns Account objects for the Mapping.net concepts challenge.  I am a VB and Javascript programmer and I can't seem to get the syntax right.   
public class AccountUtils {
    
    public static void accountsByState(String st){
       List<String> accts = [SELECT Id, Name FROM Account WHERE billingState = :st];
 }
  
}
I believe the first part is correct, but I cannot seem to get a return value.  I am confused by the constructors.  I have tried the documentation but I can't get a return value.  Please help.  I need to get this challenge complete.
 
I'm new to salesforce Please explain these question
Is it advisable to call batch class from trigger? If Yes, Why? If No, Why?
Hi Everyone,

I've found the code for this at the following link,
http://developer.force.com/cookbook/recipe/overriding-a-page-for-some-but-not-all-users

but not able to understand the following "IF statement"
 
<apex:page action=
  "{!if($Profile.Name !='System Administrator', 
	null, 
	urlFor($Action.Account.Tab, $ObjectType.Account,
	null, true))}"
  standardController="Account" 
  recordSetVar="accounts" 
  tabStyle="Account">

  <!-- Replace with your markup -->  
	
  This page replaces your Account home page for 
  all users except Administrators.
</apex:page>

can anyone explain me what is happening in IF statement...
Iam a NEWBIE...

regards,
Suresh.
Hello,

Any samples on how to write a test class for a Schedular Class.

Thanks in Advance!!