• justin_sfdc
  • NEWBIE
  • 282 Points
  • Member since 2013

  • Chatter
    Feed
  • 7
    Best Answers
  • 3
    Likes Received
  • 2
    Likes Given
  • 17
    Questions
  • 116
    Replies
I am unable to resolve my test class. Before including trigger.oldmap it was 80% coverage. Now it is 0%. Any suggestions could be helpful for me.

Thank you.

Trigger:
trigger populateOpportunityfromContact on Opportunity (before insert , before update)
{
    
    Set<ID> ConIds = new Set<ID>();

    for(Opportunity opp : trigger.new)
    {
          ConIds.add(opp.RSM_Shipping_Contact__c);    
    }

    list <contact> conlist = [SELECT Email,Id,MailingCity,MailingCountry,MailingPostalCode,MailingState,MailingStreet,Phone FROM Contact where id IN:ConIds];

     MAP<ID , contact> mapCon = new MAP<ID , Contact>();
     for(Contact c : conlist)
     {
        mapcon.put(c.id,c);
     }

     for(Opportunity opp : trigger.new)
     {
      if(trigger.oldmap.get(opp.Id).RSM_Shipping_Contact__c != opp.RSM_Shipping_Contact__c)
      {

        if(opp.RSM_Shipping_Contact__c!=null)
        {
        if(mapcon.containskey(opp.RSM_Shipping_Contact__c))
        {
          contact c = mapcon.get(opp.RSM_Shipping_Contact__c);
          opp.Shipping_Street__c = c.MailingStreet;
          opp.Shipping_City__c = c.MailingCity;
          opp.Shipping_State__c = c.MailingState;
          opp.Shipping_Country__c= c.MailingCountry;
          opp.Shipping_postal_code__c = c.MailingPostalCode;
          opp.Shipping_Email__c = c.Email;
          opp.Shipping_Phone__c = c.phone;
        }
       
        }
        
        else
        {
            
          opp.Shipping_Street__c = null;
          opp.Shipping_City__c = null;
          opp.Shipping_State__c = null;
          opp.Shipping_Country__c= null;
          opp.Shipping_postal_code__c = null;
          opp.Shipping_Email__c = null;
          opp.Shipping_Phone__c = null;
            
        }
       
     }
    }
        
}

Test Class:
 
@istest

public class populateOpportunityfromContactTestclass
{
     @testSetup static void setup() 
      {
                
        contact c = new contact();
        c.lastname = 'Gopi Jayaram';
        c.mailingstreet = '1409 Roper Mountain Road';
        c.mailingcity = 'Greenville';
        c.mailingstate = 'South Carolina';
        c.mailingcountry = 'United State of America';
        c.mailingpostalcode = '29615';
        c.email = 'gopijayaram@gmail.com';
        c.phone = '4053786543';
        insert c;
        
        
        opportunity o = new opportunity();
        o.name = 'Gopi Jayaram ATT';
        o.RSM_Shipping_Contact__c = c.id;
        o.stagename = 'prospecting';
        o.closedate = Date.today();
        insert o;

     }
     
     Static testMethod void insertItemNull()
     {
         Opportunity op = [Select id, name,Shipping_Street__c from opportunity where name = 'Gopi Jayaram ATT' ];
        // contact ct = [Select id,email,phone,mailingstreet,mailingcity,mailingstate,mailingcountry,mailingpostalcode from contact where name = 'Gopi Jayaram' ];
         System.assertnotequals(op.Shipping_Street__c,null);
     } 
      Static testMethod void insertItem()
     {
         Opportunity op = [Select id, name,Shipping_Street__c from opportunity where name = 'Gopi Jayaram ATT' ];
        contact ct = [Select id,email,phone,mailingstreet,mailingcity,mailingstate,mailingcountry,mailingpostalcode from contact where name = 'Gopi Jayaram' ];
         System.assertequals(op.Shipping_Street__c,ct.mailingstreet);
     } 
     
}

 
How to Schedule a batch Apex using system.schdule with code not through UI and where to write it ,
Below is my sample code:

public class BatchLeadDelete implements database.Batchable<sobject>
{
    list<lead> llist=new list<lead>();
    public string query='select id,name,Phone from lead';
    public string flag='12345';
    
    public database.querylocator start(database.BatchableContext bc){
       return database.getQueryLocator(query); 
  }
    public void execute(database.BatchableContext bc,list<lead> le){
        for(lead l:le){
            if(l.Phone==flag)
            {
                llist.add(l);
            }
                
        }

      delete llist;             
    }
    public void finish(database.BatchableContext bc){
        
    }
 }

I called the above class with below code

BatchLeadDelete l=new BatchLeadDelete();
    database.executeBatch(l,50); 
While i am trying to create record using report buiilderf and save with the name it shows me error like this in the Screen shot but by mistake i created same named record earlier but not able to find that earlier created report.

User-added image
Please telll me how i find previous report that  I created  earlier on Opportunity object and how should i edit that?

Thanks in advance.
Hi Experts,

Am trying to call a method into VF, but am getting the below error
User-added image


here is my class

Public class RBGeneratorController{
List<account> selectacct;


Public List<account> getAllAccounts()
{
    List<account> allaccts = [Select ID,Name, Industry, Type, Billingstreet from Account limit 5];
   return allaccts;
}    


Public void selectacct()
{
    String selaccountid = System.currentPagereference().getParameters().get('accid');
    Account acc = [Select ID,Name, Industry, Type, Billingstreet from Account where Id=:selaccountid];
    selectacct =  new List<account>();
    selectacct.add(acc);
}
//Public List<account> getselectedAccount()
//{
 //   return selectacct;
//}
}


here is VF page


<apex:page>
<apex:form>
<apex:pageblock id="PB" title="Available Generators">
               <apex:pageblocktable id="PBT" value="{!AllAccounts}" var="allaccts">
                    <apex:column headervalue="Generatos">                    
                       <apex:actionsupport action="{!selectacct}" event="onclick" rerender="allcons">  
                        <input type="radio" />                    
                            <apex:param name="accid" value="{!allcon.Id}">
                        </apex:param></apex:actionsupport>                            
                    </apex:column>    
                    <apex:column headervalue="Name">
                        <apex:outputfield value="{!allcon.Name}">
                    </apex:outputfield></apex:column> 
                    <apex:column headervalue="Industry">
                        <apex:outputfield value="{!allcon.Industry}">
                    </apex:outputfield></apex:column>  
                    <apex:column headervalue="Type">
                        <apex:outputfield value="{!allcon.Type}">
                    </apex:outputfield></apex:column>  
                    <apex:column headervalue="BillingStreet">
                        <apex:outputfield value="{!allcon.Billingstreet}">
                    </apex:outputfield></apex:column>  
                </apex:pageblocktable>
</apex:pageblock>

</apex:form>

</apex:page>

please help me through this

Thank you
Hi everyone,
I am currently designing a vf page where I am using html input tag but I am not sure how to pull that value into the controller. If I use <apex:inputText> component it works but I want to use html input tag in the vf page rather. Below is a simple example of what I want to do. If there is a textbox and a button then how do I retrieve that value in a controller when the button is clicked.

VF Page:
<input type="text" name = "name"/>
<input type= "submit" value = "submit"/>

Controller:
public string name {get; set;}

public void submit() {
   System.debug('The value entered for name is: '+ name);
}

Any help is appreciated.

Thanks!
Currently we have Opportunity Approval Process - when a opportunity record is submitted for approval- the approval goes to several approvers depending on the criteria listed in each step. If one BU “approves” one part of the deal and the other BU “rejects” other part, the entire deal would be "rejected”. Either the deal would have to be modified and “approved” by both Business Units, or the deal would be considered ‘dead’.

Each Business Unit is responsible for a different line of business(s). An opportunity can have mulitple lines of business. With the way the Approval Process is set up, we run the risk with the apporval request never getting to one of the Business Units. 

We want to split the approval process into two separate Approval Process. When the opportunity is submitted for approval. Two Approval Process are fired off at the same time. Is this possible?
Hi All,

I have to compare new and old values for few fields of a object.How can it be done using custom settings and used in apex class?
Can you help me few line of codes?
Thanks for helping
 
sir, i am using list program.  This is a apex class program.  here i am getting all the colors vales at VF page. VF page and Apex page is working well.  here my doubt is how can i use this apex program without constructor.  please help. thanks in advance. 
 
public class listcolor
{
public list<string> color{set;get;}

public listcolor()
{
color=new list<string>{'red','white','green'};

list<string> myval=new list<string>();
myval.addall(color);

}
}

I tried this, but it is giving error. 
 
public class listcolor
{
public list<string> color{set;get;}

mycolors();


public void mycolors()
{
color=new list<string>{'red','white','green'};

list<string> myval=new list<string>();
myval.addall(color);

}
}

OR OR OR OR OR OR OR OR OR OR OR OR OR OR OR OR OR OR 





public class listcolor
{
public list<string> color{set;get;}

public list<string>  mycolors()
{
color=new list<string>{'red','white','green'};

list<string> myval=new list<string>();
myval.addall(color);

return color;

}
}

Vf page ( for your reference):- 
 
<apex:page controller="listcolor" title="list of colors">
<apex:form>
<apex:pageblock>

<apex:pageblocktable var="a" value="{!color}">
<apex:column headervalue="colors" value="{!a}" />

</apex:pageblocktable>
</apex:pageblock>


</apex:form>
</apex:page>

 
Hi,
I designed one webpage. I want to get the data from the web page and i want to store in one custom object. How many ways we can do it?
 I have a custom lookup filed Asset__c  at custom object Service_Report__c.  Service_Report__c is a child object of standard case object i.e. case is parent of Service_Report__c
Now I want to write a apex trigger to update InstallDate and Site__c fields at asset when Asset__c!=null, when I create and update record at custom object  Service_Report__c.
 InstallDate(asset) = Date_of_Site_Visit_To__c(custom lookup field at Service_Report__c)
 Site__c(custom lookup field at asset) =  Site__c(custom lookup field at case)
 Asset object fields: InstallDate(Standard field),  Site__c(lookup)
 Service_Report__c  object fields: Case__c(lookup), Asset__c(lookup), Date_of_Site_Visit_To__c(date field)
 Case object fields: Site__c(lookup)
Could any one help in how to deploy .object files in salesforce
I have tried this code for custom button for single click email sending. Unfortunately It is not working and showing error. Could anyone tell me where I am doing wrong and correct me please.

Thank you.
location.replace('/email/author/emailauthor.jsp retURL=/{!Opportunity.Id}&p24="varunreddypenna@gmail.com,v.reddy@thegordiangroup.com"&template_id="00Xj0000000J8sI"&p3_lkid={!Opportunity.Id}&p3={!Opportunity.Name}&p26={!User.Email}&p5="penna.janareddy@gmail.com"&save=0')
User-added image
User-added image

 
Hi,

I would like to have a validation rule when a opportunity have product added that proposal got to have contact as well.
We have a pick list field in Account object. Values of the picklist are X and Y. Now I would like to hide or restrict access to records which have picklist value as X for certain profile called Operations. So this profile users should be able to see only records with picklist value Y but not X.

I have tried different ways but could not get it. Any insights could be helpful.

Thank you.
how to pass value from vf page to controller ??