• hisalesforce
  • NEWBIE
  • 85 Points
  • Member since 2012

  • Chatter
    Feed
  • 3
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 39
    Replies

Hi all!  Anyone have any ideas on this?

 

I have a forecasting function button in the Opportunity called Establish Schedule that is generating the following error:

 

Visualforce Error


System.NullPointerException: Attempt to de-reference a null object

 

Class.EstablishScheduleController.__sfdc_FirstDate: line 20, column 1
Class.EstablishScheduleController.__sfdc_Year1: line 232, column 1
Class.EstablishScheduleController.__sfdc_Year2Len: line 250, column 1     

 

Here are the lines.  I can't paste the entire code because this site won't let me post that many characters.

 

20)       return objOpportunity.Est_Scheduled_Start_Date__c.toStartOfMonth();

232)     return String.valueOf(FirstDate.year());

250)         if (Year1 == Year2) return 0;

 

I'd be happy to provide the entire code via email or any other means if you can help out.  Thanks!!

hi all,

 

how to avoid the soql stmts inside the for loop in this class. plz help me.

 

public class assigncandidatestatusemailalert
{

public void SendEmail()
{

List<UserRole> UsersRoleList = new List<UserRole>([Select Id, Name from UserRole where Name = 'Vice President' or Name = 'Business Development Manager' or Name ='Management Representative' or Name ='Business Development Executive']);

System.debug('UserList123:' + UsersRoleList );

for(UserRole UsersRoleList123 :UsersRoleList)
{
List<User> UsersList = new List<User>([ SELECT Id, Name, Email FROM User where IsActive = true and UserRoleId = : UsersRoleList123.Id]);

System.debug('userlist1234' + UsersList);

for ( User userlist1 : UsersList )
{
List<Candidate_Mapping__c> candidatemappinglist = new List<Candidate_Mapping__c>( [SELECT Candidate__r.Candidate_Full_Name__c,Requirement__r.Name,Requirement__r.Job_Title__c, Requirement__r.Opportunity_Code__c, Requirement__r.CreatedDate,status1__c,Req_Owner_Email__c,Requirement_Owner__c FROM Candidate_Mapping__c where Submitted_to_Client__c ='' and status1__c = 'approved' and LastModifiedBy.Id = : userlist1.Id and LastModifiedDate = Last_n_days : 14]);

system.debug('candidatemappinglist :' + candidatemappinglist );

String htmlBody ;

Messaging.SingleEmailMessage mail;

htmlBody ='Dear '+userlist1 .Name+',</br></br>';

htmlBody =htmlBody +'<table style="border: 1px solid black;border-collapse:collapse;"><tr><td style="border: 1px solid black;"><b>Candidate</b> </td><td style="border: 1px solid black;"><b>Requirement</b> </td><td style="border: 1px solid black;"><b>Requirement Code</b></td><td style="border: 1px solid black;"><b>Client Name</b></td><td style="border: 1px solid black;"><b>Requirement Created Date</b></td></tr>';


for (Candidate_Mapping__c cm :candidatemappinglist )
{
htmlBody = htmlBody + '<tr><td style="border: 1px solid black;">'+cm .Candidate__r.Candidate_Full_Name__c+'</td><td style="border: 1px solid black;">'+cm.Requirement__r.Name+'</td><td style="border: 1px solid black;">'+cm.Requirement__r.Opportunity_Code__c+'</td><td style="border: 1px solid black;">'+cm.Requirement__r.Job_Title__c+'</td><td style="border: 1px solid black;">'+cm.Requirement__r.CreatedDate+'</td></tr>';

}

htmlBody = htmlBody +'</table></br>Either it is yet to be submitted to the client or the details are not updated in the EZRE system.</br> Please close this action item asap. </br></br>Regards</br>EZRE Team';

mail = new Messaging.SingleEmailMessage();

String[] address = new String[]{userlist1.Email};
mail.setToAddresses(address);
mail.setHtmlBody(htmlBody );
mail.setSubject('Submitted to client alert');
String[] bccaddress = new String[]{'abinaya_s@preludesys.com'};
mail.setBccAddresses(bccaddress);
mail.saveAsActivity = false;
if( candidatemappinglist.size() > 0 )
{

Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
}
}

}
}
}

  • September 18, 2013
  • Like
  • 0

 

 

public  class calculator1{

public integer num1{get;set;}
public integer num2{get;set;}
public integer num3{get;set;}

 
 
public void add(){
num3=num1+num2;
//EmailConformation1 E=new EmailConformation1();
//E.sendMail();
}
}

 

When i submit a record for approval, a mail will be triggered to the Approver with link to the record.I am creating a salesforce sites to open that link.
 For this requirement, I  need to pass a url value on force.com sites, so different view can be generated from different link.
 

Testclass
public class TestSendOpportunity{ public static testMethod void testBatchClass() { Account myaccount=new Account(name='Account name'); insert myaccount; Account acount=new Account(name='test'); insert acount; Account acc=[Select id from account where name='ABC' limit 1]; RecordType rcc=[SELECT id FROM RecordType where name='Managed Service']; Opportunity opp=new opportunity(name='test1',Accountid=acount.id); opp.distributor__c=acc.id; insert opp; List<PartnerNetworkConnection> connMap=[select Id, ConnectionStatus, ConnectionName from PartnerNetworkConnection where ConnectionStatus = 'Accepted' and connectionname='ACA']; List<PartnerNetworkRecordConnection> lstShareRecords= new List<PartnerNetworkRecordConnection>(); for(PartnerNetworkConnection network : connMap) { PartnerNetworkRecordConnection newrecord = new PartnerNetworkRecordConnection(); newrecord.ConnectionId = network.Id; newrecord.LocalRecordId = opp.accountid; newrecord.SendClosedTasks =false; newrecord.SendOpenTasks = false; newrecord.SendEmails = false; lstShareRecords.add(newrecord); } insert lstshareRecords; List<Opportunity> lstopp=new List<Opportunity>(); lstopp.add(opp); System.debug('HaHa list of Opportunity'+opp); SendOpportunity sendopp=new SendOpportunity();
public class SendOpportunity
{
List<Id> OpportunitySharingId=new List<ID>();
        public void sendrec(list<Opportunity> Opp)
        {
            Account act=new Account();
            
            act=[Select id from account where name='ACA' limit 1];
           
            List<PartnerNetworkRecordConnection> lstShareRecords = new List<PartnerNetworkRecordConnection>();
            
            List<PartnerNetworkConnection> connMap=[select Id, ConnectionStatus, ConnectionName from PartnerNetworkConnection
                    where ConnectionStatus = 'Accepted' and connectionname='ACA'  ];
     
            List<Opportunity> opportunitysharing=new List<Opportunity>();
           List<PartnerNetworkRecordConnection> allRecordShared=[select Id, Status, ConnectionId, LocalRecordId from PartnerNetworkRecordConnection where status='Sent'
             //This is the reason of my test coverage...
Since opportunity created in test class status ='Pending' so it is pulling coverage low                                            ];
          
           
              for(Opportunity o:Opp)
              {
                  for(PartnerNetworkRecordConnection PNRC:allRecordShared)
                      {
                          if(o.AccountId==PNRC.LocalRecordID)
                              {
                                      opportunitysharing.add(o);
                                      OpportunitySharingId.add(o.id);
                              
                              }
                      }
              
              }   
              
      List<PartnerNetworkRecordConnection> recordConns = new List<PartnerNetworkRecordConnection>([select Id, Status, 
      ConnectionId, LocalRecordId from PartnerNetworkRecordConnection where LocalRecordId in :OpportunitySharingId]);

      
                    for(PartnerNetworkConnection network : connMap) 
                    {    
                        for(Opportunity O:opportunitysharing)
                        {
                        //object declaration for PartnerNetwork
                        PartnerNetworkRecordConnection newrecord = new PartnerNetworkRecordConnection();
                       
                        newrecord.ConnectionId = network.Id;
                        newrecord.LocalRecordId = o.id;  
                        newrecord.ParentRecordId=o.accountid;
                        newrecord.SendClosedTasks =false;
                        newrecord.SendOpenTasks = false;
                        newrecord.SendEmails = false;
                        //All the Records are added to the PartnerNetwork
                        lstShareRecords.add(newrecord);
                        }
                   }
              
            
              insert lstShareRecords;
        }
}

 

sendopp.sendrec(lstopp); }

  List<PartnerNetworkRecordConnection> allRecordShared=[select Id, Status, ConnectionId, LocalRecordId from PartnerNetworkRecordConnection where status='Sent'

From this line:

allRecordshared is empty since Account shared in test class status is pending .

Because somebody has to accept it and since its a test class Noboby will accept.

 

How to make allrecordshared status ='sent'

 

Pleas help me....

Hey, 

I have written an Apex class and Visual Force page which searches the records from custom object. There is a field which is a multi pick list and it is a fielter field. User seletcs the value in that field and all the records meeting the critiriea appear in the 'Results' section. This page has 3 buttons "Search", "Cancel" and "Export to CSV". I am not good in writing a test class but I tried to write some and it is not giving my desired code coverage. Can someone pleae help me out ? Any help will be appreciated

Apex class:
public class Fetchsiteplacement{
String devicetype;
 
   public Site_Placements__c  sp{get;set;}
    public List<Site_Placements__c > spRec{get;set;}
    public List<Site_Placements__c > spRec1{get;set;}
    public List<siteplacementwrapper> spwrapper{get;set;}
    public List<siteplacementwrapper> spwrapperexcel{get;set;}    

    public class siteplacementwrapper{
            
           
            public String Name {get;set;}
           }
        public Fetchsiteplacement(){
        sp=new Site_Placements__c ();
        spRec = new List<Site_Placements__c>();
        
        }
        
         public void FillAggregates(){
          String devicetype= '';
         string[] lststr1=sp.Device_Type__c.split(';');
            
 for (String s1: lststr1) {
                            devicetype+= '\'' + s1 + '\',';
                                }
                   devicetype= devicetype.substring (0,devicetype.length() -1);

            spwrapper=new List<siteplacementwrapper>();
            spwrapperexcel=new List<siteplacementwrapper>();
                   
             String sitePlacementQuery ='SELECT Id,Name from Site_Placements__c WHERE Device_Type__c INCLUDES (' + devicetype + ')  ';
            spRec=database.query(sitePlacementQuery);
            
            String sitePlacementQuery1 ='SELECT Id,Name  from Site_Placements__c WHERE Device_Type__c INCLUDES (' + devicetype + ')  ';
            spRec1=database.query(sitePlacementQuery1);
            
             if(spRec.size() == 0)
                {
                        Apexpages.addMessage(new ApexPages.Message(ApexPages.Severity.INFO,''+'No records match your criteria'));
                } 
             else {
             
              for(Site_Placements__c sitePlacement:spRec){
              
               siteplacementwrapper spr=new siteplacementwrapper();
               
               
              spr.Name=sitePlacement.Name;
              spwrapper.add(spr);
              }  
             
             for(Site_Placements__c sitePlacement:spRec1){
              
              siteplacementwrapper spr=new siteplacementwrapper();
               
              spr.Name=sitePlacement.Name;
             
              spwrapperexcel.add(spr);
             
             
             
             }
             
             }
         }  
                
                
        public PageReference FetchExcelReport() {
        PageReference nextpage = new PageReference('/apex/RFP_Excel_Page');
return nextpage;
}
         
         public pagereference CancelSPRec(){
     
    PageReference page = new PageReference('https://c.cs30.visual.force.com/apex/SiteListPage');
    page.SetRedirect(true);
    return page;
    }}

Visual Force Page:

<apex:page controller="Fetchsiteplacement" tabStyle="Site_Placements__c" sidebar="false">
<apex:form >
     
     <apex:pageBlock >
        <apex:messages layout="table" styleClass="exceptionText"/>
             <apex:pageBlockButtons location="Bottom">
          
            <apex:commandButton value="Search" action="{!FillAggregates}"/>
            <apex:commandButton value="Reset" action="{!CancelSPRec}"/>
            <apex:commandButton value="Export to CSV" action="{!FetchExcelReport}" id="theButton" />
            </apex:pageBlockButtons>
           
           <apex:pageBlockSection title="Select your filter criteria" collapsible="False">
             <apex:pageBlockSectionItem >
                    <apex:outputLabel value="Player - Device Type" for="Devicetype"/>
                    <apex:inputField value="{!sp.Device_Type__c}" id="Devicetype"/>
                    
                </apex:pageBlockSectionItem>
                
                <apex:pageBlock >
            <apex:pageBlockSection title="Site List Results" collapsible="False">
            <apex:pageBlockSectionItem >
            
                <apex:pageblockTable value="{!spwrapper}" var="site" style="width:150%">
                   <apex:column style="width:650px"> <apex:facet name="header">Name</apex:facet>{!site.Name}</apex:column>
                   
                  </apex:pageBlockTable>
                 </apex:pageBlockSectionItem>
                 
           </apex:pageBlockSection>
           
</apex:pageblock> 
                 
                 </apex:form>
</apex:page>

Test Class:

@isTest(seeAllData=true)
private class TestFetchsiteplacement {

    static testMethod void myUnitTest() {
        // TO DO: implement unit test
        Account a = new Account(Name='Test Account');
      insert a;

Publisher_Deal_Types__c pubdeal = new Publisher_Deal_Types__c ( Name = 'Test Publisher deal type', Account_Name__c = a.Id);
        
        insert pubdeal;
        
        
        Site_Placements__c sp = new Site_Placements__c ();
        sp.Name = 'Test site placement';
        insert sp;
      
      PageReference ref = new PageReference('/apex/SiteListPage');
      
      
    Test.setCurrentPage(ref);
 
    Test.startTest();
    Fetchsiteplacement myController = new Fetchsiteplacement();
    Test.stopTest();
 }
}

Hi Everyone,

                              I am new to apex so this should be a simple question. I have a custom object with string fields. No duplicate should occur in any of these fields(before insert and before update).

                              I just want to add the duplictes to a list and in the end allow insert only if the list is NULL.

  • September 24, 2013
  • Like
  • 0

Hi all!  Anyone have any ideas on this?

 

I have a forecasting function button in the Opportunity called Establish Schedule that is generating the following error:

 

Visualforce Error


System.NullPointerException: Attempt to de-reference a null object

 

Class.EstablishScheduleController.__sfdc_FirstDate: line 20, column 1
Class.EstablishScheduleController.__sfdc_Year1: line 232, column 1
Class.EstablishScheduleController.__sfdc_Year2Len: line 250, column 1     

 

Here are the lines.  I can't paste the entire code because this site won't let me post that many characters.

 

20)       return objOpportunity.Est_Scheduled_Start_Date__c.toStartOfMonth();

232)     return String.valueOf(FirstDate.year());

250)         if (Year1 == Year2) return 0;

 

I'd be happy to provide the entire code via email or any other means if you can help out.  Thanks!!

hi all,

 

how to avoid the soql stmts inside the for loop in this class. plz help me.

 

public class assigncandidatestatusemailalert
{

public void SendEmail()
{

List<UserRole> UsersRoleList = new List<UserRole>([Select Id, Name from UserRole where Name = 'Vice President' or Name = 'Business Development Manager' or Name ='Management Representative' or Name ='Business Development Executive']);

System.debug('UserList123:' + UsersRoleList );

for(UserRole UsersRoleList123 :UsersRoleList)
{
List<User> UsersList = new List<User>([ SELECT Id, Name, Email FROM User where IsActive = true and UserRoleId = : UsersRoleList123.Id]);

System.debug('userlist1234' + UsersList);

for ( User userlist1 : UsersList )
{
List<Candidate_Mapping__c> candidatemappinglist = new List<Candidate_Mapping__c>( [SELECT Candidate__r.Candidate_Full_Name__c,Requirement__r.Name,Requirement__r.Job_Title__c, Requirement__r.Opportunity_Code__c, Requirement__r.CreatedDate,status1__c,Req_Owner_Email__c,Requirement_Owner__c FROM Candidate_Mapping__c where Submitted_to_Client__c ='' and status1__c = 'approved' and LastModifiedBy.Id = : userlist1.Id and LastModifiedDate = Last_n_days : 14]);

system.debug('candidatemappinglist :' + candidatemappinglist );

String htmlBody ;

Messaging.SingleEmailMessage mail;

htmlBody ='Dear '+userlist1 .Name+',</br></br>';

htmlBody =htmlBody +'<table style="border: 1px solid black;border-collapse:collapse;"><tr><td style="border: 1px solid black;"><b>Candidate</b> </td><td style="border: 1px solid black;"><b>Requirement</b> </td><td style="border: 1px solid black;"><b>Requirement Code</b></td><td style="border: 1px solid black;"><b>Client Name</b></td><td style="border: 1px solid black;"><b>Requirement Created Date</b></td></tr>';


for (Candidate_Mapping__c cm :candidatemappinglist )
{
htmlBody = htmlBody + '<tr><td style="border: 1px solid black;">'+cm .Candidate__r.Candidate_Full_Name__c+'</td><td style="border: 1px solid black;">'+cm.Requirement__r.Name+'</td><td style="border: 1px solid black;">'+cm.Requirement__r.Opportunity_Code__c+'</td><td style="border: 1px solid black;">'+cm.Requirement__r.Job_Title__c+'</td><td style="border: 1px solid black;">'+cm.Requirement__r.CreatedDate+'</td></tr>';

}

htmlBody = htmlBody +'</table></br>Either it is yet to be submitted to the client or the details are not updated in the EZRE system.</br> Please close this action item asap. </br></br>Regards</br>EZRE Team';

mail = new Messaging.SingleEmailMessage();

String[] address = new String[]{userlist1.Email};
mail.setToAddresses(address);
mail.setHtmlBody(htmlBody );
mail.setSubject('Submitted to client alert');
String[] bccaddress = new String[]{'abinaya_s@preludesys.com'};
mail.setBccAddresses(bccaddress);
mail.saveAsActivity = false;
if( candidatemappinglist.size() > 0 )
{

Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
}
}

}
}
}

  • September 18, 2013
  • Like
  • 0

 

 

public  class calculator1{

public integer num1{get;set;}
public integer num2{get;set;}
public integer num3{get;set;}

 
 
public void add(){
num3=num1+num2;
//EmailConformation1 E=new EmailConformation1();
//E.sendMail();
}
}

 

Hello,

 

I want to delete 500+ custom fields. Is there any solution to mass remove custom fields? I have tried with metadata Api using below code. But it gives me below error.

 

Object with id:04s900000037qo4AAA is InProgress
Error status code: INVALID_CROSS_REFERENCE_KEY
Error message: In field: members - no CustomField named Custom_Field__c found
Object with id:04s900000037qo4AAA is Error

 

Below is the code:

 


    public void deleteCustomField(String fullname) throws Exception
    {
        CustomField customField = new CustomField();
        customField.setFullName(fullname);
        
        UpdateMetadata updateMetadata = new UpdateMetadata();
        updateMetadata.setMetadata(customField);
        updateMetadata.setCurrentName(fullname);
        
        AsyncResult[] asyncResults  = metadataConnection.delete(new Metadata[] {customField});
 
        long waitTimeMilliSecs = ONE_SECOND;
 
        do
        {
            printAsyncResultStatus(asyncResults);
            waitTimeMilliSecs *= 2;
            Thread.sleep(waitTimeMilliSecs);
            asyncResults = metadataConnection.checkStatus(new String[]{asyncResults[0].getId()});
        } while (!asyncResults[0].isDone());
 
        printAsyncResultStatus(asyncResults);
    }

 


    private void printAsyncResultStatus(AsyncResult[] asyncResults) throws Exception {
        if (asyncResults == null || asyncResults.length == 0 || asyncResults[0] == null) {
            throw new Exception("The object status cannot be retrieved");
        }

        AsyncResult asyncResult = asyncResults[0]; //we are creating only 1 metadata object

        if (asyncResult.getStatusCode() != null) {
            System.out.println("Error status code: " +
                    asyncResult.getStatusCode());
            System.out.println("Error message: " + asyncResult.getMessage());
        }

        System.out.println("Object with id:" + asyncResult.getId() + " is " +
            asyncResult.getState());
    }

 

Is there any other solution (any app) to removing custom fields?

 

Thanks in advance,

 

Dhaval Panchal

Hello,

I am new to salesforce,,

I want to divide the visualforce page into partions like..two verticle and three horizontal ..

please provide one example for my requirement...

I want to get 6pm of any time zone. and then convert into PST.

For example 6pm on EST will become 3PMPST. 6PM Germany time will become 9am PST.

Also I want to take care of day light saving.

 

Thanks in advance

In my Validation Rule I am referring to an Opportunity field. The Opportunity is a grandparent to the record. My Validation Rule looks like this :

ISPICKVAL( Parent__r.Opportunity__r.Product__c,"")

 

The Validation Rule works fine. But it is still kicking off when I run my test code which is populating that field :

@isTest
private class testProjectInitiationTrigger {

    static testMethod void ProjectInitiationTriggerTest() {

        Account account = TestHelper.createAccount();
        Opportunity objOpp = TestHelper.createOpp(account);
        objOpp.Manager__c = objOpp.CreatedById;
        objOpp.Product__c = 'test';
        update objOpp;

        //this is the parent record being created
        Project__c objC = TestHelper.createCBC(objOpp);
        objC.Supplier__c = 'Test Supplier';
        update objC;

        //this is the child record which the trigger will run off
        Initiation__c oPI = new Initiation__c();
        oPI.Name =  objC.Name;
opI.Employee__c = opI.CreatedById; oPI.Parent__c = objC.Id; insert oPI; //this is the child record field which will initiate the post update trigger oPI.Initiate_Implementation__c = true; update oPI; } }

 
Why is the Validation Rule for the Opptunity Product__c field still kicking off when I run this test code ?

Thank you for any help.

  • August 16, 2013
  • Like
  • 0

Hello,

 

We have Created By and Last Modified By fields by default but Is there any way in salesforce that we can create Last Accessed By using some sort of Session or custom APEX code.

 

Thanks!



Hello,

 

I was wondering.  If I wish to set a specific visualforce page for when maintenance is occuring how can I test this out once I add it without having to wait for a Salesforce Maintenance window?

 

Thanks in advance for any help on this.

I have two buttons on the contact screen.  Log a Call and Log a Meeting.  When these are selected the corresponding screen to log a call or meeting comes up.

Upon saving the call or meeting a trigger is called on insert /update/delete.  This trigger updates a Status field on the contact record.  The updates works however, the contact screen will not show this field as updated until I hit F5.   I have reproduced this in Both FireFox and Chrome.

 

Thanks in advance for your help.

Lawrence

  • July 10, 2013
  • Like
  • 0

Hi,


I have the below requirement.

 

When i submit a record for approval, a mail will be triggered to the Approver with link to the record.

Current procedure is The Approver has to login to company portal(Not SFDC username and password) and then click on SFDC link to login to salesforce(Single Sign On) and then he should redirect to the actual record to Approve/Reject.

 

Actual Requirement: When he clicks on the link it should redirect to the company portal where he login to the portal by his username and password(Not SFDC username and password). once he login, he should directly view the record which is submitted for approval. (i.e., he should be able to dynamically redirect to the record which is mentioned in the email).

How can we do this? Any idea, please suggest.

 

Thank you in Advance,
NHK

  • June 28, 2013
  • Like
  • 0

The page you submitted was invalid for your session. Please click Save again to confirm your change.

 

 

Description; In this case am calling an VF page in a section in that page am calling commandlink and outputlinks .it is working fine when it is uinmanaged packege but it failing after making packaged application i checked the name space it is fine in all the palce .Any body know about this issue please posst some clue to track it.

  • June 17, 2009
  • Like
  • 0