• Prabu Mahalingam
  • NEWBIE
  • 75 Points
  • Member since 2014
  • SalesForce Developer
  • Edutise


  • Chatter
    Feed
  • 3
    Best Answers
  • 0
    Likes Received
  • 5
    Likes Given
  • 1
    Questions
  • 33
    Replies
I'm actually trying to get the assets from the map based on account ID and loop through the values to get the Product_Family__c.

Map<ID,Asset>actAstMap=new Map<ID,Asset>();
for (Asset a1: actAstMap.get(ActID)){
if(a1.Product_Family__c!=null ||a1.Product_Family__c<>''){
        pFamily.add(a1.Product_Family__c);
}
}

Any help will be much apprecitated.
I've only been able to get 72% code coverage for my apex class. I'm new to apex development. Can someone help me please?

Here is my class:

public class PcPContactInfo {
    public Precall_Plan_2__c c{get; set;}
   
    public PcPContactInfo(ApexPages.StandardController controller)
        {
             c = (Precall_Plan_2__c)controller.getRecord();
        }
   
    public pagereference logout()
        {  
             pagereference p1=new pagereference('/apex/Precall_Plan_Detail_clone?id='+c.get('Id')+'&clone=1');
             return p1;
        }
   
   
    public PageReference dosave()
        {   
             try
            {
                 if(ApexPages.currentPage().getParameters().get('clone')=='1'||ApexPages.currentPage().getParameters().get('save_new')=='1')
                    {
                        c.id=null;                   
                        insert c;
                    }
               
                 else
                        update c;
            }
       
                 catch(exception e) { ApexPages.addMessages(e); return null;  } 

                 return new Pagereference('/' + c.get('Id'));
        }
    
    public void doSomething()
        {
           contact TEST = [SELECT account.name,MailingCountry,Mailingcity,Title,Phone,MailingStreet,MailingState,MailingPostalCode, accountid FROM contact where id = :c.Contact_name2__c];
           // c.Company_Name__c= TEST.account.name;
           c.Contact_mailing_city__c=TEST.Mailingcity;
           c.Contact_s_Title__c=TEST.Title;
           c.Contact_s_Telephone_Number__c=TEST.Phone;
           c.Contact_Street__c=TEST.MailingStreet;
           c.Contact_State__c=TEST.MailingState;
           c.Contact_Zip__c=TEST.MailingPostalCode;
     
        }
}

And here is my Test Class:

@isTest
private class test_PcPContactInfo
{

    static testMethod void go_PcPContactInfo() 
    {
   
        account a = new account(name='ESAB');
        insert a;
        contact c = new contact (lastname= 'test2',accountid=a.id,email='abc@gmail.com');
        insert c;
       
        Precall_Plan_2__c  cw=new Precall_Plan_2__c(name='test',Contact_name2__c=c.id,Company_Name__c=a.id);
        insert cw;
       
        ApexPages.StandardController controller = new ApexPages.StandardController(cw);
        PcPContactInfo stdController = new PcPContactInfo(controller);
        //account a = [SELECT name,id FROM account limit 1];
       
        //contact TEST = [SELECT id, accountid,email FROM contact where id = :cw.contact__c];
        //cw.Email__c = TEST.email;
        //update cw;
       
        stdController.doSomething();
        stdController.dosave();
       
       
    }
}
Hi. A friend helped me develop a trigger for when an activity with the subject File Forms from Recruit in EE Folder is changed to the status of completed it updates the opportunity stage to Day 1 Complete. 

But I am getting an error and I can't figure out why. Error: Compile Error: Variable does not exist: trigger at line 4 column 18

Any help is appreciated. 

Here is the code:

trigger updateStatus on Task (after insert, after update){
    List<Id> oppy_ids = new List<Id>();
    List<Opportunity> update_oppys = new List<Opportunity>();
    for(Task t : trigger.new()){
        //when subject is this, the opp should be start 10 day cycle
        if(t.Subject == 'File Forms from Recruit in EE Folder' && t.Status == 'Completed' && t.WhatId != null && String.valueOf(t.WhatId).startsWith('006')){
            oppy_ids.add(t.WhatId);
        }
    }

    for(Opportunity o : [SELECT StageName FROM Opportunity WHERE ID IN :oppy_ids]){
        // or whatever you need the stage  name to be
        o.StageName = 'Day 1 Complete';
        //add the opportunity to a list for dml
        update_oppys.add(o);
    }

    if(!update_oppys.isEmpty()){
        update update_oppys;
    }
}
Hi Everybody,
I have a requirement to create an e-commerce on salesforce using Sites. I am not sure what license can I to assign for logged in customers. I went through the salesforce license types and I am confused choosing between Communities License  and  Authenticated Website User Licenses.
The following are the key points
  • Site must allow large number of users to sign up.
  • Logged in users will access Custom Objects and some standard objects.
Please provide me suggestions on choosing the license types that will suit e-commerce functionalities.

 
Getting error to open preview with Vfpage for Pdf Attachment in Email.

VFPage
 
<apex:page controller="cESend" >
<apex:pageBlock title="Send email example to the related conatct email of the Account:{!acc.Name}">
<p> This is the example of the vfpage</p>  
    <h1>Related Contacts for the Account:{!acc.Name}</h1>
 <apex:pageBlockTable value="{!acc.Contacts}" var="c">
        <apex:column headerValue="Name">{!c.Name}</apex:column>
        <apex:column headerValue="Email">{!c.Email}</apex:column>
    </apex:pageBlockTable> <br/><br/>
    <apex:form>
        <apex:outputLabel for="Subject" value="Subject">:<br/></apex:outputLabel>
            <apex:inputText size="80" maxlength="80" id="Subject" value="{!eSubject}" />:<br/><br/>
        <apex:outputLabel for="Body" value="Body">:<br/></apex:outputLabel>
        <apex:inputTextarea id="Body" cols="80" rows="8" value="{!eBody}"/><br/><br/>
        <apex:commandButton value="Send" action="{!SendEmail}" title="Send Email"/>
      </apex:form>
    </apex:pageBlock>    
  </apex:page>

Apex
public class cESend {
    public PageReference SendEmail(){
    Messaging.SingleEmailMessage email=new Messaging.SingleEmailMessage();
    pageReference pdfExample=Page.PDFGEN;
    pdfExample.setRedirect(true);
        
     Blob b=pdfExample.getContent();
        
    Messaging.EmailFileAttachment fa=new Messaging.EmailFileAttachment();
    fa.setFileName('AttachmentEmailFile.pdf');
        fa.setBody(b);
        
    String eAddress;
        if(acc.Contacts[0].email!=null){
            eAddress=acc.Contacts[0].email;
            for(Integer i=1;i<acc.Contacts.size();i++){
                
                if(acc.Contacts[i].email!=null){
                    eAddress =acc.Contacts[i].email;
                }
            }
            }
    string[] toAddress=eAddress.split(':',0);
    email.setSubject(eSubject);
    email.setPlainTextBody(eBody);
    email.setToAddresses(toAddress);
    email.setFileAttachments(new Messaging.EmailFileAttachment[] {fa});
      //Now sending th email;
        Messaging.SendEmailResult[] r=Messaging.sendEmail(new Messaging.SingleEmailMessage[] {email});
        return null;
    }
    public Account acc{get;set;} 
    public string eSubject{get;set;} 
       public string eBody {get;set;} 
    
    
    public cEsend(){
    acc=[SELECT Name,(Select Name, Id,Email from Account.Contacts)from Account Where Id=:ApexPages.currentPage().getParameters().get('Id')];
        eSubject='';
        eBody='';
    }
                  }

Error

User-added image



 
  • April 27, 2021
  • Like
  • 0
I'm not sure what I'm missing so that when the onchange event happens on the picklist values, my searchResults is not updating to show only the records with that value.

Right now, when I select a different product family from the list, nothing happens to the products displayed.

Any help would be apprecidated!!

Here is my visualforce page section:
<apex:selectList value="{!products.Family}" size="1" id="Families">
                    <apex:actionSupport event="onchange" action="{!updateAvailableList}" reRender="searchResults" />
                    <apex:selectOptions value="{!Families}"/>     
                </apex:selectList>

Here is the update available list function:
 
public void updateAvailableList() {
        
        String qString = 'select Id, Pricebook2Id, IsActive, Product2.Name, Product2.Family, Product2.IsActive, Product2.Description, UnitPrice from PricebookEntry where IsActive=true and Pricebook2Id = \'' + theBook.Id + '\'';
             
        if(searchString!=null){
            qString+= ' and (Product2.Name like \'%' + searchString + '%\' or Product2.ProductCode like \'%' + searchString + '%\')';      
        }

This is how I'm getting my product family list:
 
public List<SelectOption> getFamilies()
    {
        List<SelectOption> options = new List<SelectOption>();
        
        Schema.DescribeFieldResult fieldResult =
            Product2.Family.getDescribe();
        List<Schema.PicklistEntry> ple = fieldResult.getPicklistValues();
        
        for( Schema.PicklistEntry f : ple)
        {
            options.add(new SelectOption(f.getLabel(), f.getValue()));
        }       
        return options;
    }

 
Hi, Everyone,

I'm looking for a plug-in for outlook and gmail that will sync events created in gmail or outlook on to the saelsforce calendar. in addition i am looking for something that will intelegently relate to and/or populate name of account and contact on the event from gmail or outlook. I know Einstein Activity Capture has the capactity as far as the AI to intelegently link these events with existing accounts or contacts. Thoughts??
Hi Everybody,
I have a requirement to create an e-commerce on salesforce using Sites. I am not sure what license can I to assign for logged in customers. I went through the salesforce license types and I am confused choosing between Communities License  and  Authenticated Website User Licenses.
The following are the key points
  • Site must allow large number of users to sign up.
  • Logged in users will access Custom Objects and some standard objects.
Please provide me suggestions on choosing the license types that will suit e-commerce functionalities.

 
In our CRM, we have multiple organizations (Accounts object) with exact same names that are located in different locations; so those duplicate names are legitimate. Now the problem is, we found that if we click “New Contact” from an Account that shares a name with another account, it may NOT assign it to the correct one.

So basically if the account name is a duplicate, SalesForce is showing a drop-down for account names rather than using the account where you clicked “New Contact” from. Then it is sorting the dropdown by some other columns so the selection (if you don’t change it) may not be the account we want.

Salesforce is supposed to use the account ids (instead of the text based names) to work correctly in our case. How can we fix the issue please?

Thank you very much in advance
In my last for loop (last 4-5 lines of code that I post here) I get a cannot de-reference null object error when I try to insert an AHU record into the database.  I've gone over the code a couple of times, and can't figure out what object I don't instantiate. 


trigger updateGatewayCounts on AHU__c (after update, after delete, after insert) {
AHU__c editedAHU = new AHU__c();
if (Trigger.isDelete) {editedAHU = trigger.old[0];}
else {editedAHU = trigger.new[0];}

Map<Control_Gateway__c, Integer[]> cggwCounts = new Map<Control_Gateway__c, Integer[]>();
List<AHU__c> project_AHUs = [SELECT AHU_Project__c, AHU_Site__c, Name, AHU_Control_Group__c
        FROM AHU__c
        WHERE AHU_Project__c = :editedAHU.AHU_Project__c
        ORDER BY Name];
for (AHU__c ahu: project_AHUs) {
  List<AHU_Point__c> points = [SELECT AHU_Point_Source__c, AHU_Point_Type__c, AHU_Point_Gateway__c FROM AHU_Point__c WHERE AHU_Point_AHU__c =: ahu.Id];
  if (points.size() > 0) {
   Map<String, AHU_Point__c[]> sensorMap = new Map<String, AHU_Point__c[]>();
   for (AHU_Point__c point: points) {
    AHU_Point__c[] sensorList = sensorMap.get(point.AHU_Point_Source__c);
    if (sensorList == null) {sensorList = new List<AHU_Point__c>();}
    sensorList.add(point);
    sensorMap.put(point.AHU_Point_Source__c, sensorList);
   }

   for (AHU_Point__c[] hwList: sensorMap.values()) {
    Integer temperature = 0;
    Integer voltage = 0;
    Integer int_temp = 0;
    Integer other = 0;
    String gw = '';
    String source = '';
    for (AHU_Point__c point: hwList) {
     List<Point__c> port = [SELECT Point_Port__c FROM Point__c WHERE Point_Name__c =: point.AHU_Point_Type__c];
     if (port.size() > 0) {
      if (port[0].Point_Port__c == 'Temperature') {temperature += 1;}
      else if (port[0].Point_Port__c == 'Voltage') {voltage += 1;}
      else if (port[0].Point_Port__c == 'Internal Temperature') {int_temp += 1;}
     }
     else {other += 1;}
     gw = point.AHU_Point_Gateway__c;
     source = point.AHU_Point_Source__c;
    }
    List<Control_Gateway__c> cggw = [SELECT CGGW_WAM_Count__c, CGGW_WSM_AHU_Count__c, CGGW_WSM_Power_Count__c
            FROM Control_Gateway__c
            WHERE CGGW_Project__c = :editedAHU.AHU_Project__c AND CGGW_Gateway__c = :gw AND CGGW_Control_Group__c = :ahu.AHU_Control_Group__c];
    Integer[] counts = cggwCounts.get(cggw[0]);
    if (counts == null) {counts = new List<Integer>();counts.add(0);counts.add(0);counts.add(0);}
    if (source == 'WAM') {counts.set(0, counts.get(0)+1);}
    else if (source != 'BACnet') {if (voltage > 0) {counts.set(1, counts.get(1)+1);} else {counts.set(2, counts.get(2)+1);}}
    cggwCounts.put(cggw[0], counts);
   }
  }
}
for (Control_Gateway__c cggw: cggwCounts.keySet()) {
  cggw.CGGW_WAM_Count__c = cggwCounts.get(cggw).get(0);
  cggw.CGGW_WSM_Power_Count__c = cggwCounts.get(cggw).get(1);
  cggw.CGGW_WSM_AHU_Count__c = cggwCounts.get(cggw).get(2);
  upsert(cggw);
}
}
Hello! I have this error when running tests. 

System.QueryException: List has no rows for assignment to SObject
Class.FastSubmitAssetsClassTest.AdditionalTesting: line 43, column 1

Code Sample :

@isTest(SeeAllData=true)
Public Class FastSubmitAssetsClassTest{


    //
    @IsTest Public Static Void SubmitSigleCaseTest(){
        FastSubmitAssetsClass FsA=new FastSubmitAssetsClass();
        FsA.SelectedId=FsA.assetContainers.get(0).cases.get(0).kase.id;           
        system.assertNotEquals(NULL,FsA.SubmitForApproval());
        
        PageReference submitPage=Page.FastSubmitAssetsPage;
        Test.setCurrentPageReference(submitPage);        
        ApexPages.CurrentPage().getParameters().put('assetId',FsA.assetContainers.get(0).asset.id);
        system.assertNotEquals(NULL,FsA.SubmitForApproval());
        
        //Action page testing
        PageReference actionPage=Page.FastSubmitActionPage;
        Test.setCurrentPageReference(actionPage);
        ApexPages.CurrentPage().getParameters().put('id',FsA.SelectedId);
        FastSubmitActionClass action=new FastSubmitActionClass();
        system.assertEquals(NULL,action.yes());
        system.assertNotEquals(NULL,action.no());
        
    }
    @IsTest Public Static Void SubmitMultipleCaseTest(){
        FastSubmitAssetsClass FsA=new FastSubmitAssetsClass();
        FastSubmitAssetsClass.CaseContainer cc=FsA.assetContainers.get(0).cases.get(0);
        cc.isSelected=true;           
        system.assertNotEquals(NULL,FsA.SubmitSelected());
        
        //Action page testing
        PageReference actionPage=Page.FastSubmitActionMultiplePage ;
        Test.setCurrentPageReference(actionPage);
        ApexPages.CurrentPage().getParameters().put('allids',cc.Kase.id);
        FastSubmitActionClass action=new FastSubmitActionClass();
        system.assertNotEquals(NULL,action.YesMulti());
        system.assertNotEquals(NULL,action.NoMulti());
        
        
    }
    //Product_udpate and OpportunityLine Item testing 
    @IsTest Public static void AdditionalTesting(){
        Product2 prod=[Select Id,Name from Product2 LIMIT 1];
        prod.Name='Name Changing';
        update prod;
        
        OpportunityLineItem oli=[SELECT id,PriceBookEntryId 
                                 FROM OpportunityLineItem LIMIT 1];
        UPDATE Oli;
        
    
    }

}



Hi,

I have tried to implement the simple operations such as Add, Subtract, Multiply and Divide through callouts. So my page has 4 buttons. 

But only the first button click works fine and gives me the result. When i try to fire another event, it doesn't work. Below are my controller and Visualforce page. 

Please help !!

Controller:

public class CalculatorController{
    public double a;
    public double b;
    public double c;
    public final wwwParasoftComWsdlCalculator.ICalculator calculator;
   
    public CalculatorController(){
        calculator = new wwwParasoftComWsdlCalculator.ICalculator();
    }
    public double getA(){
        return a;
    }
   
    public void setA(double number1){
        a = number1;
    }
   
    public double getB(){
        return b;
    }
   
    public void setB(double number2){
        b = number2;
    }
   
    public double getC(){
        return c;
    }
   
    public void setC(double number2){
        c = number2;
    }
   
    public void Add(){
        System.debug(a);
        System.debug(b);
       
      c = calculator.add(a,b);       
    }
   
    public void Subtract(){
        System.debug(a);
        System.debug(b);
       
      c = calculator.subtract(a,b);       
    }
   
    public void Divide(){
        System.debug(a);
        System.debug(b);
       
      c = calculator.divide(a,b);       
    }
   
    public void Multiply(){
        System.debug(a);
        System.debug(b);
       
      c = calculator.multiply(a,b);       
    }
}
Visualforce page:

<apex:page controller="CalculatorController" sidebar="false">
    <apex:form >
        <apex:pageBlock title="Calculator">
            <apex:pageBlockSection title="Inputs" collapsible="false">
                <apex:inputText label="Number 1" value="{!a}" title="Number 1"/>
                <apex:inputText label="Number 2" value="{!b}" title="Number 2"/>
            </apex:pageBlockSection>
            <apex:pageBlockSection title="Result" columns="1" collapsible="false">
                <apex:inputText label="Result" value="{!c}" title="Result" disabled="true"/>
            </apex:pageBlockSection>
            <apex:pageBlockButtons location="bottom">
                <apex:commandButton action="{!Add}" value="Add"/>
                <apex:commandButton action="{!Subtract}" value="Subtract"/>
                <apex:commandButton action="{!Multiply}" value="Multiply"/>
                <apex:commandButton action="{!Divide}" value="Divide"/>
            </apex:pageBlockButtons>
        </apex:pageBlock>
    </apex:form>
</apex:page>
Hi  I'm Trying  deploy this trigger but it is showing exception can any one will help in this
Trigger

  1. trigger convertNumbersToWords on Transaction__c(before update) {
  2.     String[] units=new String[]{'',' One',' Two',' Three',' Four',' Five',' Six',' Seven',' Eight',' Nine'};
  3.     String[] teen=new String[]{' Ten',' Eleven',' Twelve',' Thirteen',' Fourteen',' Fifteen',' Sixteen',' Seventeen',' Eighteen',' Nineteen'};
  4.     String[] tens=new String[]{' Twenty',' Thirty',' Fourty',' Fifty',' Sixty',' Seventy',' Eighty',' Ninety'};
  5.     String[] maxs=new String[]{'','',' Hundred',' Thousand',' Lakh',' Crore'};
  6.     For(Transaction__c T : trigger.new){
  7.     if(t.Net_Supplementary_Amount__c >0){
  8.       t.Net_Suppl_Interset_words__c =convert(integer.valueof(t.Net_Supplementary_Amount__c)) ;}
  9.        else{
  10.               t.Net_Suppl_Interset_words__c=' ';
  11.           }  
  12.       
  13.        t.Net_Supplementary_Brokerage_in_words__c =convert(integer.valueof(t.Net_Suppl_Brokerage__c)) ;
  14.        t.Net_Interest_till_31st_March_in_words__c =convert(integer.valueof(t.Interest_pre_31_Mar__c));
  15.        t.Net_Interest_post_31st_March_in_words__c =convert(integer.valueof(t.Intrst_post_31_Mar__c));
  16.        t.Net_Brokerage_Amt_in_Words__c =convert(integer.valueof(t.Net_Brokerage_INR__c));
  17.       
  18.     }
  19.   
  20.    
  21.     public string digitsToWord(string val){
  22.         String Convertedtext='';
  23.         list<string> Vallist=val.split('');
  24.                 string sss=Vallist.remove(0);
  25.         for(integer i=Vallist.size()-1;i>=0;i--){
  26.             integer index=integer.valueof(Vallist[i]);
  27.             if(i==0&&index>1&&Vallist.size()>1)
  28.                  Convertedtext=tens[index-2]+Convertedtext;
  29.             else if(i==0&&index==1&&Vallist.size()==2){
  30.                 integer sum=0;
  31.                 for(integer j=0;j<2;j++){
  32.                      sum=(sum*10)+integer.valueof(Vallist[j]);
  33.                 }
  34.                 return teen[sum-10]; 
  35.             }
  36.             else{
  37.                
  38.                  if(index>0)
  39.                      Convertedtext=units[index]+Convertedtext;
  40.             }
  41.         }
  42.         return Convertedtext;
  43.     }
  44.    
  45.    public String convert(integer n) {
  46.        if(n==0)
  47.            return 'Zero';
  48.         if(n>999999999)
  49.             return 'More then 100 corers ';
  50.        string amount=string.valueOf(n);
  51.       
  52.        integer positioning=1;
  53.        boolean IsHundred=false;
  54.        string Convertedtext='';
  55.        while(amount.length()>0){
  56.            if(positioning==1){
  57.                if(amount.length()>=2){
  58.                    String C=amount.substring(amount.length()-2,amount.length());
  59.                    amount=amount.substring(0,amount.length()-2);
  60.                    Convertedtext+=digitsToWord(C);
  61.                } else if(amount.length()==1){
  62.                     Convertedtext+=digitsToWord(amount);
  63.                     amount='';
  64.                }positioning++;
  65.            }
  66.            else if(positioning==2){
  67.                String C=amount.substring(amount.length()-1,amount.length());
  68.                amount=amount.substring(0,amount.length()-1);
  69.                if(Convertedtext.length()>0&&digitsToWord(C)!=''){
  70.                    Convertedtext=(digitsToWord(C)+maxs[positioning]+' and')+Convertedtext;
  71.                    IsHundred=true;
  72.                }
  73.                else{
  74.                    if(digitsToWord(C)!='')
  75.                      Convertedtext=(digitsToWord(C)+maxs[positioning])+Convertedtext;IsHundred=true;
  76.                }
  77.                positioning++;
  78.            }
  79.            else if(positioning>2){
  80.                if(amount.length()>=2){
  81.                    String C=amount.substring(amount.length()-2,amount.length()); amount=amount.substring(0,amount.length()-2);
  82.                    if(!IsHundred&&Convertedtext.length()>0)
  83.                        Convertedtext=digitsToWord(C)+maxs[positioning]+' and'+Convertedtext;
  84.                    else{ if(digitsToWord(C)=='') {} else Convertedtext=digitsToWord(C)+maxs[positioning]+Convertedtext; }
  85.                } else if(amount.length()==1){
  86.                    if(!IsHundred&&Convertedtext.length()>0)
  87.                        Convertedtext=digitsToWord(amount)+maxs[positioning]+' and'+Convertedtext; 
  88.                    else{ if(digitsToWord(amount)==''){}else Convertedtext=digitsToWord(amount)+maxs[positioning]+Convertedtext;   amount='';  }
  89.                   
  90.                }
  91.                 positioning++;
  92.            }
  93.         }
  94.       
  95.    return Convertedtext;
  96.    }
  97.    
  98. }
  99.  
  100.  
  101.  
  102.  

Failure Message: "System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, convertNumbersToWords: execution of BeforeUpdate caused by: System.NullPointerException: Attempt to de-reference a null object Trigger.convertNumbersToWords: line 55, column 1 Trigger.convertNumber...
 
I'm actually trying to get the assets from the map based on account ID and loop through the values to get the Product_Family__c.

Map<ID,Asset>actAstMap=new Map<ID,Asset>();
for (Asset a1: actAstMap.get(ActID)){
if(a1.Product_Family__c!=null ||a1.Product_Family__c<>''){
        pFamily.add(a1.Product_Family__c);
}
}

Any help will be much apprecitated.
I've only been able to get 72% code coverage for my apex class. I'm new to apex development. Can someone help me please?

Here is my class:

public class PcPContactInfo {
    public Precall_Plan_2__c c{get; set;}
   
    public PcPContactInfo(ApexPages.StandardController controller)
        {
             c = (Precall_Plan_2__c)controller.getRecord();
        }
   
    public pagereference logout()
        {  
             pagereference p1=new pagereference('/apex/Precall_Plan_Detail_clone?id='+c.get('Id')+'&clone=1');
             return p1;
        }
   
   
    public PageReference dosave()
        {   
             try
            {
                 if(ApexPages.currentPage().getParameters().get('clone')=='1'||ApexPages.currentPage().getParameters().get('save_new')=='1')
                    {
                        c.id=null;                   
                        insert c;
                    }
               
                 else
                        update c;
            }
       
                 catch(exception e) { ApexPages.addMessages(e); return null;  } 

                 return new Pagereference('/' + c.get('Id'));
        }
    
    public void doSomething()
        {
           contact TEST = [SELECT account.name,MailingCountry,Mailingcity,Title,Phone,MailingStreet,MailingState,MailingPostalCode, accountid FROM contact where id = :c.Contact_name2__c];
           // c.Company_Name__c= TEST.account.name;
           c.Contact_mailing_city__c=TEST.Mailingcity;
           c.Contact_s_Title__c=TEST.Title;
           c.Contact_s_Telephone_Number__c=TEST.Phone;
           c.Contact_Street__c=TEST.MailingStreet;
           c.Contact_State__c=TEST.MailingState;
           c.Contact_Zip__c=TEST.MailingPostalCode;
     
        }
}

And here is my Test Class:

@isTest
private class test_PcPContactInfo
{

    static testMethod void go_PcPContactInfo() 
    {
   
        account a = new account(name='ESAB');
        insert a;
        contact c = new contact (lastname= 'test2',accountid=a.id,email='abc@gmail.com');
        insert c;
       
        Precall_Plan_2__c  cw=new Precall_Plan_2__c(name='test',Contact_name2__c=c.id,Company_Name__c=a.id);
        insert cw;
       
        ApexPages.StandardController controller = new ApexPages.StandardController(cw);
        PcPContactInfo stdController = new PcPContactInfo(controller);
        //account a = [SELECT name,id FROM account limit 1];
       
        //contact TEST = [SELECT id, accountid,email FROM contact where id = :cw.contact__c];
        //cw.Email__c = TEST.email;
        //update cw;
       
        stdController.doSomething();
        stdController.dosave();
       
       
    }
}
Hi,
 I have create the visualforce page Pdf,in that page when by clicking it's open in pdf it containd pull through the all value in custom object and parent object values

i could to be bind the value ion pdf and i wll bind the parent object of the addrees field value in this value data typa in formula text when i'm click on the button it will show the address field value in that format .

chennais<br>Demo<br>Demo<br>600004<br>Tel
: <br>Contact : Test Contact



but i need 

chennais<br>
Demo<br>
Demo<br>
600004<br>
Tel

in this format and removing the <br>

I dnt know how to remove the unwanted letters ,please if anyone know please post ur answer it's very urgent....


thanks in advance

I hope u all..  :) :)
: <br>Contact : Test Contact

Hi ,

I have the following controller and Vf page that adds one attachment

controller:

public with sharing class OpportunityAttachmentController{
   
    public Opportunity_Attachment__c objOppAtt {get; set;}
  
    public OpportunityAttachmentController(ApexPages.StandardController controller) {
        attach = new Attachment();
        objOppAtt = (Opportunity_Attachment__c)controller.getRecord();
      
    }

    public Attachment attach {get;set;}
    public Attachment attach1 {get;set;}
  
    //When user clicks upload button on Visualforce Page, perform upload/insert

    public ApexPages.Pagereference save(){
        if(attach.body==null){
            ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR,'Please select a file to upload'));
            return null;
        }
        insert objOppAtt;
      
       
        attach.ParentId = objOppAtt.id;
        insert attach;
       
        
        objOppAtt.URL__c = URL.getSalesforceBaseUrl().toExternalForm()+'/servlet/servlet.FileDownload?file='+attach.id;
        objOppAtt.name = attach.Name;
        update objOppAtt;
       
        return new PageReference('/'+objOppAtt.Opportunity__c);  
    }
   
   
   
   
   
}


VF page:
<apex:page standardController="Opportunity_Attachment__c" extensions="OpportunityAttachmentController">
    <apex:sectionHeader title="New Opportunity Attachment" subtitle="Opportunity Attachment Edit"/>
    <apex:form >
        <apex:pageBlock >
            <apex:pageMessages />
            <apex:pageBlockSection columns="1">
               
                <apex:outputField value="{!Opportunity_Attachment__c.Opportunity__c}"/>
                <apex:pageBlockSectionItem >Upload Contract<apex:inputFile required="true" value="{!attach.body}" filename="{!attach.name}" /></apex:pageBlockSectionItem>
               
            </apex:pageBlockSection>
            <apex:pageBlockButtons >
                <apex:commandButton value="Upload" action="{!save}"/>
            </apex:pageBlockButtons>
        </apex:pageBlock>
    </apex:form>
</apex:page>


I want to add one more attachment  so i modify the vf as follows:
<apex:page standardController="Opportunity_Attachment__c" extensions="OpportunityAttachmentController">
    <apex:sectionHeader title="New Opportunity Attachment" subtitle="Opportunity Attachment Edit"/>
    <apex:form >
        <apex:pageBlock >
            <apex:pageMessages />
            <apex:pageBlockSection columns="1">
              
                <apex:outputField value="{!Opportunity_Attachment__c.Opportunity__c}"/>
                <apex:pageBlockSectionItem >Upload Contract<apex:inputFile required="true" value="{!attach.body}" filename="{!attach.name}" />
            <apex:pageBlockSectionItem >Upload Attributes<apex:inputFile required="true" value="{!attach.body}" filename="{!attach.name}" />

</apex:pageBlockSectionItem>
              
            </apex:pageBlockSection>
            <apex:pageBlockButtons >
                <apex:commandButton value="Upload" action="{!save}"/>
            </apex:pageBlockButtons>
        </apex:pageBlock>
    </apex:form>
</apex:page>


do i have to write a seperate controller,or i can modify the same?If modify the same ,how?

Please help.
 

We have custom objects and on those we have written approval processes. Currently we are migrating from one org(production) to another org(full sandbox) using data loader. We are able to insert the records but not able to get the approval history section related details for the records. How do we get that section ?

 

 

Hi. A friend helped me develop a trigger for when an activity with the subject File Forms from Recruit in EE Folder is changed to the status of completed it updates the opportunity stage to Day 1 Complete. 

But I am getting an error and I can't figure out why. Error: Compile Error: Variable does not exist: trigger at line 4 column 18

Any help is appreciated. 

Here is the code:

trigger updateStatus on Task (after insert, after update){
    List<Id> oppy_ids = new List<Id>();
    List<Opportunity> update_oppys = new List<Opportunity>();
    for(Task t : trigger.new()){
        //when subject is this, the opp should be start 10 day cycle
        if(t.Subject == 'File Forms from Recruit in EE Folder' && t.Status == 'Completed' && t.WhatId != null && String.valueOf(t.WhatId).startsWith('006')){
            oppy_ids.add(t.WhatId);
        }
    }

    for(Opportunity o : [SELECT StageName FROM Opportunity WHERE ID IN :oppy_ids]){
        // or whatever you need the stage  name to be
        o.StageName = 'Day 1 Complete';
        //add the opportunity to a list for dml
        update_oppys.add(o);
    }

    if(!update_oppys.isEmpty()){
        update update_oppys;
    }
}
Hi Guys,

If anyone has any reccomendation it would be greatly appricated. 

Issue: 
Our company's web-to-lead sends us requests daily. Many of our leads are new and therefore handled by our inside sales team. Some however are request from current contacts that are looking to make a new purchase therefore they are handled by our account mgmt team. 

Rather than having our inside sales team convert the lead only to find out they are already a contact, is there a way or tool that we can buy that can determine if a lead is already a contact (Using email address) at the lead view level or in the web-to-lead process?

 
  • March 26, 2014
  • Like
  • 1
For specific users  not able to access the old records belongs to case. I have verified  in profile level. he has Read,Edit,Create permissions. Still he has no access to  already created records. I saw that no users under this Role has not access to case records.

I think we need to create a sharing rule.  Users in this role do not own any contacts.
  • March 25, 2014
  • Like
  • 1
I am employing field sets to display intormation on a VF page. A new requirement is to dynamically require a field within the field set, based on information from a record in an associated object.

For example, if Object1.checkbox1 = true, then the field Object2.DogName is required on the page. 

In the context of using a field set, is there a way to dynamically require Object2.DogName to be either required or not based on the value of Object1.checkbox? 

Any help is greatly appreciated! 
Hi,
Is it possible to stop the execution of the flow in apex classes / triggers so that I could put a breakpoint in the apex class and when I hit the breakpoint in the class it would stop the execution and I could step thru the code in the Eclipse IDE and inspect the variables ?
This is a very good way of learning how the code works and which code is executed in different scenarios.
This is possible in non-cloud normal app development with Java
I know that it is possible to set debug log statements in the code and then run thru the code and it would print the result but this is not nearly as easy as stepping thru the code.
Thanks, Jani
  • January 14, 2014
  • Like
  • 4