• PavanK
  • NEWBIE
  • 335 Points
  • Member since 2012

  • Chatter
    Feed
  • 9
    Best Answers
  • 0
    Likes Received
  • 14
    Likes Given
  • 4
    Questions
  • 97
    Replies
I am in the "Creating List Views" unit and it says "To create a view, click Create New View at the top of any list page or in the Views section of any tab home page." The Exercise is asking me to create a view for the Contacts but I can't find the link.  What am I missing?
I just got back from taking ADM-231 and I am trying to put what i learned in to practices. We have some custom code that I need to edit. I can kind of tell what it says now but still not sure.

I need to edit it so that it does not up date  "CampaignId" unless HasResponded = True in the CampaignMember sObject. 
Any help would be great.
 
trigger Opportunity on Opportunity (after delete, after insert, after undelete, after update, before delete, before insert, before update) {
    if(trigger.isBefore){
        if(trigger.isInsert){
   
           /////////// non bulk trigger
           if(trigger.new.size() > 1){
            return;
           }
           /////////// non bulk trigger
         
           Opportunity o = trigger.new[0];
           System.debug('Akash --> o:' + o);
            System.debug('Akash --> 1:' + o.ECi_Product__c);
           
         
           if((o.Type_of_Sale__c == 'New System' || o.Type_of_Sale__c == 'Aftermarket')){
                
                list<Contact> lstContact = [Select Id From Contact Where AccountId = :o.AccountId ];
               list<Lead> lstLead = [Select Id From Lead Where Id  =: o.Leadid__c ];
               String soql = ' Select Id,CampaignId,Campaign.Type,Response_Tracking_Date__c, Campaign.Type_of_sale__c ';
               soql += ' From CampaignMember ';
               soql += ' Where Campaign.ECi_Product__c = \'' + o.ECi_Product__c + '\' and Campaign.Type_of_sale__c = \''+ o.Type_of_Sale__c+'\'';
               
               System.debug('Akash --> lstContact:' +lstContact);
               System.debug('anuj--> LstLead:' +lstLead);
               /*    
               if(o.Type_of_Sale__c == 'Aftermarket'){
                soql += ' And Campaign.ECi_Aftermarket__c = \'' + o.ECi_Aftermarket__c + '\'';
               }
                */
               soql += ' And Status = \'Responded\'';
               soql += ' And Response_Tracking_Date__c != null';
               soql += ' And ( ContactId In :lstContact OR LeadId In :lstLead )';
               soql += ' Order By Response_Tracking_Date__c Desc';
                
               System.debug('Akash --> soql:' + soql);
               List<CampaignMember> cmList = new List<CampaignMember>();
               cmList = Database.Query(soql);
               if(cmList.size() > 0){
                   for(CampaignMember cm: cmList){
                     
                       System.debug('Akash --> cm:' + cm);
                       System.debug('Akash --> cm.Campaign.Type:' + cm.Campaign.Type);
                         
                       Campaign_Type_Time_Mapping__c cttm = Campaign_Type_Time_Mapping__c.getall().get(cm.Campaign.Type); 
                    
                      
                         
                       if(cttm != null && cttm.Value__c != null){
                         
                           DateTime startDT = DateTime.now(); 
                           DateTime EndDT = DateTime.now();
                             
                           
                             
                           if(cttm.Type__c == 'Year'){
                                startDT = startDT.addYears(-1*Integer.valueOf(cttm.Value__c));
                           }else if(cttm.Type__c == 'Month'){
                                startDT = startDT.addMonths(-1*Integer.valueOf(cttm.Value__c));
                           }else if(cttm.Type__c == 'Day'){
                                startDT = startDT.addDays(-1*Integer.valueOf(cttm.Value__c));
                           }
                             
                           System.debug('Akash --> startDT:' + startDT);
                           System.debug('Akash --> EndDT:' + EndDT);
                            
                           if(cm.Response_Tracking_Date__c >= startDT && cm.Response_Tracking_Date__c <= EndDT){
                                
                               System.debug('Akash --> cm.Response_Tracking_Date__c:' + cm.Response_Tracking_Date__c);
                               System.debug('Akash --> startDT:' + startDT);
                               System.debug('Akash --> EndDT:' + EndDT);
                                    
                               o.CampaignId = cm.CampaignId;
                               System.debug('Akash --> oppor \n' + o);
                               break;
                           }
                       }
                   }
               }else{
                    o.CampaignId = null;
               }    
           }
        }
    }
}

 
Hi friends,

I want to convert this value Sun Jun 12 00:00:00 GMT 2016 into date format 06/12/2016(MM/DD/YYYY) format. I am using custom controller. While fetching data from time_entry object its showing in VF page like this Sun Jun 12 00:00:00 GMT 2016. So while showing in page I want dd/mm/yyyy format. Here I attached my code . Please help on this.
 
<apex:page standardController="Time_Entry__c" showHeader="false" sidebar="false" standardStylesheets="true" recordSetVar="timelist" >
  <apex:form >
      <apex:pageBlock title="Time Entry Page" >
          <apex:pageBlockButtons location="top" >
                  <apex:commandButton value="Select"/>
                   </apex:pageBlockButtons>   
         
            <apex:selectList multiselect="false" size="1"  >
                  <apex:selectOption itemValue="MON" itemLabel="--Month--">  </apex:selectOption> 
                  <apex:selectOption itemValue="JAN" itemLabel="January">  </apex:selectOption> 
                  <apex:selectOption itemValue="FEB" itemLabel="February"> </apex:selectOption>
                  <apex:selectOption itemValue="MAR" itemLabel="March"> </apex:selectOption>
                  <apex:selectOption itemValue="APR" itemLabel="April"> </apex:selectOption>     
                  <apex:selectOption itemValue="MAY" itemLabel="May"> </apex:selectOption> 
                  <apex:selectOption itemValue="JUN" itemLabel="June"> </apex:selectOption> 
                  <apex:selectOption itemValue="JUL" itemLabel="July"> </apex:selectOption> 
                  <apex:selectOption itemValue="AUG" itemLabel="August"> </apex:selectOption> 
                  <apex:selectOption itemValue="SEP" itemLabel="September"> </apex:selectOption> 
                  <apex:selectOption itemValue="OCT" itemLabel="October"> </apex:selectOption> 
                  <apex:selectOption itemValue="NOV" itemLabel="November"> </apex:selectOption> 
                  <apex:selectOption itemValue="DEC" itemLabel="December"> </apex:selectOption> 
              </apex:selectList>
              <apex:selectList multiselect="false" size="1">
                  <apex:selectOption itemValue="YEAR" itemLabel="--Year--">  </apex:selectOption> 
                  <apex:selectOption itemValue="2016" itemLabel="2016">  </apex:selectOption> 
                  <apex:selectOption itemValue="2017" itemLabel="2017">  </apex:selectOption> 
                  <apex:selectOption itemValue="2018" itemLabel="2018">  </apex:selectOption> 
                  <apex:selectOption itemValue="2019" itemLabel="2019">  </apex:selectOption> 
                  <apex:selectOption itemValue="2020" itemLabel="2020">  </apex:selectOption> 
              </apex:selectList>
                   
                   
        
                <apex:pageBlockTable value="{!timelist}" var="t" columns="4">
                <apex:column width="25%" > <apex:outputLink value="/apex/te_detail?idx={!t.id}">{!t.name}</apex:outputLink> </apex:column>
                <apex:column value="{!t.Time_From_Date__c}"/>
                <apex:column value="{!t.Time_To_Date__c}"/>
                <apex:column value="{!t.Status__c}"/>
          </apex:pageBlockTable>         
         
          
      </apex:pageBlock>
  </apex:form>
</apex:page>

Controller is
 
Public class Wrapperclassdemo{
    /* Our Wrapper Class */
    Public Class Tablerow{
        Public Date Fromdate {get;set;}
        Public Date Todate {get;set;}
        Public String Status {get;set;}
        Public String Name {get;set;}
        
    
    }
    /*Public Property that will hold all the Tablerows and our PageBlockTable can use this Variable   to get the whole List of rows*/
    Public List<Tablerow> Rowlist {get;set;}
    
    /*Constructor that runs a SOQL to get all the Records and build the List. This get executed automatically on the Page Load.*/
    Public Wrapperclassdemo(){
        Rowlist = new List<Tablerow>();
        Tablerow tr;
        /*Building the List of TableRows*/
        /*Fetch all the Contacts and then build the List*/
        
        

    } 
    
   Public void select1(){
   
          for(Time_Entry__c tm : [Select Name, Time_From_Date__c,Time_To_Date__c,Status__c from Time_Entry__c ]){
            Tablerow tr = new Tablerow();
            tr.Fromdate = tm.Time_From_Date__c;
            tr.Todate = tm.Time_To_Date__c;
            tr.Status = tm.Status__c;
            tr.Name = tm.Name;
            
            /*Add the TableRow to the List then and there*/
            
            Rowlist.add(tr);
                
        }
   
   
   
   }
}

 
In my case, I want to show pessage with a div, when a checkbox is checked. But when it is unchecked, I want to hide the div. I can it by using javascript, but it failed. Is there any problem for the script?
<apex:page standardController="M_Pioneers__c" extensions="addPionners">
 <head>
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
 <script src="https://code.jquery.com/jquery-1.10.2.js"></script>
 </head>
 <apex:form >
  <script>
$(".showp").hide();
$("#checkbox").click(function() {
    if($(this).is(":checked")) {
        $(".showp").show("slow");
    } else {
        $(".showp").hide("slow");
    }
});

  </script>
  <apex:pagemessages />
  <div>
   <label for="M_Pioneers_Name__c">Name</label>
   <apex:inputField value="{!pioneers.M_Pioneers_Name__c}" id="M_Pioneers_Name__c"/>
  </div>
  <div>
   <label for="M_Pioneers_Email__c">Email</label>
   <apex:inputField value="{!pioneers.M_Pioneers_Email__c}" id="M_Pioneers_Email__c"/>
  </div>
  <div>
   <label for="M_Pioneers_Phone__c">Contact Number</label>
   <apex:inputField value="{!pioneers.M_Pioneers_Phone__c}" id="M_Pioneers_Phone__c"/>
  </div>
  <div>
   <apex:inputCheckbox id="checkbox" onfocus="showp()"/>
  </div>
  <div class="showp" style="display: none">
  <p>HI!</p>
  </div>
 </apex:form>
</apex:page>

Thank you so much.
Hello,

I am trying to create a trigger to populate a Contract Uploaded Date on the Opportunity. I am new to triggers and keep getting erros on both the apex trigger and apex class. Can someone please help me? 

trigger setContractAttachment on Attachment (before insert) {
    List<Opportunity> listOpp = new List<Opportunity>();
     for(Attachment att: Trigger.New){
        if(att.ParentId.getSobjectType() == Opportunity.SobjectType) {
            oppId.add(att.ParentId);
            opp.Contract_Uploaded_Date__c=Date.today();
}

//update the Opportunities
    opportunityList = [select id, has_Attachment__c from Opportunity where id is : oppId];
    if(opportunityList!=null && opportunityList.size()>0){
        for(Opportunity opp : opportunityList){
            opp.has_Attachment__c = true;
        }
        update opportunityList;
    }


Test Class

Test Class
@isTest
 
public class ContractAttachmentTest {
    Opportunity = [Select id=;0062C0000022sfT]
    
    Attachment attachTest = new Attachment (Name= 'Test');
    attachTest.body = Blob.valueOf('')
    attachTest.ParentID = b.Id;
    attachTest.OwnerID = U.Id;
    insert attachTest;
        
}
 
Hi Everyone,

Brand new to Visualforce and I seem to have hit an error in my syntax, though I believe there is a better way to go about what I am trying to accomplish.

I am attempting to pass an account id to a report and have had success with the below code.
<apex:outputLink onclick="return isClickedInConsole(this)" html-data-reporturl="/{!$Label.Factset_List_View}?pv1={!URLENCODE(LEFT(Account.id,15))}" id="theLink_14">
                <apex:outputLabel value="Factset List View"/>
                <br/>
</apex:outputLink>

But I have now been requested to dynamically send the parent account id if the Hierarchy Level is equal to L3. Using the following code and other similar variations I recieve a syntax error and I am not sure how to go about solving it.
<apex:outputLink onclick="return isClickedInConsole(this)" html-data-reporturl="/{!$Label.Factset_Dashboard}?pv1={!URLENCODE(LEFT({!IF((Account.Hierarchy_Level__C=='L3'),Account.parentid,Account.id)},15))}" id="theLink_13">
                <apex:outputLabel value="Factset Dashboard"/>
                <br/>
</apex:outputLink>

Any help is greatly appreciated, thanks!
We have migrated to a new CPQ package in Salesforce, but have an old, unsupported trigger that is causing problems with creating new Opportunities. I deactivated the trigger in my Sandbox, pushed it out in a change set, but it fails in the Production Org because there is no test class?

I have no idea how to write the test class, and have no access to the old third-party support. 

Here is the trigger:
//This is provided as a sample to require a contact on opportunities it is provided without warranty and support. 

trigger opportunity_contact_required on Opportunity (before insert, before update) {
/*
    //map to keep track of the contact_required = 1
    Map<String, Opportunity> oppy_contact = new Map<String, Opportunity>();

    //Trigger.new is an array of opportunities 
    //and adds any that have Contact_Required = 1 to the oppy_contact Map
    for (Integer i = 0; i < Trigger.new.size(); i++) {
        System.debug('*****Required? ' + Trigger.new[i].contact_required__c);
        if  (Trigger.new[i].contact_required__c == 1) {
            oppy_contact.put(Trigger.new[i].id,Trigger.new[i]);
        }  
    }

    //map to keep track of the opportunity contact roles
    map<Id, OpportunityContactRole> oppycontactroles = new map<Id, OpportunityContactRole>();

    //select OpportunityContactRoles for the opportunities with contact role required 

    List<OpportunityContactRole> roles = [select OpportunityId, IsPrimary from OpportunityContactRole
        where (OpportunityContactRole.IsPrimary = True and OpportunityContactRole.OpportunityId
        in :oppy_contact.keySet())];


    for (OpportunityContactRole ocr : roles) {
        //puts the contact roles in the map with the Opportunity ID as the key
        oppycontactroles.put(ocr.OpportunityId,ocr);
    }

    // Loop through the opportunities and check if they exists in the contact roles map or contact role isn't required    
    for (Opportunity oppy : system.trigger.new) {
        //system.debug('List oppy Id - '+oppy.id);
        if  (oppy.contact_required__c ==1 && !oppycontactroles.containsKey(oppy.id))
        {
            oppy.addError('No Primary Contact Exists. Please go to the Contact Roles and select a primary contact.  Insure that all contacts related to this Opportunity are properly added in the Contact Roles with respective roles assigned.');       
        }
    } //for    */
 }

Here is the error: http://screencast.com/t/2V9hnkTH1 
User-added image
Hi All,

I need to create a trigger that flags a checkbox when two fields of different objects have the same value:
I have two objects with a field a want to map:
OBJECT: Radio_Taxi__c----> FIELD: Radio_Taxi_Trip_ID__c
OBJECT: Gastos__c----> FIELD: ID_Radio_Taxi__c

We always create a new Gasto record before a new Radio Taxi Record. 
I need to set to TRUE a field (Gasto_creado_en_SF__c) in Radio Taxi Object every time a new Radio Taxi record is created and the  Radio_Taxi_Trip_ID__c and  ID_Radio_Taxi__c fields have the same value.

Thanks!!!
 
Seriously, code coverage will be the death of me! This test is not returning any coverage and I can't figure out why. Any suggestions?

Here's the trigger. It's supposed so transfer two dates from the relationship field Opportunity__c on the contract when the contract record is updated. However in the developer console the code coverage is 0%.
 
trigger TransferOpportunityValue on Contract (before update) { 
     
    for(Contract c : Trigger.new){

        if(c.Opportunity__c != null){

        	Opportunity o = [Select id,Pay_History_Received__c,Pay_History_Reviewed__c From Opportunity Where Id = :c.Opportunity__c];
			c.Pay_History_Received__c = o.Pay_History_Received__c;
			c.Pay_History_Reviewed__c = o.Pay_History_Reviewed__c;
            
        }

    }

}

The test class is here, I'm updating the field price_level__c, but to no avail the coverage is still 0% and there are definitely activated contracts. Anyone have any idea why? You help is much appreciated.
 
@isTest

private class TestUpdateContract {
    
    static testMethod void myTest() {

        Contract con; 
        con= [SELECT Id,price_level__c FROM Contract LIMIT 1];
         
        con.price_level__c = '12345';
        update con;           
        
    }

}


 
Question:
  •  I want to understand, if we are using Winter-17 non preview sandbox then what will happen to 'Non-preview sandboxes' after Winter 17 release to production which is scheduled for Oct-15, 2016.
  • Sandboxes will also automatically update to Winter 17 or it will stay on older version and we have to refresh sandbox after Oct 15th, 2016?.
 
To me more specific, please refer below senario
 
  • If we refresh sandbox on 15th Sept 2016 then even after 15th Oct 2016 we will not get Winter 17  in our sandboxes.
  • Only way to get Winter 17 in these(non-preview) sandboxes is refresh after 15th Oct 2016?
 
Thanks
  • September 02, 2016
  • Like
  • 0
I want to understand, if we are using Winter-17 non preview sandbox then what will happen to 'Non-preview sandboxes' after Winter 17 release to production which is scheduled for Oct-15, 2016.

Sandboxes will also automatically update to Winter 17 or it will stay on older version and we have to refresh sandbox after Oct 15th, 2016?
  • September 02, 2016
  • Like
  • 0
Hi,

We are using visualforce pages with bootstrap and till yesterday it was working fine.

But from today scroll is not working.

If there is scrollable content(long verticle data) on page then on click page is blanking out.

If there is enough data for single screen then its working fine.

Please help as it may impact my delivery. Thanks
Hi All,

I am Salesforce developer and I have good knowledge on apex and VF. But I am not good with Javascript or bootstrap.

I have learned Bootstrap but facing issue on how to use with VF page. If anybody can send me example class and page which can work in mobile will be great.

If page is showing any table that will be great. You can mail me code snippet on pvnkhapre03@gmail.com

thank in advance.
I am in the "Creating List Views" unit and it says "To create a view, click Create New View at the top of any list page or in the Views section of any tab home page." The Exercise is asking me to create a view for the Contacts but I can't find the link.  What am I missing?
Question:
  •  I want to understand, if we are using Winter-17 non preview sandbox then what will happen to 'Non-preview sandboxes' after Winter 17 release to production which is scheduled for Oct-15, 2016.
  • Sandboxes will also automatically update to Winter 17 or it will stay on older version and we have to refresh sandbox after Oct 15th, 2016?.
 
To me more specific, please refer below senario
 
  • If we refresh sandbox on 15th Sept 2016 then even after 15th Oct 2016 we will not get Winter 17  in our sandboxes.
  • Only way to get Winter 17 in these(non-preview) sandboxes is refresh after 15th Oct 2016?
 
Thanks
  • September 02, 2016
  • Like
  • 0
The error I am getting is  :

Error: Invalid Data.
Review all error messages below to correct your data.
Apex trigger hybinjoseph1.AcctTrigger caused an unexpected exception, contact your administrator: hybinjoseph1.AcctTrigger: execution of AfterInsert caused by: System.FinalException: Cannot modify a collection while it is being iterated.: Trigger.hybinjoseph1.AcctTrigger: line 9, column 1

and my tirgger is :

trigger AcctTrigger on Account (After Insert) {

list<contact> conlist = new list<contact>();

for(Account a : trigger.new){

conlist = [SELECT AccountID, Name from Contact WHERE Mailingcity = :a.Billingcity];

for(contact con : conlist){
con.AccountId = a.Id;
conlist.add(con);

}


}
update conlist;

}



I am new to writing triggers so cant understand whats wrong here.Please help
I always had web-to-lead working for us but after we upgraded to Enterprise edition. Everything stops working. We even tried regenerating the form with just first name and last name field and that didn't help.

Any idea how to debug this?
Hi,

I was wondering how I could write a for loop instead of a for each loop to cycle through each object in the trigger. The reason being, I want to reference the number that object is in the List of objects in the trigger- later in the code after cycling through the loop. I have tried google searches and all the triggers seem to use this format- for each loop:

"for (User userInLoop : Trigger.new) {...}"

I tried using a for loop like this for account trigger- "for(Integer i = 0; i < Trigger.new.size(); i++) { 

Account a = Trigger.new.get(i);

//do some code on Account a...

}"


This kept giving me an error. Is this not allowed? 

Thanks!
Mazlow
Help! I'm trying to update a custom account field to editable, that is currently read-only. I've tried going to Accounts -> Fields -> Click Specific Field -> Set Field Level Security and I do not have the option to unselect Read-Only. 

I've also tried to update the System Administrator Profile to allow for Edit Access under the speicfic Account Field but again - it will not allow me to edit the "Edit Access". 

Please HELP!
 
Apex Class:

public class Testcontroller {
    public String temp {get; set;}
    public Opportunity oppstagename{set;get;}
    public account accrating{set;get;}
    public Lead ldsource{set;get;}
    public List<Opportunity> opplist{set;get;}
    public List<Account> acclist{Set;get;}
    public List<Lead> ldlist{set;get;}
    public boolean oppstgbool{set;get;}
    public boolean accbool{set;get;}
    public boolean ldbool{set;get;}
    public Opportunity Oppt{set;get;}
    public boolean newoppt{set;get;}
    
    public List<Contact> conList {get;set;}
    public List<Contact> conAddList {get;set;}
    public String conName {get;set;}   
    public boolean addrowbool{set;get;}
    public Integer rowNum{get;set;}
    
    public Testcontroller() 
    {
        oppstagename=new Opportunity();
        accrating=new account();
        ldsource=new lead();
        oppstgbool=false;
        accbool=false;
        ldbool=false;
        newoppt=false;
        addrowbool=false;
        Oppt=new Opportunity();       
    } 
    
    public PageReference newopptsave()
    {
        insert oppt;
        ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.Confirm,'New Opportunity is Sucessfully Saved.'));
        return null;
    }
    
    public PageReference newopptsavenew()
    {
        insert oppt;
        oppt.clear();
        ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.Confirm,'New Opportunity is Sucessfully Saved and Cleared.'));
        return null;
    }
    
    public SelectOption[] getAccountNames(){
        SelectOption[] acccopptoptions = new SelectOption[]{};
            acccopptoptions.add(new SelectOption('','--None--')); 
        
        for (Opportunity accoppt : [select id, name,accountid,account.name FROM Opportunity ]) {  
            if(accoppt.account.name!= null) {
                acccopptoptions.add(new SelectOption(accoppt.accountid, accoppt.account.name));  
            }
        } 
        return acccopptoptions;
    }
    
    public void find()
    {
        if(temp == 'Opportunity')
        {
            oppstgbool=true;
            accbool=false;
            ldbool=false;
            newoppt=false;
            addrowbool=false;
            opplist=[Select id,Name,StageName FROM Opportunity WHERE StageName=:oppstagename.StageName Limit 5];
        }
        else if(temp == 'Account')
        {
            oppstgbool=false;
            accbool=true;
            ldbool=false;
            newoppt=false;
            addrowbool=false;
            acclist=[Select id,Name,Rating FROM Account WHERE Rating=:accrating.Rating and Rating!=null Limit 5];
        } 
        else if(temp == 'Lead')
        {
            oppstgbool=false;
            accbool=false;
            ldbool=true;
            newoppt=false;
            addrowbool=false;
            ldlist=[Select id,Name,LeadSource FROM Lead WHERE LeadSource=:ldsource.LeadSource and LeadSource!=null Limit 5];
        }
        else if(temp == 'New Opportunity')
        {
            oppstgbool=false;
            accbool=false;
            ldbool=false;
            newoppt=true;
            addrowbool=false;
            Oppt=new Opportunity();
        }
        else if(temp == 'Addrow Contact')
        {
            oppstgbool=false;
            accbool=false;
            ldbool=false;
            newoppt=false;
            addrowbool=True;
            String sql='SELECT id,LastName,Phone,Email FROM Contact';
            conlist=Database.query(sql);
            conAddList=new List<Contact>();
            conAddList.add(new Contact());
        }
        else{
            oppstgbool=false;
            accbool=false;
            ldbool=false;
            addrowbool=false;
            newoppt=false;
        }
    }   
    
    public void AddRow(){
        conAddList.add(new Contact());
    }    
    
    public void delRow()
    {
        rowNum = Integer.valueOf(apexpages.currentpage().getparameters().get('index'));
        conAddList.remove(rowNum);   
    }   
    
    public void Savecon()
    {
        insert conAddList;
    }
    
    public void Cancel()
    {
        oppstgbool=false;
        accbool=false;
        ldbool=false;
        addrowbool=false;
    }
}
 
Test Class:

@isTest
public class Testcontroller_Test {
    static testMethod void Testcontroller_Test() {
        
        Account acc = new Account(Name='Abce');
        insert acc;
        Opportunity  testOppty = new Opportunity();
        testOppty.name='testOppty';
        testOppty.AccountId=acc.id;
        testOppty.StageName='Open';
        testOppty.CloseDate=System.today();
        insert testOppty;
        
        Testcontroller tc=new Testcontroller();
        tc.find();
        tc.getAccountNames();
        tc.newopptsave();
        tc.newopptsavenew();
        tc.AddRow();
        tc.Savecon();
        tc.Cancel();
    }
}

 
Good Afternoon,

I have created a trigger in Sandbox but when I try to deploy it to production it will not work due to code coverage error. Do I need to add a test class? If so, how would I do that for this trigger? 

trigger setContractAttachment on Attachment (before insert) {
    List<Opportunity> opportunityList = new List<Opportunity>();
   set<Id> oppId = new set<Id>();
     for(Attachment att: Trigger.New){
        if(att.ParentId.getSobjectType() == Opportunity.SobjectType) {
            oppId.add(att.ParentId);
       }
}

//update the Opportunities
    opportunityList = [select id, Contract_Uploaded_Date__c from Opportunity where id in : oppId];
    if(opportunityList!=null && opportunityList.size()>0){
        for(Opportunity opp : opportunityList){
           opp.Contract_Uploaded_Date__c=Date.today();
        }
        update opportunityList;
    }
}
Hi,

I'm adding apex:outputtext values into variable to compare , but unable to execute please help me
 
<script>
 function sound()
            {
                var i= '{i.OrdlItem.Supplied_Quantity__c.size()}';
                var j ='{ord.Supplied_Quantity__c.size()}';
                if(i>j){
                    alert('value increased');
                }
</script>


    <apex:dataTable value="{!orderItemsList}" border="1" var="ord" id="theTable" rowClasses="odd,even" styleclass="outBorder" width="550px" rendered="{!orderItemsList.size>0}">

  </apex:column>
        <apex:column styleclass="inBorder" >
            <apex:facet name="header">Supplied Quantity</apex:facet>
            <apex:outputText value="{!ord.Supplied_Quantity__c}"/>
        </apex:column>


 <apex:pageBlockTable value="{!ListItem}" var="i">
<apex:column headerValue="Supplied Quantity">
                    
                  
                            <apex:outputText value="{!i.OrdlItem.Supplied_Quantity__c}" />

 
I just got back from taking ADM-231 and I am trying to put what i learned in to practices. We have some custom code that I need to edit. I can kind of tell what it says now but still not sure.

I need to edit it so that it does not up date  "CampaignId" unless HasResponded = True in the CampaignMember sObject. 
Any help would be great.
 
trigger Opportunity on Opportunity (after delete, after insert, after undelete, after update, before delete, before insert, before update) {
    if(trigger.isBefore){
        if(trigger.isInsert){
   
           /////////// non bulk trigger
           if(trigger.new.size() > 1){
            return;
           }
           /////////// non bulk trigger
         
           Opportunity o = trigger.new[0];
           System.debug('Akash --> o:' + o);
            System.debug('Akash --> 1:' + o.ECi_Product__c);
           
         
           if((o.Type_of_Sale__c == 'New System' || o.Type_of_Sale__c == 'Aftermarket')){
                
                list<Contact> lstContact = [Select Id From Contact Where AccountId = :o.AccountId ];
               list<Lead> lstLead = [Select Id From Lead Where Id  =: o.Leadid__c ];
               String soql = ' Select Id,CampaignId,Campaign.Type,Response_Tracking_Date__c, Campaign.Type_of_sale__c ';
               soql += ' From CampaignMember ';
               soql += ' Where Campaign.ECi_Product__c = \'' + o.ECi_Product__c + '\' and Campaign.Type_of_sale__c = \''+ o.Type_of_Sale__c+'\'';
               
               System.debug('Akash --> lstContact:' +lstContact);
               System.debug('anuj--> LstLead:' +lstLead);
               /*    
               if(o.Type_of_Sale__c == 'Aftermarket'){
                soql += ' And Campaign.ECi_Aftermarket__c = \'' + o.ECi_Aftermarket__c + '\'';
               }
                */
               soql += ' And Status = \'Responded\'';
               soql += ' And Response_Tracking_Date__c != null';
               soql += ' And ( ContactId In :lstContact OR LeadId In :lstLead )';
               soql += ' Order By Response_Tracking_Date__c Desc';
                
               System.debug('Akash --> soql:' + soql);
               List<CampaignMember> cmList = new List<CampaignMember>();
               cmList = Database.Query(soql);
               if(cmList.size() > 0){
                   for(CampaignMember cm: cmList){
                     
                       System.debug('Akash --> cm:' + cm);
                       System.debug('Akash --> cm.Campaign.Type:' + cm.Campaign.Type);
                         
                       Campaign_Type_Time_Mapping__c cttm = Campaign_Type_Time_Mapping__c.getall().get(cm.Campaign.Type); 
                    
                      
                         
                       if(cttm != null && cttm.Value__c != null){
                         
                           DateTime startDT = DateTime.now(); 
                           DateTime EndDT = DateTime.now();
                             
                           
                             
                           if(cttm.Type__c == 'Year'){
                                startDT = startDT.addYears(-1*Integer.valueOf(cttm.Value__c));
                           }else if(cttm.Type__c == 'Month'){
                                startDT = startDT.addMonths(-1*Integer.valueOf(cttm.Value__c));
                           }else if(cttm.Type__c == 'Day'){
                                startDT = startDT.addDays(-1*Integer.valueOf(cttm.Value__c));
                           }
                             
                           System.debug('Akash --> startDT:' + startDT);
                           System.debug('Akash --> EndDT:' + EndDT);
                            
                           if(cm.Response_Tracking_Date__c >= startDT && cm.Response_Tracking_Date__c <= EndDT){
                                
                               System.debug('Akash --> cm.Response_Tracking_Date__c:' + cm.Response_Tracking_Date__c);
                               System.debug('Akash --> startDT:' + startDT);
                               System.debug('Akash --> EndDT:' + EndDT);
                                    
                               o.CampaignId = cm.CampaignId;
                               System.debug('Akash --> oppor \n' + o);
                               break;
                           }
                       }
                   }
               }else{
                    o.CampaignId = null;
               }    
           }
        }
    }
}

 
Hi,
I am tring to update a custom field on the opportunity object using a custom button.  I was able to create the button but I get an "Unexpected Identifier" error whenever the button is pressed.   I'm new to writing to JavaScipt code, so I'm having some trouble troubleshooting the error.


{!REQUIRESCRIPT("/soap/ajax/29.0/connection.js")}

Var Opp = new sforce.SObject("Opportunity")
Opp.Id = '{!Opportunity.Id}'
Opp.Submit_to_UW__c = 'Yes'

var results = sforce.connection.update([Opp])
window.location.reload()



I am trying to create a pdf from the Lead Object in Salesforce using the Apex language. I am able to create the pdf and attach it to the Current Lead but it does not pull in any of the information from the Lead into the PDF itself.
Page Code:

<apex:page standardController="Lead" renderAs="pdf" showHeader="false"> 
    <apex:stylesheet value="{!$Resource.pdfCss}"/> 
    <apex:panelGrid columns="1" width="100%"> 
      <apex:outputField value="{!Lead.Name}" styleClass="companyName"/> 
      <apex:outputText value="{!NOW()}"></apex:outputText> 
    </apex:panelGrid> 
</apex:page>

Class Code:

public class attachPDFToLead { 
    private final Lead a;
    public attachPDFToLead(ApexPages.StandardController standardPageController) 
       { 
          a = (Lead)standardPageController.getRecord(); 
       } 

public PageReference attachPDF() {
    PageReference pdfPage = Page.PDF; Blob pdfBlob = pdfPage.getContent(); 
    Attachment attach = new Attachment(parentId = a.Id, Name = 'insuranceVerification.pdf', body = pdfBlob); 
    insert attach; 
    PageReference pageURL = new ApexPages.StandardController(a).view(); 
    pageURL.setRedirect(true); return pageURL; 
} 
}
Hi All,

I have Created sample Visual Flow and calling from Custom button. The logic is jsut creating Account Records. And I have a workflow when ever Account is created, updating the field in Account.

So when ever i ran the flow from button after the submitting the flow. I got the above error.
So i deactivated the workflow then the flow works fine. Can any one know why this is happened. Please help me out.

Error :
 
Flow Details
Flow Name: Sample_Account_Create
Type: Flow
Version: 1
Status: Inactive
Flow Interview Details
Interview Label: Sample Account Create 27/7/2016 7:35 PM
Current User: siva kumar (00590000003L0bm)
Start time: 27/7/2016 7:35 PM
Duration: 18 seconds
How the Interview Started
siva kumar (00590000003L0bm) started the flow interview.
SCREEN: Submit_Account_Details
Textbox: Account_Name
Label: Account Name
Value at run time: TestFlowRecord1

Number: Fax
Label: Fax
Value at run time: 554,646

Long Text Area: Description
Label: Description
Value at run time: 

Selected Navigation Button: NEXT
RECORD CREATE: Create_Record
Create one Account record where:
Description = {!Description} ()
Fax = {!Fax} (554,646)
Name = {!Account_Name} (TestFlowRecord1)
Result
Failed to create record.


Regards,
VSK
  • July 27, 2016
  • Like
  • 1
hi Friends in this trigger "Variable does not exist: list at line 53 column 9" error is showing.please help with this. and another thing if i want to fetch the date from createdBy field then what will be the syntax for SOQL & if i want to fetch picklist into a text field then what will be thye soql syntax.



trigger RevenueWithoutST on Revenue__c (after insert, before update) {
    List<SCSCHAMPS__Appointment__c> appList;
    List<Revenue__c> revlist;
    Revenue__c r= new Revenue__c();
    string eCode;
    date salaryDate;
    string category;
    string type;
    for(Revenue__c rev:Trigger.new)
    {
        eCode=rev.ECode__c;
        salaryDate=rev.Salary_Processed_Month__c;
        category=rev.InvoiceCategory__c;
        type=rev.Invoice_Type__c;
        
        if(eCode!=null)
        {
           appList =[select AvvasECode__c,Name_of_the_Candidate__c,Client_Name__c,Date_of_Onboarding__c,
                    Last_Working_Date__c,Location__c from SCSCHAMPS__Appointment__c where AvvasECode__c=: rev.ECode__c] ;
            
            for(SCSCHAMPS__Appointment__c app : appList)
            {
                r.Talent_Name__c= app.Name_of_the_Candidate__c;
                
            }
            
        }
        if(eCode!=null && category=='individual' && salaryDate!=null && type=='Time& Material' )
        {
            List<Invoice__c> InvList;
            Invoice__c inv= new Invoice__c();
            InvList=[select id,Name,Emp_Code__c,Invoice_Category__c,
                     Sub_Total__c from Invoice__c where Emp_Code__c=: rev.ECode__c
                       ];
                FOR(Invoice__c inc : InvList)
                {
                    r.Revenue_Without_ST__c=inc.Sub_Total__c;
                }
                
        }
        else if(eCode!=null && category=='consolidated')
        {
            List<Invoice_Line_Item__c> ILineList;
            Invoice_Line_Item__c iline=new Invoice_Line_Item__c();
            ILineList=[select id,Name,Employee_Code__c,Total__c
                       from Invoice_Line_Item__c where Employee_Code__c=:rev.ECode__c ];
            for(Invoice_Line_Item__c IL : ILineList)
            {
              r.Revenue_Without_ST__c=IL.Total__c;  
            }
        }
        
        list.add(rev);
        
        
    }
    update revlist;

}
I have a picklist field A on contact record. picklist field B on contact opportunity record. They have the same name on both objects. 

When I'm on contact record and I click on new opportunity, I want the info from field A to get copied to field B when I click on "New opportunity" on Contact page.

What's the simplest way of doing this? Any ideas?

Thanks,
Rakshith
Hello Team SFDC,

I have an autolaunched Flow that is fired off as an immediate action of a Process. My flow looks up to a custom objects that mimics contact roles in a sense (my custom object Team Members is a junciton object between a custom object "Team" and the User object). When the flow runs, it looks up the members of a Team, then looks up those Users, then loops through them using a Loop and two Assignment elements. When the loop is done, the last element is a Fast Create that is supposed to create Billings (another custom object) for each of the users on the team. In my sandbox where I am testing, the team has three users. When I do the action in Salesforce that runs my flow, only one Bill is created, not three. I am stumped as to why. Any ideas?
I have followed a progression.

1.  I built Lightning components on the developer console, and the documentation shows.

     In order to keep snapshots of my work as I went, I copied and pasted to emails that I sent to myself. 

2.  I attended Midwest Dreaming, and discovered that my compatriots worked in Sublime and Eclipse, and connected to Salesforce. 

     That would allow me to use git, as I'm used to.  

3.  I tried Sublime 3 with MavensMate.  I got a complaint that TLS 1.0 wasn't supported, only TLS 1.1. 

4.  I looked into using Eclipse with the Force.com IDE.  It's not clear that environment supports building Lightning components conveniently.

5.  I discovered that if you go to salesforce...devcenter/lightning, they talk about a plug-in for Sublime.  Not a MavensMate plug-in.  One made by Salesforce.

So my question is:  Where can I go for reliable, convenient development of Lightning components?
Hi All,
I'm new to salesforce and started working on Trailhead's. I facing issue with the Trigger Challenge. Here is the triger code im writing 

trigger AccountAddressTrigger on Account (before insert) {
    for(Account a : Trigger.new){
        if(a.Match_Billing_Address__c && a.BillingPostalCode != null){
            a.ShippingPostalCode = a.BillingPostalCode;
        }
    }
    
}

but i'm getting the following error. Not sure where i'm doing wrong. can someone please help me here. Thanks in advance.

System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, TestTrigger: execution of AfterInsert caused by: System.NullPointerException: Attempt to de-reference a null object Trigger.TestTrigger: line 3, column 1: []
when we start the lead conversion process will the validation gets execute in backend or not? and why?
Is it possible to run Apex code under a different user than the logged in one?

So someone has logged in and they kick off some Apex code, but I need that specific method to run under an admin user? Is that possible?

Thanks.
Is it enough to prepare for the admin & developer certifcation exam through trailhed ???
Process Builder seems to be causing issues with Test Classes. They have all failed after we have activated a few new processes in Process Builder. When deactivating the processes and resorting to workflow rules, the test classes do not fail.
Hi Salesforce folks,

I have updated blank value for the Email field in contact in salesforce, now i want to roll back the email values, please can any one suggest to get the correct data.

Checked with slaesforce, its very expensive. 

Please let us know if any of you can retrive the data from  salesforce.

Please contact for the given number :+91 9686987233

Thanks in advance .
Seriously, code coverage will be the death of me! This test is not returning any coverage and I can't figure out why. Any suggestions?

Here's the trigger. It's supposed so transfer two dates from the relationship field Opportunity__c on the contract when the contract record is updated. However in the developer console the code coverage is 0%.
 
trigger TransferOpportunityValue on Contract (before update) { 
     
    for(Contract c : Trigger.new){

        if(c.Opportunity__c != null){

        	Opportunity o = [Select id,Pay_History_Received__c,Pay_History_Reviewed__c From Opportunity Where Id = :c.Opportunity__c];
			c.Pay_History_Received__c = o.Pay_History_Received__c;
			c.Pay_History_Reviewed__c = o.Pay_History_Reviewed__c;
            
        }

    }

}

The test class is here, I'm updating the field price_level__c, but to no avail the coverage is still 0% and there are definitely activated contracts. Anyone have any idea why? You help is much appreciated.
 
@isTest

private class TestUpdateContract {
    
    static testMethod void myTest() {

        Contract con; 
        con= [SELECT Id,price_level__c FROM Contract LIMIT 1];
         
        con.price_level__c = '12345';
        update con;           
        
    }

}


 
Sharing this in case anyone else needs it.  Here is a formula field for clean company name. 
TRIM(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(Company, 
",", " ") /*remove commas*/,
".", " ") /*remove periods*/,
" inc", "") /*remove inc*/,
" Inc", "") /*remove Inc*/,
" INC", "") /*remove INC*/,
" llc", "") /*remove llc*/,
" Llc", "") /*remove Llc*/,
" LLC", "") /*remove LLC*/,
" Ltd", "") /*remove Ltd*/,
" LTD", "") /*remove LTD*/,
"Corporation", "") /*remove Corporation*/
)

If you have an improved version please post :)

When someone takes the time/effort to repspond to your question, you should take the time/effort to either mark the question as "Solved", or post a Follow-Up with addtional information.  

 

That way people with a similar question can find the Solution without having to re-post the same question again and again. And the people who reply to your post know that the issue has been resolved and they can stop working on it.