• Arup Sarkar
  • NEWBIE
  • 125 Points
  • Member since 2011

  • Chatter
    Feed
  • 5
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 20
    Questions
  • 15
    Replies

Hi,


We have the following scenario where user will enter few fields, the value of the fields need to be validated from back office where the data exists. The data will be available via web services. Imagine a user is putting a employee number in a field, when the user is tabbing out a callout whould happen.the number will be passed to the callout and a xml or json response will be generated. Depending on that further user action will proceed to fill in the form.

 

How can this functionality be achieved in using visualforce, javascript and apex ?

 

Any help will be appreciated.

 

 

Hi,

 

I am following the instruction as mentioned in the below URL:

 

http://www2.developerforce.com/mobile/getting-started/html5/#angularjs-heroku

 

Finally, when I am trying to deploy to heroku using the following command

 

git push heroku master

 I am getting the following error

 

Permission denied (publickey).
fatal: The remote end hung up unexpectedly

  I have already added the client_id generated after creating connected apps as mentioned.

 

Any help will be appreciated.

Hello,

 

I am using the following Apex Web Service class.

 

global class ContactWebService
{
    webservice static id CreateExternalContact(String LastName, String FirstName)
    {
        Contact contact = new Contact();
    
        contact.LastName = LastName;
        contact.FirstName = FirstName;
        insert contact;
        
        return contact.id;
    }
}

  I generated the WSDL and created another apex class using that WSDL, code pasted below.

 

//Generated by wsdl2apex

public class soapSforceComSchemasClassContactweb {
    public class LogInfo {
        public String category;
        public String level;
        private String[] category_type_info = new String[]{'category','http://soap.sforce.com/schemas/class/ContactWebService','LogCategory','1','1','false'};
        private String[] level_type_info = new String[]{'level','http://soap.sforce.com/schemas/class/ContactWebService','LogCategoryLevel','1','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://soap.sforce.com/schemas/class/ContactWebService','true','false'};
        private String[] field_order_type_info = new String[]{'category','level'};
    }
    public class CreateExternalContactResponse_element {
        public String result;
        private String[] result_type_info = new String[]{'result','http://soap.sforce.com/schemas/class/ContactWebService','ID','1','1','true'};
        private String[] apex_schema_type_info = new String[]{'http://soap.sforce.com/schemas/class/ContactWebService','true','false'};
        private String[] field_order_type_info = new String[]{'result'};
    }
    public class AllowFieldTruncationHeader_element {
        public Boolean allowFieldTruncation;
        private String[] allowFieldTruncation_type_info = new String[]{'allowFieldTruncation','http://www.w3.org/2001/XMLSchema','boolean','1','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://soap.sforce.com/schemas/class/ContactWebService','true','false'};
        private String[] field_order_type_info = new String[]{'allowFieldTruncation'};
    }
    public class DebuggingHeader_element {
        public soapSforceComSchemasClassContactweb.LogInfo[] categories;
        public String debugLevel;
        private String[] categories_type_info = new String[]{'categories','http://soap.sforce.com/schemas/class/ContactWebService','LogInfo','0','-1','false'};
        private String[] debugLevel_type_info = new String[]{'debugLevel','http://soap.sforce.com/schemas/class/ContactWebService','LogType','1','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://soap.sforce.com/schemas/class/ContactWebService','true','false'};
        private String[] field_order_type_info = new String[]{'categories','debugLevel'};
    }
    public class CallOptions_element {
        public String client;
        private String[] client_type_info = new String[]{'client','http://www.w3.org/2001/XMLSchema','string','1','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://soap.sforce.com/schemas/class/ContactWebService','true','false'};
        private String[] field_order_type_info = new String[]{'client'};
    }
    public class CreateExternalContact_element {
        public String LastName;
        public String FirstName;
        private String[] LastName_type_info = new String[]{'LastName','http://www.w3.org/2001/XMLSchema','string','1','1','true'};
        private String[] FirstName_type_info = new String[]{'FirstName','http://www.w3.org/2001/XMLSchema','string','1','1','true'};
        private String[] apex_schema_type_info = new String[]{'http://soap.sforce.com/schemas/class/ContactWebService','true','false'};
        private String[] field_order_type_info = new String[]{'LastName','FirstName'};
    }
    public class SessionHeader_element {
        public String sessionId;
        private String[] sessionId_type_info = new String[]{'sessionId','http://www.w3.org/2001/XMLSchema','string','1','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://soap.sforce.com/schemas/class/ContactWebService','true','false'};
        private String[] field_order_type_info = new String[]{'sessionId'};
    }
    public class DebuggingInfo_element {
        public String debugLog;
        private String[] debugLog_type_info = new String[]{'debugLog','http://www.w3.org/2001/XMLSchema','string','1','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://soap.sforce.com/schemas/class/ContactWebService','true','false'};
        private String[] field_order_type_info = new String[]{'debugLog'};
    }
    public class ContactWebService {
        public String endpoint_x = 'https://na3-api.salesforce.com/services/Soap/class/ContactWebService';
        public Map<String,String> inputHttpHeaders_x;
        public Map<String,String> outputHttpHeaders_x;
        public String clientCertName_x;
        public String clientCert_x;
        public String clientCertPasswd_x;
        public Integer timeout_x;
        public soapSforceComSchemasClassContactweb.SessionHeader_element SessionHeader;
        public soapSforceComSchemasClassContactweb.AllowFieldTruncationHeader_element AllowFieldTruncationHeader;
        public soapSforceComSchemasClassContactweb.CallOptions_element CallOptions;
        public soapSforceComSchemasClassContactweb.DebuggingHeader_element DebuggingHeader;
        public soapSforceComSchemasClassContactweb.DebuggingInfo_element DebuggingInfo;
        private String SessionHeader_hns = 'SessionHeader=http://soap.sforce.com/schemas/class/ContactWebService';
        private String AllowFieldTruncationHeader_hns = 'AllowFieldTruncationHeader=http://soap.sforce.com/schemas/class/ContactWebService';
        private String CallOptions_hns = 'CallOptions=http://soap.sforce.com/schemas/class/ContactWebService';
        private String DebuggingHeader_hns = 'DebuggingHeader=http://soap.sforce.com/schemas/class/ContactWebService';
        private String DebuggingInfo_hns = 'DebuggingInfo=http://soap.sforce.com/schemas/class/ContactWebService';
        private String[] ns_map_type_info = new String[]{'http://soap.sforce.com/schemas/class/ContactWebService', 'soapSforceComSchemasClassContactweb'};
        public String CreateExternalContact(String LastName,String FirstName) {
            soapSforceComSchemasClassContactweb.CreateExternalContact_element request_x = new soapSforceComSchemasClassContactweb.CreateExternalContact_element();
            soapSforceComSchemasClassContactweb.CreateExternalContactResponse_element response_x;
            request_x.LastName = LastName;
            request_x.FirstName = FirstName;
            Map<String, soapSforceComSchemasClassContactweb.CreateExternalContactResponse_element> response_map_x = new Map<String, soapSforceComSchemasClassContactweb.CreateExternalContactResponse_element>();
            response_map_x.put('response_x', response_x);
            WebServiceCallout.invoke(
              this,
              request_x,
              response_map_x,
              new String[]{endpoint_x,
              '',
              'http://soap.sforce.com/schemas/class/ContactWebService',
              'CreateExternalContact',
              'http://soap.sforce.com/schemas/class/ContactWebService',
              'CreateExternalContactResponse',
              'soapSforceComSchemasClassContactweb.CreateExternalContactResponse_element'}
            );
            response_x = response_map_x.get('response_x');
            return response_x.result;
        }
    }
}

 

Now I am executing the following code in Developer Console.

 

private Id testId;
soapSforceComSchemasClassContactweb.ContactWebService test = new       soapSforceComSchemasClassContactweb.ContactWebService();
        testId = test.CreateExternalContact('LExternal Contact', 'FExternal Contact');
    	System.debug('test id : ' + testId);

  I am getting the following error, how can I set the session header, I have no problem in creating the stub in java or .NET and it works, I want to make it work within salesforce framework

 

Error:

=============

Web service callout failed: WebService returned a SOAP Fault: INVALID_SESSION_ID: Invalid Session ID found in SessionHeader: Illegal Session faultcode=sf:INVALID_SESSION_ID faultactor=

Hi,

 

I have successfully integrated Twilio with salesforce, contacts can call the twilio number and get routed accordingly and speak to a company representative, also call and SMS can be made from salesforce.

 

What I am looking for is when an outside caller calls the twilio number a small popup window should display the contact's details.

 

How can I achieve this functionality? 

 

Architecture:

================

 

Triggering point: Visualforce Page, tied to a Apex Class.

The caller is requested to press "1" to speak to someone, right now the owner of the record is automatically called. (at this point the pop up window should be displayed. which is my requirement)

 

Page 1 is first invoked which is linked to a controller and the caller is greeted with name and directed to press a 1, when the caller presses 1 it is directed to Page 2 which automatically calls the owner of the contact record.

 

Page 1:

 

<apex:page controller="KVTwilioController" showheader="false" contentType="text/xml" 
  >{! '<?xml version=\"1.0\" encoding=\"UTF-8\"?>' }
    <Response>
        <Say>Hello {!name}</Say>
        <Say>Welcome to Neuberger Berman.</Say>

        <Gather  numDigits="1" action="KVTwilioHandleKeyPage" method="POST">
          <Say>To speak to a real person, press 1. Press any other key to start over.</Say>
        </Gather>

    </Response>
</apex:page>

 Controller controlling Page 1:

public class KVTwilioController {
 
  public KVTwilioController() {}
 
  /* return TwiML */
  public String getName() {
    // if the caller is known, then greet them by name
    // otherwise, consider them just another monkey
    String name = 'Hi';
    
    String fromPhone = ApexPages.currentPage().getParameters().get('From');
    if (fromPhone!=null) {
    
        System.debug('~~~~~~~~ KVTwilioController : fromPhone : ' + fromPhone);
    
      // remove the country prefix for Phone field search
      if (fromPhone.startsWith('+1'))
        fromPhone = fromPhone.substring(2);
    
      // search Lead and Contact phone number fields
      List<List<SObject>> results = [FIND :fromPhone IN Phone FIELDS
          RETURNING Contact(FirstName, LastName), Lead(FirstName, LastName)
          LIMIT 1];
    
      // extract the name if there’s a match
      if (!results[0].isEmpty()) {
        Contact r = (Contact)results[0][0];
        name = r.firstName + ' ' + r.lastName;
        
        System.debug('~~~~~~~~ KVTwilioController : Contact Name : ' + name);
        
      } else if (!results[1].isEmpty()) {
        Lead r = (Lead)results[1][0];
        name = r.firstName + ' ' + r.lastName;
        
        System.debug('~~~~~~~~ KVTwilioController : Lead Name : ' + name);
        
      }
    }
    return name;
  }
  
  // if the caller pressed anything but 1 send them back
    public PageReference getHandleUserInput() {
        PageReference p = new PageReference('/apex/KVTwilioHandleKeyPage');
        if (ApexPages.currentPage().getParameters().get('Digits') == '1'){
        }  
        return p;
    }
  
  
}

 Page 2:

<apex:page controller="KVTwilioHandleKeyController" showheader="false" contentType="text/xml"
  >{! '<?xml version=\"1.0\" encoding=\"UTF-8\"?>' }
    <Response>
        <Dial>{!dialNumber}</Dial>
        <Gather action="KVPopUpPage" />
        <Say>The call failed or the remote party hung up. Goodbye.</Say>
    </Response>
</apex:page>

 Controller controlling page 2

public class KVTwilioHandleKeyController
{
  public String getDialNumber() {
    // if the caller is known, then find their owner's phone number
    String dialNumber;
    
    String fromPhone = ApexPages.currentPage().getParameters().get('From');
    if (fromPhone!=null) {
      // remove the country prefix for Phone field search
      if (fromPhone.startsWith('+1'))
        fromPhone = fromPhone.substring(2);
    
      // search Lead and Contact phone number fields
      List<List<SObject>> results = [FIND :fromPhone IN Phone FIELDS
          RETURNING Contact(Owner.Phone), Lead(Owner.Phone)
          LIMIT 1];
    
      // extract the owner phone if there’s a match
      if (!results[0].isEmpty()) {
        Contact r = (Contact)results[0][0];
        if (r.owner!=null && r.owner.phone!=null)
          dialNumber = r.owner.phone;
      } else if (!results[1].isEmpty()) {
        Lead r = (Lead)results[1][0];
        if (r.owner!=null && r.owner.phone!=null)
          dialNumber = r.owner.phone;
      }
    }
    return dialNumber;
  }
 
  // if the caller pressed anything but 1 send them back
  public String redirect() {
    if (ApexPages.currentPage().getParameters().get('Digits') != '1')
      return '/KVTwilioPage';
    return null;
  }  

}

 

 

 

Hi I have the following web service in Apex.

 

global class AccountWebService
{
    webService static Id makeAccount(String AccountName)
    {
        Account acct = new Account();
        acct.Name = AccountName;
        insert acct;
        return acct.Id;
    }

}

 I have created the following java client in java.

 

package com.nb.sfdc.ws.client;

import java.net.MalformedURLException;
import java.net.URL;
import java.rmi.RemoteException;

import org.apache.axis.AxisFault;

import com.sforce.soap.schemas._class.AccountWebService.AccountWebServiceBindingStub;
import com.sforce.soap.schemas._class.AccountWebService.AccountWebServiceServiceLocator;

public class TestWSClient {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		
		System.setProperty("http.proxyHost", "xxxxx");
		System.setProperty("http.proxyPort", "80");
		
		AccountWebServiceServiceLocator loc = new AccountWebServiceServiceLocator();
		try {
			URL url = new URL(loc.getAccountWebServiceAddress());
			AccountWebServiceBindingStub stub = new AccountWebServiceBindingStub(url,loc);
			stub.setUsername("xxxx");
			stub.setPassword("xxxx");
			stub.makeAccount("testing");
			
		} catch (MalformedURLException e) {
			// TODO Auto-generated catch block
			System.out.println("MalformedURLException: " + e.toString());
		} catch (AxisFault e) {
			// TODO Auto-generated catch block
			System.out.println("AxisFault: " + e.toString());
		} catch (RemoteException e) {
			// TODO Auto-generated catch block
			System.out.println("RemoteException: " + e.toString());
		}

	}

}

 I am getting the following error.

 

AxisFault: INVALID_SESSION_ID: Invalid Session ID found in SessionHeader: Illegal Session

 

Can someone please help me.

 

Hi I have the following web service in Apex.

 

global class AccountWebService
{
    webService static Id makeAccount(String AccountName)
    {
        Account acct = new Account();
        acct.Name = AccountName;
        insert acct;
        return acct.Id;
    }

}

 I have created the following java client in java.

 

package com.nb.sfdc.ws.client;

import java.net.MalformedURLException;
import java.net.URL;
import java.rmi.RemoteException;

import org.apache.axis.AxisFault;

import com.sforce.soap.schemas._class.AccountWebService.AccountWebServiceBindingStub;
import com.sforce.soap.schemas._class.AccountWebService.AccountWebServiceServiceLocator;

public class TestWSClient {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		
		System.setProperty("http.proxyHost", "xxxxx");
		System.setProperty("http.proxyPort", "80");
		
		AccountWebServiceServiceLocator loc = new AccountWebServiceServiceLocator();
		try {
			URL url = new URL(loc.getAccountWebServiceAddress());
			AccountWebServiceBindingStub stub = new AccountWebServiceBindingStub(url,loc);
			stub.setUsername("xxxx");
			stub.setPassword("xxxx");
			stub.makeAccount("testing");
			
		} catch (MalformedURLException e) {
			// TODO Auto-generated catch block
			System.out.println("MalformedURLException: " + e.toString());
		} catch (AxisFault e) {
			// TODO Auto-generated catch block
			System.out.println("AxisFault: " + e.toString());
		} catch (RemoteException e) {
			// TODO Auto-generated catch block
			System.out.println("RemoteException: " + e.toString());
		}

	}

}

 I am getting the following error.

 

AxisFault: INVALID_SESSION_ID: Invalid Session ID found in SessionHeader: Illegal Session

 

Can someone please help me.

 

Hi:

 

I would like to know what is the best possible approach to migrate data from production to sandbox on a regular basis. Once we refresh sandbox with production metadata the application data gets erased, we have a real challenge to bring the data back to sandbox with a specified timeframe.

 

Our Sandbox is not a full sandbox.

 

Regards,

Arup

Hi:

 

  1. I created a simple APEX web service class.
  2. Generated WSDL from the custom class.
  3. Created a Web Service client, in eclipse which generated stub, port and service locator class.

I already have enterprise.jar in my build path. When I am running it I am getting an error. Can someone please let me know where I am going wrong, My connection is working fine. Checked it.

 

package com.nb.sfdc.client;

import java.net.MalformedURLException;
import java.net.URL;
import java.rmi.RemoteException;

import javax.xml.rpc.ServiceException;

import org.apache.axis.AxisFault;

import com.sforce.soap.enterprise.Connector;
import com.sforce.soap.enterprise.EnterpriseConnection;
import com.sforce.soap.enterprise.LoginResult;
import com.sforce.soap.enterprise.fault.LoginFault;
import com.sforce.soap.schemas._class.AccountWebService.AccountWebServiceBindingStub;
import com.sforce.soap.schemas._class.AccountWebService.AccountWebServiceServiceLocator;
import com.sforce.ws.ConnectionException;
import com.sforce.ws.ConnectorConfig;

public class TestAccountWebService {

	/**
	 * @param args
	 */
	
	static ConnectorConfig config = new ConnectorConfig();
	static EnterpriseConnection connection;		
	
	public static void main(String[] args) {
		//Create a salesforce service
		LoginResult loginResult;
		System.out.println("start of program");
		try{
			
			
			config.setNtlmDomain("xxxxxx.com");
			config.setProxy("xxxxxxx.xx.com", 80);
			config.setProxyUsername("xxxxxxxxx");
			config.setProxyPassword("xxxxxxxxx");
			config.setAuthEndpoint("https://login.salesforce.com/services/Soap/c/23.0");
			config.setUsername("xxxxxxxxxxxxxxxxxx");
			config.setPassword("xxxxxxxxxxxxxxxxxx");

			connection = Connector.newConnection(config);
			System.out.println("Connected to salesforce successfully.");
			System.out.println("Authorized End Point: " + config.getAuthEndpoint());
			System.out.println("Session Id : " + config.getSessionId());

			
			//Integrate Web Service
			AccountWebServiceServiceLocator service = new AccountWebServiceServiceLocator();
			try {
				service.getAccountWebService(new URL("https://login.salesforce.com/services/Soap/c/23.0"));
			} catch (ServiceException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			AccountWebServiceBindingStub stub = new AccountWebServiceBindingStub(new URL("https://login.salesforce.com/services/Soap/c/23.0"), service);
			stub.makeAccount("Testing web account");
			

            System.out.println("after call to getSoap()");			
			
		}catch(LoginFault ex){
			ex.printStackTrace();
		}catch(ConnectionException e){
			e.printStackTrace();
		}catch(AxisFault e){
			e.printStackTrace();
		}catch(RemoteException e){
			e.printStackTrace();
		}catch(MalformedURLException e){
			e.printStackTrace();
		}
		

	}

}

 I am getting the following error.

 

AxisFault
 faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException
 faultSubcode: 
 faultString: java.net.NoRouteToHostException: No route to host: connect
 faultActor: 
 faultNode: 
 faultDetail:

 

 

Hi:

 

I would like to create a Formula field which will show the full name of the Activity owner. How can I achieve it? I have tried

"Owner.Name" it is not working, I know there is a relationship between Task and Owner since in SOQL I can access Owner.Name.

 

Regards,

Arup

Hi I have attached the mail controller class file, I have written a corresponding test class, I am not getting code coverage beyond 88%. The red lines are on the following lines in the main class, I would like to increase my code coverage to 100% if possible.

 

        Messaging.EmailFileAttachment attach = new Messaging.EmailFileAttachment();
        attach.setContentType('application/pdf');
        attach.setFileName('Call Report.pdf');
        attach.setInline(false);
        attach.Body = body;        
        
        mail.setFileAttachments(new Messaging.EmailFileAttachment[] { attach }); 
        Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });

        PageReference p = new PageReference('/' + theId);
        return p;

 Main Class:

 

public class CallReportSendEmailClass {
 
    private final Call_Report_Summary__c t;
    
    public string sTo {get;set;}
    public string sSubject {get;set;}
    public string sBody {get;set;}
    public string sBehalf {get;set;}
    Public boolean Cancel {get;set;}

    List<String> NBContacts = new String[]{};
    String SelectedContacts = '';

    public List<Contact> TaskContact = new List<Contact>();

    public String accountName {get; set;}
    public Id accountId {get; set;}
    public List<Contact> contacts {get;set;}
    public String ConEmail {get;set;}
    public String cc {get;set;}
    public String sHtmlBody = '';
    
    
    public Date From_Date{get;set;}
    public Date To_Date{get;set;}
    Public String Account{get;set;}
    Public String Contact{get;set;}
    Public String User{get;set;}
    Public String Opportunity{get;set;}
    Public String DateRangeEquality{get;set;}
    Public String DateLiteral{get;set;}
    Public String EmailContactId{get;set;}
    Public String Email{get;set;}
    Public String Subject{get;set;}
    Public String EmailBody{get;set;}    
    Public String Region{get;set;}
    Public String Channel{get;set;}
    Public String SubChannel{get;set;}    
      
      
    public Call_Report_Summary__c EmailReportParams = new Call_Report_Summary__c();      
      
    public CallReportSendEmailClass(ApexPages.StandardController stdController) {
        this.t = (Call_Report_Summary__c)stdController.getRecord();
        
    }
    
    Public PageReference CancelEmail(){
        Cancel = true;
        String theId = ApexPages.currentPage().getParameters().get('id');
        PageReference p = new PageReference('/' + theId);
        return p;        
        
    }
 
    public PageReference SendEmail() {
    
    
 
        String theId = ApexPages.currentPage().getParameters().get('id');
        
        System.debug(' Call Report Template Id : ' + theId);
        
        PageReference pdf = new PageReference('/apex/CallReportDataComponentPage' + '?id=' + theId);
                
        if (accountName == null) {accountName = 'jayakumar.vadivelkarumbayiram@nb.com';}
        List<String> toaddress = accountName.split(';');                
                
        Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
        mail.setToAddresses(toaddress);
        

        
        mail.setsubject(sSubject);
        
        sHtmlBody = '<html>';
        sHtmlBody = sHtmlBody + '<head><title>Tutorial: HelloWorld</title></head><body>';
        //sHtmlBody = sHtmlBody + '<table>';
            
        if (sBody != null ) {
            sBody = sBody.replace('\n', '<br>');
        }
        sHtmlBody = sHtmlBody + sBody;
        sHtmlBody = sHtmlBody + '</body></html>';
        mail.setHtmlBody(sHtmlBody);

                
        
        Blob body;
        body = pdf.getContent();
        Messaging.EmailFileAttachment attach = new Messaging.EmailFileAttachment();
        attach.setContentType('application/pdf');
        attach.setFileName('Call Report.pdf');
        attach.setInline(false);
        attach.Body = body;        
        
        mail.setFileAttachments(new Messaging.EmailFileAttachment[] { attach }); 
        Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });

        PageReference p = new PageReference('/' + theId);
        return p;
    }
    
    public List<selectOption> getItems() {
        List<selectOption> options = new List<selectOption>();
        for (Contact nbcontactsall : [SELECT Email FROM Contact ORDER BY Email LIMIT 100]) {
            options.add(new selectOption(nbcontactsall.Email, nbcontactsall.Email));
        }
        return options;
    }
 
     public String getCC() {
        String cc = 'From Apex'; 
        return cc;
    }
 
     public void setCC(String s) {
        this.cc = 'From Apex'; 
    }

    public String[] getNBContacts() {
            return NBContacts;
    }
    
    public void setNBContacts(String[] NBContacts) {
            this.NBContacts = NBContacts;
    } 

    public String getSelectedContacts() {
            return SelectedContacts;
    }
    
    public PageReference findContacts()
    {
    if (null!=accountId)
    {
       contacts=[select id,FirstName, LastName from Contact where AccountId=:accountId];
    }
    
    return null;
  }
  
    //Method CheckNull: Will return true or false based on column value
    //Invoked From: InvokeCallReport
    //Return Value: Boolean
    
    //private boolean CheckNull(String ColumnValue){
    //    boolean val;
    //    if(ColumnValue == null){
    //        val = true;
    //    }else{
    //        val = false;
    //    }
    //    return val;
    //}  

}

 Test class:

 

@isTest
private class TestCallReportSendEmailClass{

    static testMethod void myUnitTest()
    {
        //Get a record from Call_Report_Summary__c object
        Call_Report_Summary__c CallReportSummaryId = new Call_Report_Summary__c();
        CallReportSummaryId = [select Id from Call_Report_Summary__c limit 1];

        System.debug(CallReportSummaryId.Id);
        PageReference ParentPage = new PageReference('/' + CallReportSummaryId.Id);
        
        //Get the Page Reference of the Call Report SendMultiple EmailPage
        PageReference pageRef = Page.CallReportSendMultipleEmailPage;
        pageRef.getParameters().put('id',CallReportSummaryId.Id);
        //Set the current Page
        Test.setCurrentPageReference(pageRef);
        
        Test.startTest();
        
        //create an instance of the standard controller
        ApexPages.StandardController sc = new ApexPages.standardController(CallReportSummaryId);
    
        //Create an instance of the Controller class
        CallReportSendEmailClass mySendEmailController = new CallReportSendEmailClass(sc);
        
        PageReference testPage1 = new PageReference('/apex/CallReportDataComponentPage' + '?id=' + CallReportSummaryId.Id);
        ApexPages.currentPage().getParameters().put('Id',CallReportSummaryId.Id);
        
        
        //validate CancelEmail Method
        PageReference pageCancelEmail = mySendEmailController.CancelEmail();
        
        //validate setCC Method
        mySendEmailController.setCC('arup.sarkar@nb.com');
        String get_cc = mySendEmailController.getCC();
        
        //validate findContacts Method
        PageReference findContacts = mySendEmailController.findContacts();        
        List<selectOption> items = mySendEmailController.getItems();
        String testContacts = mySendEmailController.getSelectedContacts();
        
        //validate setNBContacts/getNBContacts Method
        List<String> nbContacts = new String[]{'testing'};
        mySendEmailController.setNBContacts(nbContacts);
        String[] nbContacts1 = mySendEmailController.getNBContacts();            
        
        //validate sendemail Method
        mySendEmailController.sBody = 'This is a test body';
        PageReference send_email_page = mySendEmailController.SendEmail();
        System.assertEquals(send_email_page.getURL(), ParentPage.getURL());
        
        
        Test.stopTest();       
    
    }    

}

 

Hi:
We have a field in a object To_Date__c which is of type Date, that value is passed on to a Controller to a "Task" object. Since it is a date object the value which I am seeing in System.debug message is for example if the user selected today is 2011-12-07 00:00:00

We have a SOQL based on task mentioned below. Now if someone creates a Task now the CreatedDate in the task object will be 2011-12-07 13:58:45. Hence, the below mentioned newly created task will not be picked by the query.

Requirement:
============
I would like to have the To_Date in the Apex class to be set to 2011-12-07 23:59:59

Options:
==========
How can I achieve my requirement.
a) Update the field type in the object (To_Date__c) to datetime, have a calculated field (To_Date_Calc__c) map to this field, and have a trigger set the value of To_Date__c to always 2011-12-07 23:59:59
OR
b) Change it in the Apex class.

 

    public Date From_Date{get;set;}

 

select Id, OwnerId, AccountId, Activity_Type__c, Date__c, Location__c, CreatedById,
                                Contacts__c,Employees__c,Description, Comments__c, Product_Alts__c, Products_Equity__c,
                                Products_Fixed_Income__c, Products_Multi_Asset__c, Asset_Class_Formula__c, Owner.Name,
                                Other_Information__c, Account.Name
                                from Task
                                where (CreatedDate >= :From_Date and CreatedDate <= :To_Date)
                                and Type__c = 'Call Report'
                                order by Owner.Name, Date__c

Hi:

We have a List<Task> CallReportData in a controller (apex class) which queries a task object based on date parameters and return rows, which is then fed to a VF page rendered as PDF to display results. There is corresponding get method in the controller.

 

In VF we use the following

<apex:pageblockTable value="{!CallReportData}" var="task">
<apex:column value="{!task.Date__c}" />
</apex:pageblockTable>

 

Problem is when the number of records are more than 1000 I am getting the following error.

 

Collection size 1,695 exceeds maximum size of 1,000

 

I also loop within the main loop another SOQL which is giving me this error when the number of rows from main SOQL is more than 1000.


caused by: System.LimitException: Too many SOQL queries: 101

How to get past the above errors?

 

Regards,

Arup

Hi:

 

I have created a DateTime field in my custom object which is shown in the UI, is there any way to mask the time part and just show the date?

 

I need to have the field as DateTime because behind the scene it issues a SOQL and is compared against CreatedDate.

 

 

regards,

Arup

Hi :

 

I have a Apex controller which returns List<Task>. This object has 4 product columns which needs to be formatted in the visualforce page which is rendered as pdf. Here is the code for Apex class followed by Visualforce page.

 

How can I format the 4 product fields into a comma separated single field and return it to visual force, the reason being 

Product_Alts__c, Products_Equity__c, Products_Fixed_Income__c, Products_Multi_Asset__c will not always have values. So before returning I would like to format it, now number of records returned can be 1 or greater or 0 depending on the query condition.

 

 

I have not copied the entire code since it is long, but proper variable reference exist in the code.

public List<Task> CallReportData = new List<Task>();

    public List<Task> getCallReportData(){
    
            CallReportData = [select Id, OwnerId, AccountId, Activity_Type__c, Date__c, Location__c, CreatedById, 
                                Contacts__c,Employees__c,Description, Comments__c, Product_Alts__c, Products_Equity__c, 
                                Products_Fixed_Income__c, Products_Multi_Asset__c, Asset_Class_Formula__c 
                                from Task 
                                where (Date__c >= :From_Date and Date__c <= :To_Date)
                                and Type__c = 'Call Report'
                                order by Owner.Name, Date__c];

            return CallReportData;

    }

 

Visual force page.

 

<apex:page controller="GenerateCallReportController" renderAs="pdf">

    <apex:pageBlock >
        <apex:pageblockTable value="{!CallReportData}" var="task">


            <apex:column breakBefore="true" style="vertical-align:Top;height:20">
                <apex:outputText value="Products:" style="font-weight:bold; font-family:Tahoma; font-size:x-small; color:#002C52; width:10%; height:20px"/>
            </apex:column>            

            <apex:column value="{!task.Product_Alts__c}" style="font-weight:normal; font-family:Tahoma; font-size:x-small; width:45%; height:20px"/>            
            <apex:column breakBefore="true" style="vertical-align:Top;height:20"/>
            <apex:column value="{!task.Products_Equity__c}" style="font-weight:normal; font-family:Tahoma; font-size:x-small; width:45%; height:20px"/>
            <apex:column breakBefore="true" style="vertical-align:Top;height:20"/>
            <apex:column value="{!task.Products_Fixed_Income__c}" style="font-weight:normal; font-family:Tahoma; font-size:x-small; width:45%; height:20px"/>
            <apex:column breakBefore="true" style="vertical-align:Top;height:20"/>
            <apex:column value="{!task.Products_Multi_Asset__c}" style="font-weight:normal; font-family:Tahoma; font-size:x-small; width:45%; height:20px"/>








        </apex:pageblockTable>
    </apex:pageBlock>
</apex:page>

 

Hi:

 

I am using the following in my visualforce page to open a new window but it is opening in the same window, can anyone please tell me how to open a popup window ?

 

    <script type="text/javascript">
    function popupwindow(){
        var newwindow = window.open('/apex/CallReportDataComponentPage','Call Report'); 
        newwindow.focus();
    }
    </script>

<apex:commandButton action="{!InvokeCallReport}" value="Generate Report" onclick="popupwindow"/>

 

Hi:

 

I have created a visualforce page as follows, I would like to make the fields appearing in the page read only, how do I achieve it?

 

The custom page is shown in the tab.

 

<apex:page showHeader="true" readOnly="false" >
    <apex:enhancedList type="Call_Report_Summary__c" customizable="false" height="700" rowsPerPage="50" id="CallReportListPage"/>
</apex:page>

 

 

Hi:

 

I have created a summary report, where we do not want to show the Record Count when the record is visible in Dashboard. Currently when you run the report standalone or drill down on the report from the dashboard the record count is not showing BUT on the dash board itself it is visible. I would like to remove it from the dashboard.

 

Regards,

Arup

 

Hi:

 

I would appreciate if someone can shed some information on the objects accessible from the resultInfo.get() method. For example, resultInfo.get("Id") return the Id of the record, I would like to know what else is returned. If you look in the code below you will see I am trying to get("Name") but I am not getting anything. Any documentation pointer would be helpful too.

 

 

	private void checkResults(BulkConnection connection, JobInfo job,
			List<BatchInfo> batchInfoList) throws AsyncApiException,
			IOException {
		// batchInfoList was populated when batches were created and submitted
		for (BatchInfo b : batchInfoList) {
			CSVReader rdr = new CSVReader(connection.getBatchResultStream(
					job.getId(), b.getId()));
			List<String> resultHeader = rdr.nextRecord();
			int resultCols = resultHeader.size();

			List<String> row;
			while ((row = rdr.nextRecord()) != null) {
				Map<String, String> resultInfo = new HashMap<String, String>();
				for (int i = 0; i < resultCols; i++) {
					resultInfo.put(resultHeader.get(i), row.get(i));
				}
				boolean success = Boolean.valueOf(resultInfo.get("Success"));
				boolean created = Boolean.valueOf(resultInfo.get("Created"));
				String id = resultInfo.get("Id");
				String error = resultInfo.get("Error");
				
				//GenerateCSVFile(String sFileName, String Id, String Name, String log)
				GenerateCSVFile(sFileName, id, resultInfo.get("Name"), error);
				
				if (success && created) {
					System.out.println("Created row with id " + id);
				} else if (!success) {
					System.out.println("Failed with error: " + error);
				}
			}
		}
	}

 

Hi I am getting the following error in Visualforce, I would really appreciate if someone can help me resolve it. I have also attached the apex class.



ErrorError: Unknown property 'String.label'

 

The error is in the tag

<h2>{!caseField.label}</h2><br/>

 

Visualforce page:

=============

<apex:page standardController="Case" extensions="dynamicCaseRecord">
    <apex:form >
        <apex:repeat var="caseField" value="{!caseFieldList}" >
            <h2>{!caseField.label}</h2><br/>
            <apex:inputText value="{!dynamicCase[caseField]}" 
                        rendered="{!IF(contains(caseField, "Contact"), true, false)}"/>
            <apex:outputText value="{!dynamicCase[caseField]}" 
                        rendered="{!IF(contains(caseField, "Contact"), false, true)}"/>
            <br/><br />
        </apex:repeat>
    </apex:form>
</apex:page>

 

Apex Class:

=============

public class dynamicCaseRecord {
    // construct a SOQL call that populates the case with values from the record  
    
    public dynamicCaseRecord(ApexPages.StandardController controller) {
        String qid = ApexPages.currentPage().getParameters().get('id');
        dynamicCase = [select id, Contact.Name,
        Contact.Email, Contact.Phone, CaseNumber, Origin, Status from Case where id= :qid];
    }

    // create a list of fields that will be rendered on the Visualforce page  
    
    public List<String> caseFieldList { 
        get {
            if (caseFieldList == null) {
                caseFieldList = new List<String>();
                caseFieldList.add('Contact.Name');
                caseFieldList.add('Contact.Email');
                caseFieldList.add('Contact.Phone');
                caseFieldList.add('CaseNumber');
                caseFieldList.add('Origin');
                caseFieldList.add('Status');
             }
        return caseFieldList;
        }
        private set;
        }

    public final Case dynamicCase {get; private set; }
}

 

Hi:

 

I am using BulkAPI to load csv data into account object, Account Name, Account Site, Type, Industry fields are getting loaded fine, but I am not being able to load Billing Address field.

 

The data type of the Billing Address field is Address, in the UI a small pop up screen has individual address fields like Billing Street, Billing State etc.

 

How can I load Billing Address data from csv to the individual fields?

 

Regards,

Arup

Hi,

 

I am following the instruction as mentioned in the below URL:

 

http://www2.developerforce.com/mobile/getting-started/html5/#angularjs-heroku

 

Finally, when I am trying to deploy to heroku using the following command

 

git push heroku master

 I am getting the following error

 

Permission denied (publickey).
fatal: The remote end hung up unexpectedly

  I have already added the client_id generated after creating connected apps as mentioned.

 

Any help will be appreciated.

Hi,

 

I am newbie to SF and per documentation it says that the queryResult returned by the query() call contains a max of 500 records(default).  If more records is needed then a queryMore() call needs to be made.  In my Java client I am not using queryMore() and making the following call where XXX is a number > 500 still fetches me the record.

 

queryResult.getRecords()[XXX]

 

How does it fetch me record where XXX is > 500. ?? Am i missing something here ??

 

Thanks for your responses.

 

 

 

 

  • July 06, 2012
  • Like
  • 0

Hi I have the following web service in Apex.

 

global class AccountWebService
{
    webService static Id makeAccount(String AccountName)
    {
        Account acct = new Account();
        acct.Name = AccountName;
        insert acct;
        return acct.Id;
    }

}

 I have created the following java client in java.

 

package com.nb.sfdc.ws.client;

import java.net.MalformedURLException;
import java.net.URL;
import java.rmi.RemoteException;

import org.apache.axis.AxisFault;

import com.sforce.soap.schemas._class.AccountWebService.AccountWebServiceBindingStub;
import com.sforce.soap.schemas._class.AccountWebService.AccountWebServiceServiceLocator;

public class TestWSClient {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		
		System.setProperty("http.proxyHost", "xxxxx");
		System.setProperty("http.proxyPort", "80");
		
		AccountWebServiceServiceLocator loc = new AccountWebServiceServiceLocator();
		try {
			URL url = new URL(loc.getAccountWebServiceAddress());
			AccountWebServiceBindingStub stub = new AccountWebServiceBindingStub(url,loc);
			stub.setUsername("xxxx");
			stub.setPassword("xxxx");
			stub.makeAccount("testing");
			
		} catch (MalformedURLException e) {
			// TODO Auto-generated catch block
			System.out.println("MalformedURLException: " + e.toString());
		} catch (AxisFault e) {
			// TODO Auto-generated catch block
			System.out.println("AxisFault: " + e.toString());
		} catch (RemoteException e) {
			// TODO Auto-generated catch block
			System.out.println("RemoteException: " + e.toString());
		}

	}

}

 I am getting the following error.

 

AxisFault: INVALID_SESSION_ID: Invalid Session ID found in SessionHeader: Illegal Session

 

Can someone please help me.

 

Hi:

 

  1. I created a simple APEX web service class.
  2. Generated WSDL from the custom class.
  3. Created a Web Service client, in eclipse which generated stub, port and service locator class.

I already have enterprise.jar in my build path. When I am running it I am getting an error. Can someone please let me know where I am going wrong, My connection is working fine. Checked it.

 

package com.nb.sfdc.client;

import java.net.MalformedURLException;
import java.net.URL;
import java.rmi.RemoteException;

import javax.xml.rpc.ServiceException;

import org.apache.axis.AxisFault;

import com.sforce.soap.enterprise.Connector;
import com.sforce.soap.enterprise.EnterpriseConnection;
import com.sforce.soap.enterprise.LoginResult;
import com.sforce.soap.enterprise.fault.LoginFault;
import com.sforce.soap.schemas._class.AccountWebService.AccountWebServiceBindingStub;
import com.sforce.soap.schemas._class.AccountWebService.AccountWebServiceServiceLocator;
import com.sforce.ws.ConnectionException;
import com.sforce.ws.ConnectorConfig;

public class TestAccountWebService {

	/**
	 * @param args
	 */
	
	static ConnectorConfig config = new ConnectorConfig();
	static EnterpriseConnection connection;		
	
	public static void main(String[] args) {
		//Create a salesforce service
		LoginResult loginResult;
		System.out.println("start of program");
		try{
			
			
			config.setNtlmDomain("xxxxxx.com");
			config.setProxy("xxxxxxx.xx.com", 80);
			config.setProxyUsername("xxxxxxxxx");
			config.setProxyPassword("xxxxxxxxx");
			config.setAuthEndpoint("https://login.salesforce.com/services/Soap/c/23.0");
			config.setUsername("xxxxxxxxxxxxxxxxxx");
			config.setPassword("xxxxxxxxxxxxxxxxxx");

			connection = Connector.newConnection(config);
			System.out.println("Connected to salesforce successfully.");
			System.out.println("Authorized End Point: " + config.getAuthEndpoint());
			System.out.println("Session Id : " + config.getSessionId());

			
			//Integrate Web Service
			AccountWebServiceServiceLocator service = new AccountWebServiceServiceLocator();
			try {
				service.getAccountWebService(new URL("https://login.salesforce.com/services/Soap/c/23.0"));
			} catch (ServiceException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			AccountWebServiceBindingStub stub = new AccountWebServiceBindingStub(new URL("https://login.salesforce.com/services/Soap/c/23.0"), service);
			stub.makeAccount("Testing web account");
			

            System.out.println("after call to getSoap()");			
			
		}catch(LoginFault ex){
			ex.printStackTrace();
		}catch(ConnectionException e){
			e.printStackTrace();
		}catch(AxisFault e){
			e.printStackTrace();
		}catch(RemoteException e){
			e.printStackTrace();
		}catch(MalformedURLException e){
			e.printStackTrace();
		}
		

	}

}

 I am getting the following error.

 

AxisFault
 faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException
 faultSubcode: 
 faultString: java.net.NoRouteToHostException: No route to host: connect
 faultActor: 
 faultNode: 
 faultDetail:

 

 

Hi I have attached the mail controller class file, I have written a corresponding test class, I am not getting code coverage beyond 88%. The red lines are on the following lines in the main class, I would like to increase my code coverage to 100% if possible.

 

        Messaging.EmailFileAttachment attach = new Messaging.EmailFileAttachment();
        attach.setContentType('application/pdf');
        attach.setFileName('Call Report.pdf');
        attach.setInline(false);
        attach.Body = body;        
        
        mail.setFileAttachments(new Messaging.EmailFileAttachment[] { attach }); 
        Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });

        PageReference p = new PageReference('/' + theId);
        return p;

 Main Class:

 

public class CallReportSendEmailClass {
 
    private final Call_Report_Summary__c t;
    
    public string sTo {get;set;}
    public string sSubject {get;set;}
    public string sBody {get;set;}
    public string sBehalf {get;set;}
    Public boolean Cancel {get;set;}

    List<String> NBContacts = new String[]{};
    String SelectedContacts = '';

    public List<Contact> TaskContact = new List<Contact>();

    public String accountName {get; set;}
    public Id accountId {get; set;}
    public List<Contact> contacts {get;set;}
    public String ConEmail {get;set;}
    public String cc {get;set;}
    public String sHtmlBody = '';
    
    
    public Date From_Date{get;set;}
    public Date To_Date{get;set;}
    Public String Account{get;set;}
    Public String Contact{get;set;}
    Public String User{get;set;}
    Public String Opportunity{get;set;}
    Public String DateRangeEquality{get;set;}
    Public String DateLiteral{get;set;}
    Public String EmailContactId{get;set;}
    Public String Email{get;set;}
    Public String Subject{get;set;}
    Public String EmailBody{get;set;}    
    Public String Region{get;set;}
    Public String Channel{get;set;}
    Public String SubChannel{get;set;}    
      
      
    public Call_Report_Summary__c EmailReportParams = new Call_Report_Summary__c();      
      
    public CallReportSendEmailClass(ApexPages.StandardController stdController) {
        this.t = (Call_Report_Summary__c)stdController.getRecord();
        
    }
    
    Public PageReference CancelEmail(){
        Cancel = true;
        String theId = ApexPages.currentPage().getParameters().get('id');
        PageReference p = new PageReference('/' + theId);
        return p;        
        
    }
 
    public PageReference SendEmail() {
    
    
 
        String theId = ApexPages.currentPage().getParameters().get('id');
        
        System.debug(' Call Report Template Id : ' + theId);
        
        PageReference pdf = new PageReference('/apex/CallReportDataComponentPage' + '?id=' + theId);
                
        if (accountName == null) {accountName = 'jayakumar.vadivelkarumbayiram@nb.com';}
        List<String> toaddress = accountName.split(';');                
                
        Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
        mail.setToAddresses(toaddress);
        

        
        mail.setsubject(sSubject);
        
        sHtmlBody = '<html>';
        sHtmlBody = sHtmlBody + '<head><title>Tutorial: HelloWorld</title></head><body>';
        //sHtmlBody = sHtmlBody + '<table>';
            
        if (sBody != null ) {
            sBody = sBody.replace('\n', '<br>');
        }
        sHtmlBody = sHtmlBody + sBody;
        sHtmlBody = sHtmlBody + '</body></html>';
        mail.setHtmlBody(sHtmlBody);

                
        
        Blob body;
        body = pdf.getContent();
        Messaging.EmailFileAttachment attach = new Messaging.EmailFileAttachment();
        attach.setContentType('application/pdf');
        attach.setFileName('Call Report.pdf');
        attach.setInline(false);
        attach.Body = body;        
        
        mail.setFileAttachments(new Messaging.EmailFileAttachment[] { attach }); 
        Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });

        PageReference p = new PageReference('/' + theId);
        return p;
    }
    
    public List<selectOption> getItems() {
        List<selectOption> options = new List<selectOption>();
        for (Contact nbcontactsall : [SELECT Email FROM Contact ORDER BY Email LIMIT 100]) {
            options.add(new selectOption(nbcontactsall.Email, nbcontactsall.Email));
        }
        return options;
    }
 
     public String getCC() {
        String cc = 'From Apex'; 
        return cc;
    }
 
     public void setCC(String s) {
        this.cc = 'From Apex'; 
    }

    public String[] getNBContacts() {
            return NBContacts;
    }
    
    public void setNBContacts(String[] NBContacts) {
            this.NBContacts = NBContacts;
    } 

    public String getSelectedContacts() {
            return SelectedContacts;
    }
    
    public PageReference findContacts()
    {
    if (null!=accountId)
    {
       contacts=[select id,FirstName, LastName from Contact where AccountId=:accountId];
    }
    
    return null;
  }
  
    //Method CheckNull: Will return true or false based on column value
    //Invoked From: InvokeCallReport
    //Return Value: Boolean
    
    //private boolean CheckNull(String ColumnValue){
    //    boolean val;
    //    if(ColumnValue == null){
    //        val = true;
    //    }else{
    //        val = false;
    //    }
    //    return val;
    //}  

}

 Test class:

 

@isTest
private class TestCallReportSendEmailClass{

    static testMethod void myUnitTest()
    {
        //Get a record from Call_Report_Summary__c object
        Call_Report_Summary__c CallReportSummaryId = new Call_Report_Summary__c();
        CallReportSummaryId = [select Id from Call_Report_Summary__c limit 1];

        System.debug(CallReportSummaryId.Id);
        PageReference ParentPage = new PageReference('/' + CallReportSummaryId.Id);
        
        //Get the Page Reference of the Call Report SendMultiple EmailPage
        PageReference pageRef = Page.CallReportSendMultipleEmailPage;
        pageRef.getParameters().put('id',CallReportSummaryId.Id);
        //Set the current Page
        Test.setCurrentPageReference(pageRef);
        
        Test.startTest();
        
        //create an instance of the standard controller
        ApexPages.StandardController sc = new ApexPages.standardController(CallReportSummaryId);
    
        //Create an instance of the Controller class
        CallReportSendEmailClass mySendEmailController = new CallReportSendEmailClass(sc);
        
        PageReference testPage1 = new PageReference('/apex/CallReportDataComponentPage' + '?id=' + CallReportSummaryId.Id);
        ApexPages.currentPage().getParameters().put('Id',CallReportSummaryId.Id);
        
        
        //validate CancelEmail Method
        PageReference pageCancelEmail = mySendEmailController.CancelEmail();
        
        //validate setCC Method
        mySendEmailController.setCC('arup.sarkar@nb.com');
        String get_cc = mySendEmailController.getCC();
        
        //validate findContacts Method
        PageReference findContacts = mySendEmailController.findContacts();        
        List<selectOption> items = mySendEmailController.getItems();
        String testContacts = mySendEmailController.getSelectedContacts();
        
        //validate setNBContacts/getNBContacts Method
        List<String> nbContacts = new String[]{'testing'};
        mySendEmailController.setNBContacts(nbContacts);
        String[] nbContacts1 = mySendEmailController.getNBContacts();            
        
        //validate sendemail Method
        mySendEmailController.sBody = 'This is a test body';
        PageReference send_email_page = mySendEmailController.SendEmail();
        System.assertEquals(send_email_page.getURL(), ParentPage.getURL());
        
        
        Test.stopTest();       
    
    }    

}

 

Hi:
We have a field in a object To_Date__c which is of type Date, that value is passed on to a Controller to a "Task" object. Since it is a date object the value which I am seeing in System.debug message is for example if the user selected today is 2011-12-07 00:00:00

We have a SOQL based on task mentioned below. Now if someone creates a Task now the CreatedDate in the task object will be 2011-12-07 13:58:45. Hence, the below mentioned newly created task will not be picked by the query.

Requirement:
============
I would like to have the To_Date in the Apex class to be set to 2011-12-07 23:59:59

Options:
==========
How can I achieve my requirement.
a) Update the field type in the object (To_Date__c) to datetime, have a calculated field (To_Date_Calc__c) map to this field, and have a trigger set the value of To_Date__c to always 2011-12-07 23:59:59
OR
b) Change it in the Apex class.

 

    public Date From_Date{get;set;}

 

select Id, OwnerId, AccountId, Activity_Type__c, Date__c, Location__c, CreatedById,
                                Contacts__c,Employees__c,Description, Comments__c, Product_Alts__c, Products_Equity__c,
                                Products_Fixed_Income__c, Products_Multi_Asset__c, Asset_Class_Formula__c, Owner.Name,
                                Other_Information__c, Account.Name
                                from Task
                                where (CreatedDate >= :From_Date and CreatedDate <= :To_Date)
                                and Type__c = 'Call Report'
                                order by Owner.Name, Date__c

Hi:

We have a List<Task> CallReportData in a controller (apex class) which queries a task object based on date parameters and return rows, which is then fed to a VF page rendered as PDF to display results. There is corresponding get method in the controller.

 

In VF we use the following

<apex:pageblockTable value="{!CallReportData}" var="task">
<apex:column value="{!task.Date__c}" />
</apex:pageblockTable>

 

Problem is when the number of records are more than 1000 I am getting the following error.

 

Collection size 1,695 exceeds maximum size of 1,000

 

I also loop within the main loop another SOQL which is giving me this error when the number of rows from main SOQL is more than 1000.


caused by: System.LimitException: Too many SOQL queries: 101

How to get past the above errors?

 

Regards,

Arup

Hi :

 

I have a Apex controller which returns List<Task>. This object has 4 product columns which needs to be formatted in the visualforce page which is rendered as pdf. Here is the code for Apex class followed by Visualforce page.

 

How can I format the 4 product fields into a comma separated single field and return it to visual force, the reason being 

Product_Alts__c, Products_Equity__c, Products_Fixed_Income__c, Products_Multi_Asset__c will not always have values. So before returning I would like to format it, now number of records returned can be 1 or greater or 0 depending on the query condition.

 

 

I have not copied the entire code since it is long, but proper variable reference exist in the code.

public List<Task> CallReportData = new List<Task>();

    public List<Task> getCallReportData(){
    
            CallReportData = [select Id, OwnerId, AccountId, Activity_Type__c, Date__c, Location__c, CreatedById, 
                                Contacts__c,Employees__c,Description, Comments__c, Product_Alts__c, Products_Equity__c, 
                                Products_Fixed_Income__c, Products_Multi_Asset__c, Asset_Class_Formula__c 
                                from Task 
                                where (Date__c >= :From_Date and Date__c <= :To_Date)
                                and Type__c = 'Call Report'
                                order by Owner.Name, Date__c];

            return CallReportData;

    }

 

Visual force page.

 

<apex:page controller="GenerateCallReportController" renderAs="pdf">

    <apex:pageBlock >
        <apex:pageblockTable value="{!CallReportData}" var="task">


            <apex:column breakBefore="true" style="vertical-align:Top;height:20">
                <apex:outputText value="Products:" style="font-weight:bold; font-family:Tahoma; font-size:x-small; color:#002C52; width:10%; height:20px"/>
            </apex:column>            

            <apex:column value="{!task.Product_Alts__c}" style="font-weight:normal; font-family:Tahoma; font-size:x-small; width:45%; height:20px"/>            
            <apex:column breakBefore="true" style="vertical-align:Top;height:20"/>
            <apex:column value="{!task.Products_Equity__c}" style="font-weight:normal; font-family:Tahoma; font-size:x-small; width:45%; height:20px"/>
            <apex:column breakBefore="true" style="vertical-align:Top;height:20"/>
            <apex:column value="{!task.Products_Fixed_Income__c}" style="font-weight:normal; font-family:Tahoma; font-size:x-small; width:45%; height:20px"/>
            <apex:column breakBefore="true" style="vertical-align:Top;height:20"/>
            <apex:column value="{!task.Products_Multi_Asset__c}" style="font-weight:normal; font-family:Tahoma; font-size:x-small; width:45%; height:20px"/>








        </apex:pageblockTable>
    </apex:pageBlock>
</apex:page>

 

Hi:

 

I am using the following in my visualforce page to open a new window but it is opening in the same window, can anyone please tell me how to open a popup window ?

 

    <script type="text/javascript">
    function popupwindow(){
        var newwindow = window.open('/apex/CallReportDataComponentPage','Call Report'); 
        newwindow.focus();
    }
    </script>

<apex:commandButton action="{!InvokeCallReport}" value="Generate Report" onclick="popupwindow"/>

 

Hi:

 

I have created a visualforce page as follows, I would like to make the fields appearing in the page read only, how do I achieve it?

 

The custom page is shown in the tab.

 

<apex:page showHeader="true" readOnly="false" >
    <apex:enhancedList type="Call_Report_Summary__c" customizable="false" height="700" rowsPerPage="50" id="CallReportListPage"/>
</apex:page>

 

 

Hi:

 

I am using BulkAPI to load csv data into account object, Account Name, Account Site, Type, Industry fields are getting loaded fine, but I am not being able to load Billing Address field.

 

The data type of the Billing Address field is Address, in the UI a small pop up screen has individual address fields like Billing Street, Billing State etc.

 

How can I load Billing Address data from csv to the individual fields?

 

Regards,

Arup