• Dilip_V
  • SMARTIE
  • 1468 Points
  • Member since 2015
  • Infosys

  • Chatter
    Feed
  • 49
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 9
    Questions
  • 261
    Replies
Sample code written in Anonymous Window :

Account acc = new Account();
acc.Name = 'XYZ';
insert acc;

The error is shown as :
Line: 2, Column: 3, Variable does not exist: Name

Same problem is occuring with all the fields of Account object.
Rest of the object fields can be accessed using the same method.

Please Help
 
Hello 
I have a custom object fan which has three fields, email , firstname and lastname , email field being mandatory.
first time when page  loads, I append an ID known as encryptedfanID to the browser URL , thereby it loads the respective values into the fields.
so this part is working fine
suppose if I do not append any ID to the URL and hit the save button without entering any values then it throws error " ateempt to deference a null object" error.
 
public class PrefCenterCTRL{
02
 
03
    //Profile Tab 
04
     public String fanLastName { get; set; }
05
    public String fanFirstName { get; set; }
06
    public String fanEmail { get; set; }    
07
    public String encryptedfanID{get;set;}
08
    public fan__c fan{get;set;}
09
    
10
public PrefCenterCTRL()
11
    {
12
     try
13
     {
14
        encryptedfanID=ApexPages.currentpage().getparameters().get('id');
15
        system.debug('@@@'+encryptedfanID);
16
         
17
        if(String.isBlank(ApexPages.currentPage().getParameters().get('id')))
18
        {
19
                ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.ERROR,'Error: Invalid Id.');
20
                ApexPages.addMessage(myMsg);
21
                return;
22
        }
23
        else
24
        {
25
           
26
          fetchfanvalues();
27
        }
28
         
29
      }
30
      catch(Exception e){
31
            ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.ERROR,e.getMessage());
32
            ApexPages.addMessage(myMsg);
33
            return;
34
      }   
35
    }
36
 
37
 public void fetchfanvalues()
38
    {
39
    try
40
    {
41
       fan=[SELECT id, Email__c,First_Name__c,Last_Name__c,
42
            FROM fan__c
43
           WHERE Encrypted_ID__c=:encryptedfanID];
44
             
45
       
46
       if(!string.isBlank(fan.Email__c))
47
       {
48
            fan_email=fan.Email__c;
49
       }
50
 
51
       if(!string.isBlank(fan.First_Name__c))
52
       {
53
           fanFirstName=fan.First_Name__c;
54
       }
55
        
56
       if(!string.isBlank(fan.Last_Name__c))
57
       {
58
           fanLastName=fan.Last_Name__c;
59
       }
60
  }
61
 
62
 public void SaveValues()
63
    {
64
                
65
      if(!string.isBlank(fan_email))
66
      {
67
       fan.Email__c=fan_email;
68
      }
69
       
70
      if(!string.isBlank(fanMobile))
71
      {
72
        fan.Mobile_Phone__c=fanMobile;
73
      }
74
       
75
      if(!string.isBlank(fanFirstName))
76
      {
77
         fan.First_Name__c=fanFirstName;
78
    }
79
    public PageReference btn_profile_saveChanges()
80
    {
81
        SaveValues();
82
        return null;
83
    }
84
}
85
 
86
<apex:page controller="PrefCenterCTRL"
87
           docType="html-5.0"
88
           showHeader="false" >
89
 
90
<apex:form>
91
 
92
         <apex:inputText value="{!fanEmail}" id="email_val"/>    
93
         <apex:inputText value="{!fanfirstname}" id="firstname"/> 
94
         <apex:inputText value="{!fanLastName}" id="lastname"/>
95
<apex:commandButton value="SAVE CHANGES"
96
                    action="{!btn_profile_saveChanges}" />
97
<apex:form>
98
</apex:page>
Please help me out.

Thanks
Krishna
 
Hello 
I have a custom object fan which has three fields, email , firstname and lastname , email field being mandatory.
first time when page  loads, I append an ID known as encryptedfanID to the browser URL , thereby it loads the respective values into the fields.
so this part is working fine
suppose if I do not append any ID to the URL and hit the save button without entering any valies then it throws error " ateempt to deference a null object" error.

a piece of code explaining the above is provided.
public class PrefCenterCTRL{

    //Profile Tab 
     public String fanLastName { get; set; }
    public String fanFirstName { get; set; }
    public String fanEmail { get; set; }    
    public String encryptedfanID{get;set;}
    public fan__c fan{get;set;}
   
public PrefCenterCTRL()
    {
     try
     {
        encryptedfanID=ApexPages.currentpage().getparameters().get('id');
        system.debug('@@@'+encryptedfanID);
        
        if(String.isBlank(ApexPages.currentPage().getParameters().get('id')))
        {
                ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.ERROR,'Error: Invalid Id.');
                ApexPages.addMessage(myMsg);
                return;
        }
        else
        {
          
          fetchfanvalues();
        }
        
      }
      catch(Exception e){
            ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.ERROR,e.getMessage());
            ApexPages.addMessage(myMsg);
            return;
      }   
    }

 public void fetchfanvalues()
    {
    try
    {
       fan=[SELECT id, Email__c,First_Name__c,Last_Name__c,
            FROM fan__c 
           WHERE Encrypted_ID__c=:encryptedfanID];
            
      
       if(!string.isBlank(fan.Email__c))
       {
            fan_email=fan.Email__c;
       }

       if(!string.isBlank(fan.First_Name__c))
       {
           fanFirstName=fan.First_Name__c;
       }
       
       if(!string.isBlank(fan.Last_Name__c))
       {
           fanLastName=fan.Last_Name__c;
       }
  }

 public void SaveValues()
    {
               
      if(!string.isBlank(fan_email))
      {
       fan.Email__c=fan_email;
      }
      
      if(!string.isBlank(fanMobile))
      {
        fan.Mobile_Phone__c=fanMobile;
      }
      
      if(!string.isBlank(fanFirstName))
      {
         fan.First_Name__c=fanFirstName;
    }
    public PageReference btn_profile_saveChanges()
    {
        SaveValues();
        return null;
    }
}

<apex:page controller="PrefCenterCTRL" 
           docType="html-5.0" 
           showHeader="false" >

<apex:form>

         <apex:inputText value="{!fanEmail}" id="email_val"/>     
         <apex:inputText value="{!fanfirstname}" id="firstname"/>  
         <apex:inputText value="{!fanLastName}" id="lastname"/> 
<apex:commandButton value="SAVE CHANGES"
                    action="{!btn_profile_saveChanges}" />
<apex:form>
</apex:page>
I hope I am pretty clear, I request the forum membets to kndly help me out.

thanks
JohnD
 
HI,

I need to do activate or deactivate portal community users based on contact record checkbox field.

if the check is ture then that contact can be have access on portal community or else can't become a portal user

kindly share your thoughts nd way of approch 

thanks
I have created custom field on lead object with 
Forumla return type :text
Using below formula
CASE (MOD (TODAY () - DATE (1900, 1, 7), 7), 0, "Sunday", 1, "Monday", 2, "Tuesday", 3,"Wednesday", 4, "Thursday", 5, "Friday", 6, "Saturday”, “Error",NULL)
But issue is iam getting only TUESDAY as answer . please let me know where Iam wrong .
Thanks in Advance.


 
Hello,

In apex, How to check if the account has not contacts in it ?

 
  • November 10, 2016
  • Like
  • 0
Hi, I am  making a callout to an external site to populate certain fields on the Account object based on the response of the the external site. There is a custom button on the Account object which is working on javascript and calls an apex controller which makes the callout.

The format of the apex class is :

global class ApexCallout {
    webservice static String xyz(Id accountId){
        Account accountDetails = [SELECT Id, Number1__c, Country1__c FROM Account WHERE Id = :accountId];
        // Request logic here
        // Response logic here; the response comes without any issue
        accountDetails.Registered_Name__c = response.name;
        accountDetails.Registered_Address__c = response.address;
        accountDetails.Request_Date__c = response.requestDate;
        System.debug(response);  
       return String.valueOf(response.valid);  
            
    }
    }

Valid is a boolean here.

The response of this callout is coming without any issue. Registered name, Registered Address and Request Date are the fields on the Account object which should be populated based on the response as soon as I click on that custom button on the Account detail page.
However, in my case the button is working, the response is coming but these fields are not getting populated on the detail page. Can someone please let me know what I am missing here.
Hi,

I'm trying to create a Process that will send an email to a Contact, and create a Task to record the activity (and relate it to the correct records), but I can't save the action in the process builder without using a static ID in the ID field.  I'd like to have it look up the IDs from the record.  

I have a cutom object 'QMR' that triggers the Process when it is updated.  The QMR has a master-detail relationship with a Contact and an Account, and I would like the Task to be related to both so it appears in the Activity feed on those pages.  

Not sure if it's worth noting, but my company uses the Professional Edition so Visual Workflow is not available to us.  

User-added image
I'm new to Apex and trying to achieve code coverage for an Apex Class that references a VF page. Below is my apex class: 
 
public class Wave_Sales_Performance{
 public PageReference saveMethod()
    {
  PageReference pgref = new PageReference('https://c.na26.visual.force.com/apex/Wave_Sales_Performance');
        pgref.setRedirect(true);
        return pgref;
        
    }
    public PageReference saveMethod2()
    {
  PageReference pgref = new PageReference('https://c.na26.visual.force.com//apex/Wave_New_Rev_by_Individual');
        pgref.setRedirect(true);
        return pgref;
    }    
        public PageReference saveMethod3()
    {
  PageReference pgref = new PageReference('https://c.na26.visual.force.com/apex/Wave_YTD_Appointment_Metrics');
        pgref.setRedirect(true);
        return pgref;
       } 
        public PageReference saveMethod4()
    {
  PageReference pgref = new PageReference('https://c.na26.visual.force.com/apex/Wave_Online_Offline');
        pgref.setRedirect(true);
        return pgref;
       } 
         public PageReference saveMethod5()
    {
  PageReference pgref = new PageReference('https://c.na26.visual.force.com/apex/Wave_Actual_Budget');
        pgref.setRedirect(true);
        return pgref;
       } 
        
    
}


Any solutions or advice would be much appreciated. 

Thanks
Daniel

Hi,
I have a custom object " Transaction ( API Name : Quotation__c) " and a related object " Biz Validation" on it.
User-added image

I want that, if there is any records exists in the " Biz validation" related object , the field " Biz Validation exists" value in the " Transaction" object should be "YES". can anyone plz suggest how to achieve this. I have the look up relationship between the two objects ( Biz valid being the child object). I have written the below trigger for it, although its not showing any errors while saviing, also its not working. Can anyone plz pont out where i gone wrong in the below trigger? Thanx
 
trigger updateTrans on Biz_validations__c (after update) {
Map<Id, Biz_validations__c> bizValidWithAuthLimit=new Map<Id, Biz_validations__c> ();
for(Integer i=0; i<Trigger.new.size();i++){
if(Trigger.new[i].Authority_limit__c != null) 
{
bizValidWithAuthLimit.put(Trigger.new[i].id,null);
}
}
                                                     
List<Quotation__c> updatedTrans=new List<Quotation__c>();

    for (Quotation__c q : [SELECT id,Biz_Validation_Exists__c FROM Quotation__c WHERE id
                            in :bizValidWithAuthLimit.keySet()])
                      
                          {
  Biz_validations__c parentBizValid = bizValidWithAuthLimit.get(q.id);
  q.Biz_Validation_Exists__c= parentBizValid.Authority_limit__c;
  
  updatedTrans.add(q);
  
  }
update updatedTrans ;                   
}

 
Hi,

Could you please help me on the below.
Is there a way we can set the redirect url on Session Time out like we have for Log out URL?

Currently, the user is reirected to www.salesforce.com on session time out. is there a way we could configure this value?

Thanks,
 
can anybody explain order of execution of empty VF page ?

Thanks for advance !!!
Regards,

Bhanu
I have get the above (title question)Error on the execution of my Controller and page.It's a standardcontroller with extension of to providing the pagination and sorting and now try to add the alpha  navigation bar.
So that's why I getting this error I don't know to how to rectify this error so can any one help me to solve the error.
My controller:
public class StandardPaginationSorting {

    // Variables required for Sorting.
    public String soql {get;set;}
    public List <Account> CandidateList1 = New List <Account>();
    public String soqlsort {get;set;}
    public List <Account> CandidateList2 = New List <Account>();
    public List<Account> acc {get; set;}

                // List used in to display the table in VF page.
                public List<Account> getCandidateList() {
                    // Passing the values of list to VF page.
                    return con.getRecords();
                    //all();
                }

                // instantiate the StandardSetController from a query locator
                public StandardPaginationSorting(ApexPages.StandardController controller){
                 con.getRecords();
                 all();
                }
                public ApexPages.StandardSetController con {
                    get {
                                                if(con == null) {
                                                                // String Query to have a list of cases for a respective End-user.
                                                                soql = 'SELECT Name, Website,BillingCountry, Phone, Type, Owner.Name FROM Account';

                                                                // Passing the String array to a list with Selected field sorting.
                                                                CandidateList1 = Database.query(soql + ' order by ' + sortField + ' ' + sortDir ); 

                                                                // setting values of List in StandardSetController.
                                                                con = new ApexPages.StandardSetController(CandidateList1);

                                                                // sets the number of records in each page set
                                                                con.setPageSize(10);
                                                }
                                                return con;
        }
        set;
    }

    // indicates whether there are more records after the current page set.
    public Boolean hasNext {
        get {
            return con.getHasNext();
        }
        set;
    }

    // indicates whether there are more records before the current page set.
    public Boolean hasPrevious {
        get {
            return con.getHasPrevious();
        }
        set;
    }

    // returns the page number of the current page set
    public Integer pageNumber {
        get {
            return con.getPageNumber();
        }
        set;
    }

    // returns the first page of records
    public void first() {
        con.first();
    }

    // returns the last page of records
    public void last() {
        con.last();
    }

    // returns the previous page of records
    public void previous() {
        con.previous();
    }

    // returns the next page of records
    public void next() {
        con.next();
    }

    // returns the PageReference of the original page, if known, or the home page.
    public void cancel() {
        con.cancel();
    }

    // Method for Constructor is used for Test Class.
    public StandardPaginationSorting(){ 
        //all();     
    }

   //Toggles the sorting of query from asc<-->desc
    public void toggleSort() {
        // simply toggle the direction
        sortDir = sortDir.equals('asc') ? 'desc' : 'asc';

                                // run the query again for sorting other columns
                                soqlsort = 'SELECT Name, Phone, BillingCountry, Website, Owner.Name, Type FROM Account'; 

                                // Adding String array to a List array
                                CandidateList2 = Database.query(soqlsort + ' order by ' + sortField + ' ' + sortDir ); 

                                // Adding Caselist to Standard Pagination controller variable
                                con = new ApexPages.StandardSetController(CandidateList2);

                                // Set Page Size to 10
                                con.setPageSize(10);

    }

    // the current sort direction. defaults to asc
    public String sortDir {
        // To set a Direction either in ascending order or descending order.
                                get  { if (sortDir == null) {  sortDir = 'asc';} return sortDir;}
        set;
    }

    // the current field to sort by. defaults to last name
    public String sortField {
        // To set a Field for sorting.
                                get  { if (sortField == null) {sortField = 'Name'; } return sortField;  }
        set;
    } 
    //the alpha bar navigation filter
    public PageReference ggg() {
        return null;
    }
    public PageReference eee() {
        return Null;
    }
    Public PageReference ddd() {
        return Null;
    }
    Public PageReference ccc() {
        return Null; 
    }
    Public PageReference bbb() {
        return Null;
    }
    
    string x;
    public PageReference fff() {
    x = 'f';
    acc.clear();
    String qry = 'SELECT  Name FROM Account WHERE Name LIKE \''+x+'%\' ORDER BY Name';
    acc= Database.query(qry);
    //con = new ApexPages.StandardSetController(acc);
        return null;
    }
    
    string xx;
    public PageReference rrr() {
     xx = 'R';
    acc.clear();
    String qry = 'SELECT  Name FROM Account WHERE Name LIKE \''+xx+'%\' ORDER BY Name';
    acc= Database.query(qry);
    con = new ApexPages.StandardSetController(acc);
        return null;
    }
    
    string z;
    public PageReference mmm() {
    z = 'm';
    acc.clear();
    String qry = 'SELECT  Name FROM Account WHERE Name LIKE \''+z+'%\' ORDER BY Name';
    acc= Database.query(qry);
    //con = new ApexPages.StandardSetController(acc);
        return null;
    }
    
    string y;
    public PageReference ooo() {
    y = 'o';
    acc.clear();
    String qry = 'SELECT  Name FROM Account WHERE Name LIKE \''+y+'%\' ORDER BY Name';
    acc= Database.query(qry);
        return null;
    }
    
    public void all() {
        acc = [SELECT Name FROM Account];
        con = new ApexPages.StandardSetController(acc);
        con.setpagesize(10);
    }
    
    public void aaa() {
        acc.clear();
        acc = [SELECT Name FROM Account];
        con = new ApexPages.StandardSetController(acc);
        con.setpagesize(10);
    }
    

}

For answer's thanks in advance.
On the 'Getting Started with Apex Triggers' challenge you have to add a custom checkbox field - Match_Billing_Address__c. Can this be done through the user inteface by editing the Accunts object?
On the Beginner Developer Trail I came in at 'Apex Basics and Database'. I don't recall seeing how to add new fields to objects.
Can someone pont me to the resource that tells me how to add a custom checkbox field?
Thanks,
Vin
 
Hi, 

 I am using <apex:outputField style="font-weight:500"  value="{!opportunity.name}"/> tag to display opportunity name for some reasons its not enabling the link to drill down the opportunity. 

Please suggest me how to enable the link. 

Thanks
Sudhir
  • October 25, 2016
  • Like
  • 0
Hi All,
I have written a trigger on Account.
I am storing mutiple phone number values in phone number field and I am splitting those values into three different fields.
It is working fine. If I update any phone number in phone field, I want to see the same change in those fields. This updation is not working.

Please suggest me the changes

This is the code I have written.

trigger AccountPhoneTrigger on Account (before insert) {
 List<String> descriptionValues;
 List<Id> accountIds = new List<Id>(); 
        for(Account acc: Trigger.New){
        if(!String.isBlank(acc.Phone)){
           descriptionValues = acc.Phone.split(',');
            
           for(Integer count = 0; count < descriptionValues.size(); count ++){
                    acc.Pho1__c = descriptionValues[0].trim();
                       acc.Pho2__c = descriptionValues[1].trim();
                       acc.Pho3__c = descriptionValues[2].trim();
                        
           }
        }
            
   
    }
}
Hi everyone,

I'm getting  -Error: Unknown property 'Opportunity_Positioning__cStandardController.Buying_Influence__c'? 

Any ideas what  I am doing wrong? Your assistance would be much appreciated!

Thank you,

Rog

<apex:page standardcontroller="Opportunity_Positioning__c">
           extensions="EditableBuyingInfluenceExtension"
<apex:sectionheader title="{!$ObjectType.Buying_Influence__c.label} Edit" subtitle="{!IF(ISNULL(Buying_Influence__c.Name), 'New Buying Influence',Buying_Influence__c.Name)}"/>
    <apex:form >
        <apex:pageblock mode="edit" title="{!$ObjectType.Buying_Influence__c.label} Edit">
            <apex:pageblockbuttons >
                <apex:commandbutton value="Save" action="{!Save}"/>
                <apex:commandbutton value="Cancel" action="{!Cancel}"/>
            </apex:pageblockbuttons>
            <apex:pageblocksection title="Information" showheader="true" columns="2">
                    <apex:outputText> value="{!Opportunity_Positioning__c.Name}"/>
                    <apex:outputText> value="{!Opportunity_Positioning__c.Opportunity__c}"/>
                    <apex:pageblocksectionitem />
            <apex:pageBlockSectionItem >
                <apex:pageblocksection id="childList" columns="1" title="Buying Influence" collapsible="false">
                <apex:variable var="rowNum" value="{!ZERO}" />
                <apex:outputLabel value="No Buying Influence currently exist. Click below to Add." rendered="{!NOT(hasChildren)}"/>
                    <apex:pageBlockTable value="{!children}" var="Buying Influence" rendered="{!hasChildren}">
                    <apex:column headerValue= "Buying Influence">
                    <apex:inputfield value="{!Buying_Influence__c.Name}" required="true"/>
                    <apex:column headerValue= "SCOP">
                    <apex:inputfield value="{!Buying_Influence__c.SCOP__c}" required="true"/>
                    <apex:column headerValue= "Influencer Name">
                    <apex:inputfield value="{!Buying_Influence__c.Influencer_Name__c}" required="true"/>
                    <apex:column headerValue= "Buying Influence role">
                    <apex:inputfield value="{!Buying_Influence__c.Buying_influence_role__c}" required="true"/>
                    <apex:column headerValue= "Degree of Influence">
                    <apex:inputfield value="{!Buying_Influence__c.Degree_of_Influence__c}" required="true"/>
                    <apex:pageblocksectionitem />
               </apex:column>
               <apex:pageblocksection title="How well is based covered for this contact" showheader="true" columns="2">
               </apex:pageblocksection>
               </apex:column> headerValue="Rating for base covered">
                    <apex:inputfield value="{!Buying_Influence__c.Rating_for_base_covered__c}" required="true"/>
               </apex:column> headerValue="Equivalent Collinson Stakeholder">
                    <apex:inputfield value="{!Buying_Influence__c.Equivalent_Collinson_Stakeholder__c}" required="false"/>
               </apex:column> headerValue="Evidence to support your rating">
                    <apex:inputfield value="{!Buying_Influence__c.Evidence_to_support_your_rating__c}" required="false"/>
                    </apex:column>
                    <apex:column headerValue=" ">
                    <!-- This is the second half of the trick to keep track
                    of your row index for deletion. -->
                    <apex:variable var="rowNum" value="{!rowNum + 1}" />
                    <apex:commandLink value="Delete" action="{!removeFromList}" rerender="childList,messages" immediate="true"> 
     <apex:param name="removeIndex" assignTo="{!removeIndex}" value="{!rowNum}" />
            </apex:commandLink>
          </apex:column>
        </apex:pageBlockTable>
        <apex:commandButton value="Add Buying Influence" action="{!addToList}" rerender="childList, messages" immediate="true" />
      </apex:pageBlockSection>
     </apex:pageblocksectionitem>
     </apex:outputtext> </apex:outputtext>
    </apex:pageblocksection>
</apex:pageblock>
</apex:form>
</apex:page>
Hi,
I am trying to write a Test Class for a Queueable apex class but the code coverage is not reaching 100%.

Queueable class:
public class AddPrimaryContact implements Queueable{
    private Contact con;
	private string state;
    public AddPrimaryContact(Contact con,String state)
    {
        this.con=con;
        this.state = state;
    }
    public void execute(QueueableContext Context)
    {
        Contact cont = [select Id,LastName,AccountId from Contact where Id=: con.Id limit 1];
        List<Account> accntlist = [select Id,Name,BillingState from Account where BillingState=: state limit 200];
        List<Contact> Conlist = new List<Contact>();
        for(Account a: accntlist)
        {	
            Contact cclone = cont.clone(false,false,false,false);
            cclone.AccountId = a.Id;
            Conlist.add(cclone);
        }
        insert Conlist;
    }
}

Test Class:
@isTest(seeAllData=false)
private class AddPrimaryContactTest {

    @testSetup
    static void setup()
    {
        List<Account> testAcnlist = new List<Account>();
        for(Integer i=0;i<50;i++)
        {
            Account a = new Account(Name='Test'+i,BillingCity='NY');
            testAcnlist.add(a);
        }
        for(Integer i=0;i<50;i++)
        {
            Account a = new Account(Name='Test'+i,BillingCity='CA');
            testAcnlist.add(a);
        }
        insert testAcnlist;
       Contact cnt = new Contact(LastName='TestContact');
        insert cnt;
    }
    static testmethod void testenqueuebale()
    {
         Contact conobj = [Select Id,Name,LastName from Contact where LastName='TestContact'];
        AddPrimaryContact apc = new AddPrimaryContact(conobj,'CA');
        Test.startTest();
        system.enqueueJob(apc);
        Test.stopTest();
        //system.assertNotEquals(null, [select Id,(Select LastName from contacts) from Account where BillingCity='CA']);
    }
}

Test Execution:
Strike through lines are not covered. Appreciate your help !!

public class AddPrimaryContact implements Queueable{
    private Contact con;
    private string state;
    public AddPrimaryContact(Contact con,String state)
    {
        this.con=con;
        this.state = state;
    }
    public void execute(QueueableContext Context)
    {
        Contact cont = [select Id,LastName,AccountId from Contact where Id=: con.Id limit 1];
        List<Account> accntlist = [select Id,Name,BillingState from Account where BillingState=: state limit 200];
        List<Contact> Conlist = new List<Contact>();
        for(Account a: accntlist)
        {    
            Contact cclone = cont.clone(false,false,false,false);
            cclone.AccountId = a.Id;
            Conlist.add(cclone);

        }
        insert Conlist;
    }
}

Regards
Somnath
I modified OrderTests  and Product2Tests to cover OrderTrigger,OrderTrigger. Coverage is good but Whin I clicked on check challenge I am getting this error '
Ensure that you assert the values in the verifyQuantityRemaining method.' not sure why there is no such anywhere in the components.
Hi,
We are using drawloop to merge files,we need to merge 1000 files.
We are using below method to process 1000 docs
ConvertAndMerge(List<Id> docIds, Id parentId, String outputFilename, Map<String, String> params)

This method is working fine for 500 docs but its not working for 1000.

Please suggest any other app exchange app to merge 1000 files.

Thanks. 
Hi ,

I have little doubt about XML parsing.
How can we parse an XML file that contains 10 orders and how can we insert them.I tried with DOM class.Using dom I can extract the Information from xml but I am unable to store them into the list of orders with it's childs payments.

Below is my code.

Controller:
public class ParseTestv1 {

    // This holds the text we should parse
      public blob body{get;set;}

    // This holds the result of any parsing
    public String parsedText {get; set;}
    public list<string> ParsedList{get;set;}
     public String TextToParse {get; set;}
    
    // The main method that's called when you click the button
    public PageReference parse() {
        parsedlist=new list<string>();
       if (body == null) {
         parsedText = 'Nothing to parse';
       } else {
           TextToParse=body.toString();
         parsedText = parse(textToParse);
           
       }
        return null;
    }
    
    // Just checking that it's actually XML
    private String parse(String toParse) {
        
      DOM.Document doc = new DOM.Document();
      
      try {
        doc.load(toParse);    
        DOM.XMLNode root = doc.getRootElement();
        return walkThrough(root);
        
      } catch (System.XMLException e) {  // invalid XML
        return e.getMessage();
      }
    }

    // Recursively walk through the XML
    private String walkThrough(DOM.XMLNode node) {
      String result = '\n';
      if (node.getNodeType() == DOM.XMLNodeType.COMMENT) {
        return 'Comment (' +  node.getText() + ')';
      }
      if (node.getNodeType() == DOM.XMLNodeType.TEXT) {
        return 'Text (' + node.getText() + ')';
      }
      if (node.getNodeType() == DOM.XMLNodeType.ELEMENT) {
        result += + node.getName();
        if (node.getText().trim() != '') {
          result += '=' + node.getText().trim();
        }
        if (node.getAttributeCount() > 0) { 
          for (Integer i = 0; i< node.getAttributeCount(); i++ ) {
            result += ', attribute #' + i + ':' + node.getAttributeKeyAt(i) + '=' + node.getAttributeValue(node.getAttributeKeyAt(i), node.getAttributeKeyNsAt(i));
          }  
        }
        for (Dom.XMLNode child: node.getChildElements()) {
          result += walkThrough(child);
        }
        return result;
      }
      return '';  //should never reach here
      
    }
}
Page:
<apex:page controller="ParseTestv1" sidebar="false" showHeader="false" >
   <apex:form >
       <apex:inputFile value="{!body}" />
     <apex:inputtextarea cols="40" rows="20" id="result" value="{!parsedText}"/>     
     <br/>
     <apex:commandButton value="Parse" action="{!parse}"/>
   </apex:form>
</apex:page>

Thanks.

 
Hi all,

How can we process the xml sheet of length 32 MB.I wrote sample code which is working fine for small xml files.

here is the snippet.

Controller:
public class ParseTestv1 {

    // This holds the text we should parse
      public blob body{get;set;}

    // This holds the result of any parsing
    public String parsedText {get; set;}
    public list<string> ParsedList{get;set;}
     public String TextToParse {get; set;}
    
    // The main method that's called when you click the button
    public PageReference parse() {
        parsedlist=new list<string>();
       if (body == null) {
         parsedText = 'Nothing to parse';
       } else {
           TextToParse=body.toString();
         parsedText = parse(textToParse);
           
       }
        return null;
    }
    
    // Just checking that it's actually XML
    private String parse(String toParse) {
        
      DOM.Document doc = new DOM.Document();
      
      try {
        doc.load(toParse);    
        DOM.XMLNode root = doc.getRootElement();
        return walkThrough(root);
        
      } catch (System.XMLException e) {  // invalid XML
        return e.getMessage();
      }
    }

    // Recursively walk through the XML
    private String walkThrough(DOM.XMLNode node) {
      String result = '\n';
      if (node.getNodeType() == DOM.XMLNodeType.COMMENT) {
        return 'Comment (' +  node.getText() + ')';
      }
      if (node.getNodeType() == DOM.XMLNodeType.TEXT) {
        return 'Text (' + node.getText() + ')';
      }
      if (node.getNodeType() == DOM.XMLNodeType.ELEMENT) {
        result += 'Element: ' + node.getName();
        if (node.getText().trim() != '') {
          result += ', text=' + node.getText().trim();
        }
        if (node.getAttributeCount() > 0) { 
          for (Integer i = 0; i< node.getAttributeCount(); i++ ) {
            result += ', attribute #' + i + ':' + node.getAttributeKeyAt(i) + '=' + node.getAttributeValue(node.getAttributeKeyAt(i), node.getAttributeKeyNsAt(i));
          }  
        }
        for (Dom.XMLNode child: node.getChildElements()) {
          result += walkThrough(child);
        }
        return result;
      }
      return '';  //should never reach here
      
    }
}

Visualforce Page
<apex:page controller="ParseTestv1" sidebar="false" showHeader="false" >
  
   <apex:form >
       <apex:inputFile value="{!body}" />

     <apex:inputtextarea cols="40" rows="20" id="result" value="{!parsedText}"/>     
     <br />
     <apex:commandButton value="Parse" action="{!parse}"/>

   </apex:form>

</apex:page>

Thanks.

 
while searching on Google about dynamic VF pages I found this blog (http://opfocus.com/blog/how-to-dynamically-add-a-configurable-list-of-fields/).
I created the custom settings and added few fields and records.But code is not working properly.

I am getting this error:
Could not resolve field 'NewOpp' from <apex:inputField> value binding '{!dummyOpp[FieldName]}' in page customsettingsvf 

thanks.

Trigger:
trigger leadDuplicatePreventer on Lead 
(before insert, before update) { 

Map<String, Lead> leadMap = new Map<String, Lead>(); 
for (Lead lead : System.Trigger.new) { 

// Make sure we don't treat an email address that 

// isn't changing during an update as a duplicate. 

if ((lead.Email != null) && 
(System.Trigger.isInsert || 
(lead.Email != 
System.Trigger.oldMap.get(lead.Id).Email))) { 

// Make sure another new lead isn't also a duplicate 

if (leadMap.containsKey(lead.Email)) { 
lead.Email.addError('Another new lead has the ' 
+ 'same email address.'); 
} else { 
leadMap.put(lead.Email, lead); 
} 
} 
} 

// Using a single database query, find all the leads in 

// the database that have the same email address as any 

// of the leads being inserted or updated. 

for (Lead lead : [SELECT Email FROM Lead 
WHERE Email IN :leadMap.KeySet()]) { 
Lead newLead = leadMap.get(lead.Email); 
newLead.Email.addError('A lead with this email ' 
+ 'address already exists.'); 
} 
}
Test Class:
@isTest
Public class TestEmailDupPreventor
{
 Public Static testmethod void PositiveCase()
{
//Testing at the time of record creation
Lead Ld=new Lead(Firstname='Manohar',Lastname='SD',Company='Suzlon',Email='abcd@yopmail.com');
insert ld;
system.assertEquals('abcd@yopmail.com',ld.email);
Lead Ld1=new Lead(Firstname='Mohan',Lastname='SD',Company='Suzlon',Email='abcd@yopmail.com');
try
{
insert ld1;
 System.assert(false);
}
catch(DMLException e)
{
    //System.assert(false,' FIELD_CUSTOM_VALIDATION_EXCEPTION ');
}

}
  
Public Static testmethod void NegativeCase()
{
test.starttest();
//testing for Updation case
Lead l1= new Lead(Firstname='Test1',Lastname='TT',Company='KT',Email='kt1@yopmail.com');insert l1;
Lead l2= new Lead(Firstname='Test2',Lastname='TT',Company='KT',Email='kt2@yopmail.com');insert l2;
l2.email='kt1@yopmail.com';
try{
upsert l2;
system.assert(false);
}
catch(Dmlexception e)
{
}
test.stoptest();
}



}
Total coverage is 76%.
The first methode(Checking while Inserting) is executing Properly.
Second method(Checking while Updating) is not passed and showing an error:

System.UnexpectedException: No more than one executeBatch can be called from within a testmethod. Please make sure the iterable returned from your start method matches the batch size, resulting in one executeBatch invocation.

But I hav'nt wrote any batch methods.

 
I wrote a page for Searching.I declared a list in controller InvByLocation.

But when I am trying to Access the list it was showing Error: Unknown property 'InvLocationSearchContr.InvByLocation.
 
public with sharing class InvLocationSearchContr 
{

  
    public Boolean refer { get; set; }
    public string location { get;set;}
    public List<Inventory__C> InvByLocation=new List<Inventory__C>();
    public PageReference Search()
    {
         refer=true;
         InvByLocation=[Select Name,Location__C From Inventory__C where Location__C='Location'];
         return null;
    }



}


<apex:page Controller="InvLocationSearchContr" showHeader="False">
  <apex:form id="MyF">
  <apex:pageBlock title="Inventory Search By Location">
  <apex:pageBlockSection >
      <apex:inputText value="{!Location}" label="Location"/>  
  </apex:pageBlockSection>
  <apex:pageBlockSection >
      <apex:commandButton action="{!Search}" value="Search" style="background:black;font-weight:bold;color:white"/>
  </apex:pageBlockSection>
  </apex:pageBlock>
  <apex:pageblock rendered="{!refer}">
      <apex:pageBlockTable value="{!InvByLocation}" var="lap">
          <apex:column value="{!lap.Name}"/>
          <apex:column value="{!lap.Location__c}"/>
      </apex:pageBlockTable>
  </apex:pageblock>
  
  
  
  </apex:form>
</apex:page>

 


I developed a page for capturing candidate Inf.If user selects PG( in the picklist ) then both Gradation and PG inf should appear on the page,If user selcts Graduation then Only Graduation inf should appear on the page.But unfortunately somthin went wong.

When I select the value in the picklist the page is not responding.
<apex:page standardController="Candidate__c">
<apex:sectionHeader title="Candidate" subtitle="{!Candidate__c.name}"/>
<apex:form >
<apex:pageBlock title="Candidate__C Edit" mode="edit">

<apex:pageBlockButtons location="bottom">
<apex:commandButton value="Save" action="{!save}"/>
<apex:commandButton value="Save & New" action="{!save}" />
<apex:commandButton value="Cancel" action="{!cancel}"/>
</apex:pageBlockButtons>


<apex:pageBlockSection title="Information" columns="2">
<apex:inputField value="{!Candidate__c.Gender__c}" required="false"/>
<apex:inputField value="{!Candidate__c.Name}" required="true"/>
<apex:inputField value="{!Candidate__c.EMail__c}" required="false"/>
<apex:inputField value="{!Candidate__c.Phone__c}" required="false"/>

<apex:PageBlockSectionItem >
 <apex:outputLabel value="Highest Qualification   "/>
<apex:actionRegion >
                          
                          <apex:inputField value="{!Candidate__c.HighestQualification__c}">
                          <apex:actionSupport event="onchange" reRender="ajaxrequest" status="status"/>
                          </apex:inputField>
</apex:actionRegion>
</apex:PageBlockSectionItem>
</apex:pageblocksection>
                         
<apex:outputPanel id="ajaxrequest">
 <apex:pageBlockSection rendered="{!Candidate__c.HighestQualification__c=='B.Tech'}" >
                      <apex:inputField value="{!Candidate__c.BBranch__c}" required="false"/>
                      <apex:inputField value="{!Candidate__c.BCollege__c}" required="false"/>
  </apex:pageBlockSection>
 <apex:pageBlockSection rendered="{!Candidate__c.HighestQualification__c=='M.Tech'}" >
 
         <apex:inputField value="{!Candidate__c.BBranch__c}" required="false"/>
         <apex:inputField value="{!Candidate__c.BCollege__c}" required="false"/>
        <apex:inputField value="{!Candidate__c.MBranch__c}" required="false"/>
        <apex:inputField value="{!Candidate__c.M_Tech_College__c}" required="false"/>
</apex:pageBlockSection>
</apex:outputPanel> 
</apex:pageBlock>
</apex:form>
//https://developer.salesforce.com/forums/?id=906F000000096zcIAA
</apex:page>
  • September 09, 2015
  • Like
  • 0
I wrote a custom controller(Wizard based) and two VF pages.

My Intention is to capture the details of custom object(Candidate)Using first page I and
Using Next page I am displying the same fields and save button.

But the records are not saving and not displaying in the VF2.

Controller:
Apex Controller:

public with sharing class CanrecordCon {

public Candidate__C Can{ get; private set; }
public CanrecordCon() {
Id id = ApexPages.currentPage().getParameters().get('id');
if(id == null) 
 new Candidate__C();
 else
Can=[SELECT Name, Phone__C FROM Candidate__C WHERE Id = :id];
}

public PageReference Next() 
{
      return Page.newCanrecord1;
 }

public PageReference save() {
try {

insert(Can);
} catch(System.DMLException e) {
ApexPages.addMessages(e);
return null;
}
// After Save, navigate to the default view page:
return (new ApexPages.StandardController(Can)).view();
}
}

Vf-page1:
<apex:page Controller="CanrecordCon" >

<apex:form >
<apex:pageBlock mode="edit">
<apex:pageMessages />
<apex:pageBlockSection >
<apex:inputField value="{!Can.name}" id="No1"/>
<apex:inputField value="{!Can.Phone__c}" id="No2"/>

</apex:pageBlockSection>
<apex:pageBlockButtons location="bottom">
<apex:commandButton value="Next" action="{!Next}"/>
</apex:pageBlockButtons>
</apex:pageBlock>
</apex:form>
  
</apex:page>

Vf page2:

<apex:page controller="CanrecordCon" tabstyle="Account">
  
  <apex:form >
<apex:pageBlock >
<apex:pageBlockSection title="Details" collapsible="false"  columns="2">
            <apex:outputField id="a1" value="{!Can.Name}"/> 
            
            <apex:outputField id="a3" value="{!Can.Phone__c}"/>          
        </apex:pageBlockSection></apex:pageBlock>
   <apex:commandButton value="Save" action="{!save}"/>
</apex:form>
</apex:page>

 
I modified OrderTests  and Product2Tests to cover OrderTrigger,OrderTrigger. Coverage is good but Whin I clicked on check challenge I am getting this error '
Ensure that you assert the values in the verifyQuantityRemaining method.' not sure why there is no such anywhere in the components.
Hi 
I need a solution for this.

When Customer reply to the email which was sent from Salesforce by Workflow/Process builder, The case owner should get notified the particular case itself.
 
Sample code written in Anonymous Window :

Account acc = new Account();
acc.Name = 'XYZ';
insert acc;

The error is shown as :
Line: 2, Column: 3, Variable does not exist: Name

Same problem is occuring with all the fields of Account object.
Rest of the object fields can be accessed using the same method.

Please Help
 
Hi Experts,

I have one problem in the trigger. Here two mail notifications are going instead of one when case is opened. The trigger is given below. Only one notification should go. Please help.


         
   Apex Coding to send email to the Account insidesales rep based on case status.
           
    1.If Case Status is Open then Send email notification to the account insidesalesrep  .
   
 
    
Trigger Case_AIU_Rep_Notification  on Case (after insert,after update) {
    Set<Id> accIds = new Set<Id>();
    Set<Id> contIds=new Set<Id>();
    
    List<Messaging.SingleEmailMessage> mails = new List<Messaging.SingleEmailMessage>();
    if(checkRecursive_Case_AIU_Rep_Notification.runOnce())
    {
    for (Case c: trigger.new) {
     If(c.Status == 'Open'){
        accIds.add(c.AccountId);
         contIds.add(c.ContactId);
        }
    }
    Map<Id, Account> accMap = new Map<Id, Account>([SELECT Id,name,Customer_ID__c, thermage_tlr__Rep_2__r.Email,thermage_tlr__Consumable_Rep__r.name,thermage_tlr__Rep_3__r.name,thermage_tlr__Rep_1__r.name,thermage_tlr__Capital_Rep__r.name FROM Account WHERE Id In :accIds]);
    Map<Id,Contact> contMap=new Map<Id,Contact>([select id,lastname,firstname from contact where id in:contids]);
    //System.debug('accMap '+accMap );
    for (Case c : trigger.new) {
    
        string body='<h3>*** CASE OPENED NOTIFICATION ***</h3>'+' <br/>';
        body+='The following case has been opened.'+' <br/>';
        body+='Company:'+accMap.get(c.accountid).name +' <br/>';      
        body+='Customer id:'+accMap.get(c.Accountid).Customer_ID__c+' <br/>';
        body+='Contact Name: '+contMap.get(c.contactId).lastname+' <br/>';
        body+='Case #: '+c.CaseNumber+' <br/>'; 
        body+='Subject #: '+c.Subject+' <br/>'; 
        body+='Description #: '+c.Description +'<br/><br/>'; 
        body+= 'Click on the link to access the case:<a href=https://cs51.salesforce.com/>'+c.CaseNumber+'</a>'+'<br/><br/>';
        body+='Account Manager:'+accMap.get(c.AccountId).thermage_tlr__Consumable_Rep__r.name +'<br/>'; 
        body+='Capital Specialist:'+accMap.get(c.AccountId).thermage_tlr__Capital_Rep__r.name+'<br/>'; 
        body+='Surgical Specialist:'+accMap.get(c.AccountId).thermage_tlr__Rep_3__r.name+'<br/>'; 
        body+='Clinical Specialist:'+ accMap.get(c.AccountId).thermage_tlr__Rep_1__r.name+'<br/>';
      
        String Subject='Open Case # '+c.CaseNumber+','+ accMap.get(c.Accountid).Name+' | Account Manager :'+accMap.get(c.Accountid).thermage_tlr__Consumable_Rep__c;
        Account relatedCaseaccount = accMap.get(c.AccountId);
       
        Messaging.SingleEmailMessage CaseNotificationmail = new Messaging.SingleEmailMessage();  
        CaseNotificationmail.setToAddresses(new List<String> {accMap.get(c.AccountId).thermage_tlr__Rep_2__r.Email});
       
        CaseNotificationmail.setSubject(Subject);
       
        CaseNotificationmail.setHtmlBody(body);
        Messaging.sendEmail(new Messaging.SingleEmailMessage[] {CaseNotificationmail});

       mails.add(CaseNotificationmail); 
    
    }
    Messaging.sendEmail(mails);
   }
}

 
Hello 
I have a custom object fan which has three fields, email , firstname and lastname , email field being mandatory.
first time when page  loads, I append an ID known as encryptedfanID to the browser URL , thereby it loads the respective values into the fields.
so this part is working fine
suppose if I do not append any ID to the URL and hit the save button without entering any values then it throws error " ateempt to deference a null object" error.
 
public class PrefCenterCTRL{
02
 
03
    //Profile Tab 
04
     public String fanLastName { get; set; }
05
    public String fanFirstName { get; set; }
06
    public String fanEmail { get; set; }    
07
    public String encryptedfanID{get;set;}
08
    public fan__c fan{get;set;}
09
    
10
public PrefCenterCTRL()
11
    {
12
     try
13
     {
14
        encryptedfanID=ApexPages.currentpage().getparameters().get('id');
15
        system.debug('@@@'+encryptedfanID);
16
         
17
        if(String.isBlank(ApexPages.currentPage().getParameters().get('id')))
18
        {
19
                ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.ERROR,'Error: Invalid Id.');
20
                ApexPages.addMessage(myMsg);
21
                return;
22
        }
23
        else
24
        {
25
           
26
          fetchfanvalues();
27
        }
28
         
29
      }
30
      catch(Exception e){
31
            ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.ERROR,e.getMessage());
32
            ApexPages.addMessage(myMsg);
33
            return;
34
      }   
35
    }
36
 
37
 public void fetchfanvalues()
38
    {
39
    try
40
    {
41
       fan=[SELECT id, Email__c,First_Name__c,Last_Name__c,
42
            FROM fan__c
43
           WHERE Encrypted_ID__c=:encryptedfanID];
44
             
45
       
46
       if(!string.isBlank(fan.Email__c))
47
       {
48
            fan_email=fan.Email__c;
49
       }
50
 
51
       if(!string.isBlank(fan.First_Name__c))
52
       {
53
           fanFirstName=fan.First_Name__c;
54
       }
55
        
56
       if(!string.isBlank(fan.Last_Name__c))
57
       {
58
           fanLastName=fan.Last_Name__c;
59
       }
60
  }
61
 
62
 public void SaveValues()
63
    {
64
                
65
      if(!string.isBlank(fan_email))
66
      {
67
       fan.Email__c=fan_email;
68
      }
69
       
70
      if(!string.isBlank(fanMobile))
71
      {
72
        fan.Mobile_Phone__c=fanMobile;
73
      }
74
       
75
      if(!string.isBlank(fanFirstName))
76
      {
77
         fan.First_Name__c=fanFirstName;
78
    }
79
    public PageReference btn_profile_saveChanges()
80
    {
81
        SaveValues();
82
        return null;
83
    }
84
}
85
 
86
<apex:page controller="PrefCenterCTRL"
87
           docType="html-5.0"
88
           showHeader="false" >
89
 
90
<apex:form>
91
 
92
         <apex:inputText value="{!fanEmail}" id="email_val"/>    
93
         <apex:inputText value="{!fanfirstname}" id="firstname"/> 
94
         <apex:inputText value="{!fanLastName}" id="lastname"/>
95
<apex:commandButton value="SAVE CHANGES"
96
                    action="{!btn_profile_saveChanges}" />
97
<apex:form>
98
</apex:page>
Please help me out.

Thanks
Krishna
 
Hello 
I have a custom object fan which has three fields, email , firstname and lastname , email field being mandatory.
first time when page  loads, I append an ID known as encryptedfanID to the browser URL , thereby it loads the respective values into the fields.
so this part is working fine
suppose if I do not append any ID to the URL and hit the save button without entering any valies then it throws error " ateempt to deference a null object" error.

a piece of code explaining the above is provided.
public class PrefCenterCTRL{

    //Profile Tab 
     public String fanLastName { get; set; }
    public String fanFirstName { get; set; }
    public String fanEmail { get; set; }    
    public String encryptedfanID{get;set;}
    public fan__c fan{get;set;}
   
public PrefCenterCTRL()
    {
     try
     {
        encryptedfanID=ApexPages.currentpage().getparameters().get('id');
        system.debug('@@@'+encryptedfanID);
        
        if(String.isBlank(ApexPages.currentPage().getParameters().get('id')))
        {
                ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.ERROR,'Error: Invalid Id.');
                ApexPages.addMessage(myMsg);
                return;
        }
        else
        {
          
          fetchfanvalues();
        }
        
      }
      catch(Exception e){
            ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.ERROR,e.getMessage());
            ApexPages.addMessage(myMsg);
            return;
      }   
    }

 public void fetchfanvalues()
    {
    try
    {
       fan=[SELECT id, Email__c,First_Name__c,Last_Name__c,
            FROM fan__c 
           WHERE Encrypted_ID__c=:encryptedfanID];
            
      
       if(!string.isBlank(fan.Email__c))
       {
            fan_email=fan.Email__c;
       }

       if(!string.isBlank(fan.First_Name__c))
       {
           fanFirstName=fan.First_Name__c;
       }
       
       if(!string.isBlank(fan.Last_Name__c))
       {
           fanLastName=fan.Last_Name__c;
       }
  }

 public void SaveValues()
    {
               
      if(!string.isBlank(fan_email))
      {
       fan.Email__c=fan_email;
      }
      
      if(!string.isBlank(fanMobile))
      {
        fan.Mobile_Phone__c=fanMobile;
      }
      
      if(!string.isBlank(fanFirstName))
      {
         fan.First_Name__c=fanFirstName;
    }
    public PageReference btn_profile_saveChanges()
    {
        SaveValues();
        return null;
    }
}

<apex:page controller="PrefCenterCTRL" 
           docType="html-5.0" 
           showHeader="false" >

<apex:form>

         <apex:inputText value="{!fanEmail}" id="email_val"/>     
         <apex:inputText value="{!fanfirstname}" id="firstname"/>  
         <apex:inputText value="{!fanLastName}" id="lastname"/> 
<apex:commandButton value="SAVE CHANGES"
                    action="{!btn_profile_saveChanges}" />
<apex:form>
</apex:page>
I hope I am pretty clear, I request the forum membets to kndly help me out.

thanks
JohnD
 
Hi,
I am getting error:  ' Method does not exist or incorrect signature: [Messaging.SingleEmailMessage].setToAddresses(String)'  in my email class which is as below:

 List<Messaging.SingleEmailMessage> sme = new List<Messaging.SingleEmailMessage>();
     for(case c: newList){
      Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
      email.setTemplateId('00X500000013avG');
      email.setToAddresses(insideSalesEmailMap.get(c.accountId));
      email.targetObjectId(c.id);
      email.setSaveAsActivity(false);
      sme.add(email);
     }

Please help with the same.
HI,

I need to do activate or deactivate portal community users based on contact record checkbox field.

if the check is ture then that contact can be have access on portal community or else can't become a portal user

kindly share your thoughts nd way of approch 

thanks
I have created custom field on lead object with 
Forumla return type :text
Using below formula
CASE (MOD (TODAY () - DATE (1900, 1, 7), 7), 0, "Sunday", 1, "Monday", 2, "Tuesday", 3,"Wednesday", 4, "Thursday", 5, "Friday", 6, "Saturday”, “Error",NULL)
But issue is iam getting only TUESDAY as answer . please let me know where Iam wrong .
Thanks in Advance.


 
Hello,

In apex, How to check if the account has not contacts in it ?

 
  • November 10, 2016
  • Like
  • 0
public class CoverSheet {

    
    Public List<String> AttTo = new List <String>();
    AttTo.add('Test Pre-Cert');
    AttTo.add('Jim Waller Pre-Cert');
    AttTo.add('Eileen Fitzpatrick');
        
    public String[] To = New String[3];
    To.add('Pre-Cert Company');
    To.add('Regence Behaviorial Health');
    To.add('Blue Cross Federal');
    
}

What in the world am I doing wrong,   I have tried everything

Line 5: expecting a right parentheses, found 'Test Pre-Cert'
I want to add opportunity Amount to related account AnnualRevenue automatically and i want to remove the Opportunity amount from Account AnnualRevenue when opportunity gets deleted. And I want to update Account AnnualRevenue with updated opportunity amount.To achieve this i am getting following error "Invalid foreign key relationship: Account.Opportunities" could any one please resove this issue.I hope I will get correct code.

This is my trigger:
trigger addoppAmounttoAcct on Opportunity (After insert, After update) {
    public decimal amount=0;
    Map<id,integer> oppmap=new Map<id,integer>();
    List<Account> acc=new List<Account>();
    List<Account> a=[SELECT Id,Name,AnnualRevenue,(SELECT Id,Name, Amount FROM Opportunities) FROM Account];
    if(trigger.isInsert){
    set<Id> oppids=trigger.newMap.keySet();
    Map<Id,Integer> accmap=new Map<Id,Integer>();
    //List<Account> a=[SELECT Id,Name,AnnualRevenue,(SELECT Id,Name, Amount FROM Opportunities) FROM Account];
    List<Opportunity> opplist=[SELECT Id, Name,Amount,Opportunity.AccountId FROM Opportunity WHERE Id IN:oppids];
    //List<Account> acc=new List<Account>();
    for(Account ac:a){
    for(Opportunity o:opplist){
        if(o.AccountId==ac.id){
          ac.AnnualRevenue=ac.AnnualRevenue+o.Amount;
            acc.add(ac);
       }else{
           oppmap.put(o.Id, 1); 
        }
     }
  }
    update acc;
        }
 if(trigger.isUpdate){
   set<Id>updateids=trigger.newMap.keySet();
     List<Opportunity> opplistids=[SELECT Id, Name, Opportunity.AccountId,Opportunity.Account.AnnualRevenue, Amount FROM Opportunity WHERE Id IN:updateids];
        for(Opportunity upopp:opplistids){
            for(Account aid:a){
            if(upopp.AccountId==aid.Id){
                amount=upopp.Amount;
                aid.AnnualRevenue=aid.AnnualRevenue-aid.Opportunities.Amount;// here i am getting error like "Invalid foreign key relationship: Account.Opportunities"
                amount=aid.AnnualRevenue;
              aid.AnnualRevenue=amount+upopp.Amount;
                acc.add(aid); 
                }
            } 
        }
        update acc;
    }

Here my intension is to add opportunity amount to account Annual revenue after inserting the opportunity. And update the Annual revenue with updated  opportunity Amount. when i try to inserting opportunity there is no issue. When i try to perform update opportunity amount the previous amount and updated amount both will be added to the account Annualrevenue but my intension is to update only current updated Amount and remove previous amount from the Account AnnualRevenue.
Example:
i have one Account i.e' account1' if Icreate opportunity i.e 'account1opportunity' for this account with amount as 2000 the account1 Annual revenue is updated as 2000 this is fine, but if update account1opportunity with 4000 the related account1 AnnualRevenue is updated with previous amount i.e, 2000 plus updated Amount 4000 i.e  Annual revenue will be updated as 6000 according to my code. But I want to remove previous 2000 amount and update AnnualRevenue with current updated Amount i.e Annual revenue should be 4000.
Hi,

I have an issue with PDF content as we have created an autmation process where we have created quick action on opportunity tab which is creating  quotes and quotelineitem and then redirecting to another VF page having Quote as standard controller and generating PDF. We are not getting the whole content in the attached on Quote Object whose id we are passing in attachment in the below part of code.

We are calling attachQuote method from action of a VF page(Parent) :

 /* The action method that will generate a PDF document from the QuotePDF page and attach it to 
       the quote provided by the standard controller. Called by the action binding for the attachQuote
       page, this will do the work and take the user back to the quote detail page. */
        public PageReference attachQuote() {
        /* Get the page definition */
        PageReference pdfPage = Page.quotePDF;
        
        /* set the quote id on the page definition */
        pdfPage.getParameters().put('id',q.id);
        Blob  pdfBlob;
        /* generate the pdf blob */
        if(test.isRunningTest())
        {
        pdfBlob =Blob.valueof('UNIT.TEST');
        }
        else
        pdfBlob = pdfPage.getContent();
        
        System.Debug('Checking ID 1 : ' + q.id);
        /* create the attachment against the quote */
        Attachment a = new Attachment(parentId = q.id, name=q.Quote_Number__c+'.pdf', body = pdfBlob,contentType = 'application/pdf',isPrivate=false);      
        /* insert the attachment */
        System.Debug('Checking ID 2 : ' + q.id);
        insert a;
       
   return controller.view();      
    }
    
Please let me know if anything is required and please do suggest as we are using getContent() but the data is not there in it, although i am fetching the Quoteid.

Thanks,
Soumya
Hi Expert,

iam getting error when executing the trigger.

scenerio-  update the field " project risk count" of child object "Project Portfolio" with the field "risk count" of parent object "Project".

Class-

public class updateProjectRiskCount 
{
  
  public static List<CloudbyzITPM__Project__c> affectedRiskCount = new List<CloudbyzITPM__Project__c>();
  public static set<ID> affc = new set<ID>();
    

  public static void processAfterUpdateRiskCount()
 {
     affectedRiskCount = (List<CloudbyzITPM__Project__c>)Trigger.New;
     if(affectedRiskCount.size()>0){
     for(CloudbyzITPM__Project__c  affc1 : affectedRiskCount)
     {
      affc.add(affc1.id);
     }
     }
      
    CloudbyzITPM__Project_Portfolio__c fn = [select id,name,CloudbyzITPM__Project_Risk_Count__c from CloudbyzITPM__Project_Portfolio__c where id in: affc limit 1];
    list<CloudbyzITPM__Project__c> affectedRiskCount1 = [select id, name,CloudbyzITPM__Project_Portfolio__c,CloudbyzITPM__Risk_Count__c from CloudByzITPM__Project__c where CloudbyzITPM__Project_Portfolio__c = :fn.id];
      
      Decimal i=0;
       
    if(affectedRiskCount1.size()>0)
       {
           for(CloudbyzITPM__Project__C afc1 : affectedRiskCount1)
        {
            i = i + afc1.CloudbyzITPM__Risk_Count__c;
        }
    }
    
 if(i>0)
 {
     System.debug('@@pBUFinal@@');
    fn.CloudbyzITPM__Project_Risk_Count__c = i;
    }
     update fn; 
      System.debug('@@fn4@@'+fn);
    }
  
  }


Trigger- 

Trigger UpdateRC2 on CloudbyzITPM__Project__c (before insert, before update, before delete, after insert, after update, after delete)
{
  if((Trigger.isInsert || Trigger.isUpdate) && Trigger.isAfter)
      
  {
      updateProjectRiskCount.processAfterUpdateRiskCount();
  }
}

Note- i have written 4 triggers on the same object "project". 

Screenshot attached.

User-added image

 
hi. 
when I fill details on my   page  & click on save button the input fields is not get refreshed means data is still there  but data is saved to the database how to refresh the visual force page fields blank  ?  
Hi all, I have on object like Notification in this object i have one picklist field i,e status , in this  status picklist having pending,sent,complete values.So i want to delete status = complete records based on startdate and enddate of record.can u please anyone give me some sample code.
Thanks in advance