• Doctor
  • NEWBIE
  • 0 Points
  • Member since 2010

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 9
    Questions
  • 12
    Replies

I am new to working with SOAP.

I am using a cut down version of the Partner WSDL to integratre two salesforce Orgs.

 

I have successfully logged in and ssigned a session Id to the SessionHeader, but when I add a query into the mix, I get an Invalid Session ID error.

 

At the moment I am just playing around to make sure I understand the concepts, so the code isn't as complete as it could be with respect to exception handling and the like.

 

Any ideas where I am going wrong?

 

public with sharing class orgConnectionTest {
    
	public static partnerSoapSforceCom.Soap doLogin(){
		
		partnerSoapSforceCom.Soap myPartnerSoap = new partnerSoapSforceCom.Soap();
	     	partnerSoapSforceCom.LoginResult LoginResult = myPartnerSoap.login('user@domain.com', 'XXXXXXXXXXX');
	 	partnerSoapSforceCom.QueryResult QueryResult = myPartnerSoap.query('SELECT Id from Account LIMIT 1');
	 		 	
	 	myPartnerSoap.endpoint_x = LoginResult.serverUrl;
		partnerSoapSforceCom.SessionHeader_element sh = new partnerSoapSforceCom.SessionHeader_element();
		sh.sessionId = LoginResult.sessionId;

		return null;
		
	}

 

  • February 27, 2011
  • Like
  • 0

Compared to other parts of the world, the APEX and Visualforce community in APAC is relatively non-existent.

I am very keen to start some kind of beginners community for Australia and surrounds that allows 'noobs' connect with each other and learn from each other.

 

The whole is greater than the sum of it's parts - or so they say. Lets test the theory!

 

Let me know if this is something you might be interested in getting involved with and, if demand exists, we can get this thing started.

 

Matt

matt@prmaustralia.com.au

  • April 06, 2010
  • Like
  • 0

I know it is possible to create Sharing using APEX, but is it possible to revoke sharing based on a field value?

 

We want to be able to check a checkbox called 'Private' and have all sharing of that record removed.

 

Thanks in advance.

  • April 06, 2010
  • Like
  • 0
I am writing a test method for the controller below and I am stuck at 54%. It seems that where I am stuck is when trying simulate selecting Contacts from the search results prior to saving. I thought that 'controller.allContactselected = true;' would select all results and allow a save to occur, but this doesn't seem to be the case.
 
Any help would be greatly appreciated.
 
Controller:

public with sharing class contactSearchDBGExtension { 

 

public Group_Call__c GroupCall {get; private set;}

public boolean SearchDisplay {get; set;}

public boolean SelectDisplay {get; set;} 

 

public contactSearchDBGExtension(ApexPages.StandardSetController controller) {}  

 

public contactSearchDBGExtension(ApexPages.StandardController controller) {

GroupCall = new Group_Call__c();SearchDisplay = false;SelectDisplay = false;

}  

 

public PageReference save() {try {upsert(GroupCall);

} catch(System.DMLException e) {ApexPages.addMessages(e);return null;}

SearchDisplay = true;

return null;}  

 

public boolean allContactselected {get; set;}

Map<String, boolean> SelectedContact = new Map<String, boolean>{};

 

//checkbox per page

public boolean allCheckboxes = false;

public Integer getSelectedContact(){return SelectedContact.size();}

 

 /* Get Search Criteria Values */

//public String Name {get; set;}

public String getName()

{return Name;} 

 

public String getState()

{return State;}  

 

public String getSpecialty()

{return Specialty;} 

 

/* Set Results List */

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

List<contactwrapper> resultConList = new List<contactwrapper>();

List<contact> selectedContacts = new List<contact>();

List<Attendee__c> AttendeeList = new List<Attendee__c>();

List<Event> EventList = new List<Event>(); 

 

private String Name;

private String State;

private String Specialty;

private integer countfig; 

 

public contactSearchDBGExtension(){}  

public List<contact> getResult() {return result;}  

public List<contactwrapper> getConRes()

{resultConList.clear();countfig = 0;

 

if (result.size() > 0){

for(Contact c : result){countfig = countfig +1;if (countfig < 1000) resultConList.add(new contactwrapper(c));}}

return resultConList; 

//return result;} 

 

public PageReference getSelected() {

selectedContacts.clear();for(contactwrapper conwrapper : resultConList)

if(conwrapper.selected == true)

selectedContacts.add(conwrapper.con);

return null;} 

 

public List<contact> GetSelectedContacts() { 

if(selectedcontacts.size()>0)return selectedcontacts; 

else

return null;} 

 

public PageReference SaveSelectedContacts() {

if (selectedcontacts.size() > 0){

for(Contact c : selectedcontacts){

Attendee__c AttIns = new Attendee__c();

Event EventIns = new Event();

AttIns.Attendee__c = c.Id;

AttIns.Group_Call__c = GroupCall.Id;

AttendeeList.add(AttIns);

EventIns.whatID = GroupCall.Id;

EventIns.whoID = c.Id;

EventIns.StartDateTime = GroupCall.CallStart__c; 

 

if(GroupCall.Session_Length__c == '15 mins'){

EventIns.DurationInMinutes = 15;}

else if(GroupCall.Session_Length__c == '30 mins'){

EventIns.DurationInMinutes = 30;}

else if(GroupCall.Session_Length__c == '45 mins'){

EventIns.DurationInMinutes = 45;}

else if(GroupCall.Session_Length__c == '1 hr'){

EventIns.DurationInMinutes = 60;}

else if(GroupCall.Session_Length__c == '8 hrs'){

EventIns.DurationInMinutes = 480;} 

 

EventIns.Subject = GroupCall.Call_Type__c;

EventIns.Description = GroupCall.Additional_Information__c;

EventIns.ownerID = UserInfo.getUserId();

EventList.add(EventIns);} 

insert AttendeeList;

insert EventList;} 

return (new ApexPages.StandardController(GroupCall)).view();} 

 

/* Set Search Criteria Values */

public void setName(String Name) {this.Name = Name;} 

public void setState(String State) {this.State = State;} 

public void setSpecialty(String Specialty) {this.Specialty = Specialty;} 

 

/* Apply Search Criteria Values to Query and Run Query */

public PageReference fullSearch() {

String queryName = '%' + Name + '%';

String queryState = '%' + State + '%';

String querySpecialty = '%' + Specialty + '%'; 

 

if (Name != '' && State != '' && Specialty != ''){

result = [SELECT Account.Name, Name, MailingState, Specialty__c, LastName FROM Contact WHERE Account.Name LIKE :queryName ORDER BY Account.Name, LastName];} 

 

else if (Name == '' && State != '' && Specialty != ''){

result = [SELECT Account.Name, Name, MailingState, Specialty__c, LastName FROM Contact WHERE MailingState LIKE :queryState AND Specialty__c LIKE :querySpecialty ORDER BY Account.Name, LastName];} 

 

else if (Name != '' && State == '' && Specialty != ''){

result = [SELECT Account.Name, Name, MailingState, Specialty__c, LastName FROM Contact WHERE Account.Name LIKE :queryName AND Specialty__c LIKE :querySpecialty ORDER BY Account.Name, LastName];} 

 

else if (Name != '' && State != '' && Specialty == ''){

result = [SELECT Account.Name, Name, MailingState, Specialty__c, LastName FROM Contact WHERE Account.Name LIKE :queryName AND MailingState LIKE :queryState ORDER BY Account.Name, LastName];}

 

 else if (Name == '' && State == '' && Specialty != ''){

result = [SELECT Account.Name, Name, MailingState, Specialty__c, LastName FROM Contact WHERE Specialty__c LIKE :querySpecialty ORDER BY Account.Name, LastName];} 

 

else if (Name == '' && State != '' && Specialty == ''){

result = [SELECT Account.Name, Name, MailingState, Specialty__c, LastName FROM Contact WHERE MailingState LIKE :queryState ORDER BY Account.Name, LastName];} 

 

else if (Name != '' && Name != null && ( (State == '') || (State == null) ) && ( (Specialty == '') || (Specialty == null) ) ){

result = [SELECT Account.Name, Name, MailingState, Specialty__c, LastName FROM Contact WHERE Account.Name LIKE :queryName ORDER BY Account.Name, LastName];} 

 

else if (Name == '' && State == '' && Specialty == ''){

result = [SELECT Account.Name, Name, MailingState, Specialty__c, LastName FROM Contact ORDER BY Account.Name, LastName];} 

 

if (result.size() > 0)

SelectDisplay = true;

else

SelectDisplay = false;

return null; } 

 

public PageReference partSearch() {

String queryName2 = '%' + Name + '%';

String queryState2 = '%' + State + '%; 

 

if (Name != '' && State != ''){

result = [SELECT Account.Name, Name, MailingState, Specialty__c, LastName FROM Contact WHERE Account.Name LIKE :queryName2 AND MailingState LIKE :queryState2 ORDER BY Account.Name, LastName]; } 

 

else if (Name == '' && State != ''){

result = [SELECT Account.Name, Name, MailingState, Specialty__c, LastName FROM Contact WHERE MailingState LIKE :queryState2 ORDER BY Account.Name, LastName]; }

 

else if (Name != '' && State == ''){

result = [SELECT Account.Name, Name, MailingState, Specialty__c, LastName FROM Contact WHERE Account.Name LIKE :queryName2 ORDER BY Account.Name, LastName]; }

 

else if (Name == '' && State == ''){

result = [SELECT Account.Name, Name, MailingState, Specialty__c, LastName FROM Contact ORDER BY Account.Name, LastName]; }  

if (result.size() > 0)

SelectDisplay = true;

else

SelectDisplay = false;

return null; }  

 

/* Create Attendee Redord for Selected Contacts */

public class contactwrapper {

public contact con{get; set;}

public Boolean selected {get; set;}

public contactwrapper(contact c){ 

con = c;selected = false;

}}} 

 

 Test Method (so far):

@isTestprivate class DBGExtensionTest { 

 

// Unit Test for general record creation

static testMethod void createGCTest() {

PageReference pageRef = Page.GroupCallPageDBG;

Test.setCurrentPage(pageRef);

contactSearchDBGExtension controller = new contactSearchDBGExtension();

Group_Call__c GroupCall = new Group_Call__c (Call_Type__c = 'Journal Club', CallStart__c = system.now(), Session_Length__c = '45 mins', State_National_ACtivity__c = 'State', PeopleTrained__c = '1 - 5'); 

controller.save();

system.assertEquals('Journal Club', GroupCall.Call_Type__c);

system.assertNotEquals(null, GroupCall.CallStart__c);

system.assertEquals('45 mins', GroupCall.Session_Length__c);

system.assertEquals('1 - 5', GroupCall.PeopleTrained__c); }  

 

// Unit Test for fullSearch pageRef

static testMethod void fullSearchTest1() { 

PageReference pageRef = Page.GroupCallPageDBG;

Test.setCurrentPage(pageRef);

contactSearchDBGExtension controller = new contactSearchDBGExtension();

controller.setName('PRM');

controller.setState('VIC');

controller.setSpecialty('General Practice');

List<Contact> l1 = controller.getResult();

controller.fullSearch();

system.assert( l1.size() == 0 );

controller.getConRes();

system.assertEquals( 'PRM', controller.getName());

system.assertEquals( 'VIC', controller.getState());

system.assertEquals( 'General Practice', controller.getSpecialty());

controller.allContactselected = true;

controller.allCheckboxes = true;

controller.getselectedContacts();

controller.saveSelectedContacts();

controller.save(); }  

 

// Unit Test for partSearch pageRef

static testMethod void partSearchTest() {

PageReference pageRef = Page.GroupCallPageDBG;

Test.setCurrentPage(pageRef);

contactSearchDBGExtension controller = new contactSearchDBGExtension();

controller.setName('PRM');

controller.setState('NSW');

List<Contact> l2 = controller.getResult();

controller.partSearch();

system.assert( l2.size() >= 0 );

controller.getConRes();

system.assertEquals( 'PRM', controller.getName());

system.assertEquals( 'NSW', controller.getState());

controller.allContactselected = true;

controller.getselectedContacts();

controller.saveSelectedContacts();

}

}

 

 
Message Edited by Doctor on 02-18-2010 05:56 AM
Message Edited by Doctor on 02-18-2010 05:57 AM
Message Edited by Doctor on 02-18-2010 05:59 AM
  • February 18, 2010
  • Like
  • 0

I am having my first attempt at writing a test method. I am slowly getting the coverage up, but I also manage to get a failure on each test.

 

Any suggestions would be much appreciated.

 

Test Method:

 

 

@isTestprivate class DBGExtensionTest2 {

 

// Unit Test for general record creation  

static testMethod void createGCTest() {

PageReference pageRef = Page.GroupCallPageDBG;

Test.setCurrentPage(pageRef);

contactSearchDBGExtension controller = new contactSearchDBGExtension();

Group_Call__c GroupCall = new Group_Call__c (Call_Type__c = 'Journal Club', CallStart__c = system.now(), Session_Length__c = '45 mins', State_National_ACtivity__c = 'State', PeopleTrained__c = '1 - 5');

controller.save();

system.assertEquals('Journal Club', GroupCall.Call_Type__c);

system.assert(GroupCall.CallStart__c != null);

system.assertEquals('45 mins', GroupCall.Session_Length__c);

system.assertEquals('1 - 5', GroupCall.PeopleTrained__c);

}

 

  // Unit Test for fullSearch pageRef

static testMethod void fullSearchTest1() {

 

PageReference pageRef = Page.GroupCallPageDBG;

Test.setCurrentPage(pageRef);

contactSearchDBGExtension controller = new contactSearchDBGExtension();

controller.setName('PRM');

controller.setState('VIC');

controller.setSpecialty('General Practice');

List<Contact> l1 = controller.getResult();

controller.fullSearch();

system.assert( l1.size() == 0 );

controller.getConRes();

system.assertEquals( 'PRM', controller.getName());

system.assertEquals( 'VIC', controller.getState());

system.assertEquals( 'General Practice', controller.getSpecialty());

controller.allContactselected = true;

controller.getselectedContacts();

controller.saveSelectedContacts();

}

 

// Unit Test for partSearch pageRef

  static testMethod void partSearchTest() {

 

PageReference pageRef = Page.GroupCallPageDBG;

Test.setCurrentPage(pageRef);

contactSearchDBGExtension controller = new contactSearchDBGExtension();

controller.setName('PRM');

controller.setState('NSW');

List<Contact> l2 = controller.getResult();

controller.partSearch();

system.assert( l2.size() >= 0 );

controller.getConRes();

system.assertEquals( 'PRM', controller.getName());

system.assertEquals( 'NSW', controller.getState());

controller.allContactselected = true;

controller.getselectedContacts();

controller.save();

}

}

 

The errors are as follows:

 

DBGExtensionTest2.createGCTest
System.NullPointerException: Attempt to de-reference a null object
Class.contactSearchDBGExtension.save: line 19, column 20
Class.DBGExtensionTest2.createGCTest: line 11, column 8External entry point
System.NullPointerException: Attempt to de-reference a null object
Class.contactSearchDBGExtension.save: line 19, column 20 
Class.DBGExtensionTest2.partSearchTest: line 93, column 9External entry point

DBGExtensionTest2.fullSearchTest

System.NullPointerException: Argument 1 cannot be null

Class.contactSearchDBGExtension.SaveSelectedContacts: line 148, column 50Class.DBGExtensionTest2.fullSearchTest1: line 36, column 9External entry point 

 

 

Message Edited by Doctor on 02-13-2010 12:51 AM
  • February 13, 2010
  • Like
  • 0

I have some JAVA code that I need to translate into something SFDC will compile.

I am a bit of a noob to all of this, so any guidance would be greatly appreciated.

 

 

 

<%@ page import="java.util.HashMap" %>

<%@ page import="java.util.Map" %>

<%@ page import="java.util.StringTokenizer" %>

<%@ page import="com.qvalent.ccapi.CardsAPI" %>

<jsp:useBean id="cardsAPI" class="com.qvalent.ccapi.CardsAPI" scope="application"/>

<%

 

    if ( !cardsAPI.isInitialised() )

    {

        final HashMap initParams = new HashMap();

        initParams.put( "url", "https://ccapi.client.support.qvalent.com/post/CreditCardAPIReceiver" );

        initParams.put( "certificateFile", "CERT_FILE" );

        initParams.put( "logDirectory", "LOG_DIR" );

        cardsAPI.initialise( initParams );

    }

 

    //----------------------------------------------------------------------------

    // SET CONNECTION DEFAULTS

    //----------------------------------------------------------------------------

    String orderECI               = "SSL";

    String orderType              = "capture";

 

    String cardNumber             = request.getParameter( "cardNumber" );

    String cardVerificationNumber = request.getParameter( "cardVerificationNumber" );

    String cardExpiryYear         = request.getParameter( "cardExpiryYear" );

    String cardExpiryMonth        = request.getParameter( "cardExpiryMonth" );

 

    String cardCurrency           = "AUD";

    int orderAmountCents          = 

        (int)(Double.parseDouble( request.getParameter( "orderAmount" ) ) * 100 );

 

    String customerUsername       = "USER";

    String customerPassword       = "PASS";

    String customerMerchant       = "TEST";

    String orderNumber            = Long.toString( System.currentTimeMillis() );

 

    //----------------------------------------------------------------------------

    // INITIALISE REQUEST PARAMETERS

    //----------------------------------------------------------------------------

    HashMap requestParams = new HashMap();

    requestParams.put( "customer.username", customerUsername );

    requestParams.put( "customer.password", customerPassword );

    requestParams.put( "customer.merchant", customerMerchant );

    requestParams.put( "order.type", orderType );

    requestParams.put( "card.PAN", cardNumber );

    requestParams.put( "card.CVN", cardVerificationNumber );

    requestParams.put( "card.expiryYear", cardExpiryYear );

    requestParams.put( "card.expiryMonth", cardExpiryMonth );

    requestParams.put( "order.amount", Long.toString( orderAmountCents ) );

    requestParams.put( "customer.orderNumber", orderNumber );

    requestParams.put( "card.currency", cardCurrency );

    requestParams.put( "order.ECI", orderECI );

 

    Map responseParameters = cardsAPI.processCreditCard( requestParams );

 

    // Get the required parameters from the response

    String summaryCode = (String)responseParameters.get( "response.summaryCode" );

    String responseCode = (String)responseParameters.get( "response.responseCode" );

    String description = (String)responseParameters.get( "response.text" );

    String receiptNo = (String)responseParameters.get( "response.referenceNo" );

    String settlementDate = (String)responseParameters.get( "response.settlementDate" );

    String creditGroup = (String)responseParameters.get( "response.creditGroup" );

    String cardSchemeName = (String)responseParameters.get( "response.cardSchemeName" );

%> 

 

Message Edited by Doctor on 02-10-2010 06:03 AM
  • February 10, 2010
  • Like
  • 0

For some reason, when I hit the save button on my VF page, I am returned to the home page and nothing is saved.

Any ideas?

 

VF Page:

<apex:page standardController="Group_Call__c" id="page" cache="true" recordSetVar="unused" showHeader="True" sidebar="True" title="Log Group Call"> <apex:form id="massInsertTasks"> <apex:SectionHeader title="Log Group Call" /> <apex:pageMessages ></apex:pageMessages> <apex:pageBlock id="mainBlock" title="Group Call Details"> <!-- Holds Group Call Details --> <apex:actionRegion > <apex:pageBlockSection title="Group Call Details" columns="2" showHeader="false"> <apex:pageBlockSectionItem >Call Type <apex:inputField value="{!Group_Call__c.Call_Type__c}" /> </apex:pageBlockSectionItem> <apex:pageBlockSectionItem >Product/Drug <apex:inputField value="{!Group_Call__c.Product__c}" /> </apex:pageBlockSectionItem> <apex:pageBlockSectionItem >Call Start <apex:inputField value="{!Group_Call__c.CallStart__c}"/> </apex:pageBlockSectionItem> <apex:pageBlockSectionItem >No of People Trained <apex:inputField value="{!Group_Call__c.PeopleTrained__c}" /> </apex:pageBlockSectionItem> <apex:pageBlockSectionItem >Call End <apex:inputField value="{!Group_Call__c.CallFinish__c}"/> </apex:pageBlockSectionItem> <apex:pageBlockSectionItem >Location <apex:inputField value="{!Group_Call__c.Location__c}" /> </apex:pageBlockSectionItem> <apex:pageBlockSectionItem >Delivery Date <apex:inputField value="{!Group_Call__c.DeliveryDate__c}" /> </apex:pageBlockSectionItem> <apex:pageBlockSectionItem > <apex:outputLabel value="State/National Activity"/> <apex:outputPanel > <apex:inputField value="{!Group_Call__c.State_National_Activity__c}" required="true" /> <apex:actionSupport event="onchange" rerender="searchBlock" status="status"/> <apex:actionStatus startText="...please wait..." id="status" startStyle="color: rgb(255, 0, 0); font-weight: bold;"/> </apex:outputPanel> </apex:pageBlockSectionItem> </apex:pageBlockSection> </apex:actionRegion> <apex:pageBlockSection showHeader="false" columns="1" title="Additional Information"> <apex:pageBlockSectionItem >Additional Information <apex:inputField value="{!Group_Call__c.Additional_Information__c}" style="width: 85%;" /> </apex:pageBlockSectionItem> </apex:pageblockSection> <apex:pageBlockButtons > <apex:commandButton action="{!Save}" value="Save" /> </apex:pageBlockButtons> </apex:pageBlock> </apex:form> </apex:page>

 

  • January 19, 2010
  • Like
  • 0

I have developed (with much appreciated forum help) a custom search app that allows a user to search Contacts based on up to four field values. Now that I have that peice working, I need to add on the functionality of being able to select multiple contacts from the search results and create an event for all of them in one hit.

 

Can someone point me in the right direction?

Keep in mind I am fairly new to all of this.

 

Thanks in advance.

 

 

  • January 13, 2010
  • Like
  • 0
I am developing a custom search page based on the Contact object.
At the moment, the search is recognizing empty search fields as having a blank value, so if the search field is left blank the results only show records that have a blank value in the field.
I need it to work so that, essentially if the search field is left blank, the search ignores it and shows results for all values.
I hope that makes sense. Any help would be greatly appreciated.
Controller Code: 

public with sharing class contactSearchExtension { public contactSearchExtension(ApexPages.StandardSetController controller) { } public contactSearchExtension(ApexPages.StandardController controller) { } public String getName() { return null; } public String getState() { return null; } public List<Contact> result = new List<Contact>(); private String Name; private String State; public contactSearchExtension(){ } public List<Contact> getResult() { return result; } public void setName(String Name) { this.Name = Name; } public void setState(String State) { this.State = State; } public void search() { String queryName = '%' + Name + '%'; String queryState = '%' + State + '%'; result = [ SELECT Account.Name, Name, MailingState FROM Contact WHERE Account.Name like :queryName AND MailingState like :queryState]; } }

 

Message Edited by Doctor on 01-12-2010 02:44 PM
  • January 12, 2010
  • Like
  • 0

Looking to leverage SF's CRM to house and manage all of our customer databases with the ability to see one view of all customer activity.  Not sure where to start.  All suggestions welcome.  Thx...

First of all, I'm a complete newbie to SF development. I tried reading the visual force documentation and all I get his source code, but no idea where it goes, how to start, or even do the simplest thing. Basically, what I would like to do is customize the existing salesforce pages, and then eventually work my way towards building custom pages. Here are two things that have really been bugging me:

 

How do you change the logo to your company logo? This is an unacceptable product to demo our operations to outside customers with SalesForce written all over it.

 

How can I apply my own style to salesforce globally as depicted in this screenshot? http://www.zendesk.com/images/partners/getsatisfaction/screenshot_sf_main_lg.png

I know it is possible to create Sharing using APEX, but is it possible to revoke sharing based on a field value?

 

We want to be able to check a checkbox called 'Private' and have all sharing of that record removed.

 

Thanks in advance.

  • April 06, 2010
  • Like
  • 0

Hello All,

 

I'm in the process of trying to learn as much as I can as quickly as I can about development on the Force.com platform.  I've found a number of resources to look at on the Force.com site, including the incredibly intimidating 2400+ page "How to be Successful with Salesforce" eBook.  There is a huge amount of documentation, and I've found it difficult to tell where to start really, since there are so many eBooks they have available for download, each of which is anywhere from 200 to 600 pages in length

 

If cost were no object, I'd be signing up for the developer courses offered by Salesforce.com:

  1. Dev 401 ($4,000)
  2. Dev 501 ($4,000)
  3. Dev 502 ($2,400)
  4. Dev 531 ($4,000)

 

That is so far beyond my training budget as an independent developer that it's just not even an option.  I got all excited when I saw that perhaps the 401 & 501 classes could be downloaded (for free, no less) as a podcast from the iTunes Music store... but it became quickly apparent that significant chunks of the hands-on coding part of the class are not there, making things difficult to really follow along with from a very early point in the series.  They're still a great source of information, but they seem more like a preview/teaser to the class than a suitable substitute.  I would gladly pay for some sort of online version of the course that was (a lot) less expensive than the in-person class, but no such thing seems to exist.  I would sign up for 3rd party training if it seemed to be of sufficient quality, and again, was affordable... but so far, I've not found anything useful.

 

Can anyone recommend or point me in the direction of some resources I can use to gain the equivalent experience one might get from the courses Salesforce.com provides, without the accompanying bankruptcy forms I'd probably have to fill out if I took those courses?

 

Thanks in advance for any tips, hints or pointers!

 

Cheers,

Jon

I am writing a test method for the controller below and I am stuck at 54%. It seems that where I am stuck is when trying simulate selecting Contacts from the search results prior to saving. I thought that 'controller.allContactselected = true;' would select all results and allow a save to occur, but this doesn't seem to be the case.
 
Any help would be greatly appreciated.
 
Controller:

public with sharing class contactSearchDBGExtension { 

 

public Group_Call__c GroupCall {get; private set;}

public boolean SearchDisplay {get; set;}

public boolean SelectDisplay {get; set;} 

 

public contactSearchDBGExtension(ApexPages.StandardSetController controller) {}  

 

public contactSearchDBGExtension(ApexPages.StandardController controller) {

GroupCall = new Group_Call__c();SearchDisplay = false;SelectDisplay = false;

}  

 

public PageReference save() {try {upsert(GroupCall);

} catch(System.DMLException e) {ApexPages.addMessages(e);return null;}

SearchDisplay = true;

return null;}  

 

public boolean allContactselected {get; set;}

Map<String, boolean> SelectedContact = new Map<String, boolean>{};

 

//checkbox per page

public boolean allCheckboxes = false;

public Integer getSelectedContact(){return SelectedContact.size();}

 

 /* Get Search Criteria Values */

//public String Name {get; set;}

public String getName()

{return Name;} 

 

public String getState()

{return State;}  

 

public String getSpecialty()

{return Specialty;} 

 

/* Set Results List */

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

List<contactwrapper> resultConList = new List<contactwrapper>();

List<contact> selectedContacts = new List<contact>();

List<Attendee__c> AttendeeList = new List<Attendee__c>();

List<Event> EventList = new List<Event>(); 

 

private String Name;

private String State;

private String Specialty;

private integer countfig; 

 

public contactSearchDBGExtension(){}  

public List<contact> getResult() {return result;}  

public List<contactwrapper> getConRes()

{resultConList.clear();countfig = 0;

 

if (result.size() > 0){

for(Contact c : result){countfig = countfig +1;if (countfig < 1000) resultConList.add(new contactwrapper(c));}}

return resultConList; 

//return result;} 

 

public PageReference getSelected() {

selectedContacts.clear();for(contactwrapper conwrapper : resultConList)

if(conwrapper.selected == true)

selectedContacts.add(conwrapper.con);

return null;} 

 

public List<contact> GetSelectedContacts() { 

if(selectedcontacts.size()>0)return selectedcontacts; 

else

return null;} 

 

public PageReference SaveSelectedContacts() {

if (selectedcontacts.size() > 0){

for(Contact c : selectedcontacts){

Attendee__c AttIns = new Attendee__c();

Event EventIns = new Event();

AttIns.Attendee__c = c.Id;

AttIns.Group_Call__c = GroupCall.Id;

AttendeeList.add(AttIns);

EventIns.whatID = GroupCall.Id;

EventIns.whoID = c.Id;

EventIns.StartDateTime = GroupCall.CallStart__c; 

 

if(GroupCall.Session_Length__c == '15 mins'){

EventIns.DurationInMinutes = 15;}

else if(GroupCall.Session_Length__c == '30 mins'){

EventIns.DurationInMinutes = 30;}

else if(GroupCall.Session_Length__c == '45 mins'){

EventIns.DurationInMinutes = 45;}

else if(GroupCall.Session_Length__c == '1 hr'){

EventIns.DurationInMinutes = 60;}

else if(GroupCall.Session_Length__c == '8 hrs'){

EventIns.DurationInMinutes = 480;} 

 

EventIns.Subject = GroupCall.Call_Type__c;

EventIns.Description = GroupCall.Additional_Information__c;

EventIns.ownerID = UserInfo.getUserId();

EventList.add(EventIns);} 

insert AttendeeList;

insert EventList;} 

return (new ApexPages.StandardController(GroupCall)).view();} 

 

/* Set Search Criteria Values */

public void setName(String Name) {this.Name = Name;} 

public void setState(String State) {this.State = State;} 

public void setSpecialty(String Specialty) {this.Specialty = Specialty;} 

 

/* Apply Search Criteria Values to Query and Run Query */

public PageReference fullSearch() {

String queryName = '%' + Name + '%';

String queryState = '%' + State + '%';

String querySpecialty = '%' + Specialty + '%'; 

 

if (Name != '' && State != '' && Specialty != ''){

result = [SELECT Account.Name, Name, MailingState, Specialty__c, LastName FROM Contact WHERE Account.Name LIKE :queryName ORDER BY Account.Name, LastName];} 

 

else if (Name == '' && State != '' && Specialty != ''){

result = [SELECT Account.Name, Name, MailingState, Specialty__c, LastName FROM Contact WHERE MailingState LIKE :queryState AND Specialty__c LIKE :querySpecialty ORDER BY Account.Name, LastName];} 

 

else if (Name != '' && State == '' && Specialty != ''){

result = [SELECT Account.Name, Name, MailingState, Specialty__c, LastName FROM Contact WHERE Account.Name LIKE :queryName AND Specialty__c LIKE :querySpecialty ORDER BY Account.Name, LastName];} 

 

else if (Name != '' && State != '' && Specialty == ''){

result = [SELECT Account.Name, Name, MailingState, Specialty__c, LastName FROM Contact WHERE Account.Name LIKE :queryName AND MailingState LIKE :queryState ORDER BY Account.Name, LastName];}

 

 else if (Name == '' && State == '' && Specialty != ''){

result = [SELECT Account.Name, Name, MailingState, Specialty__c, LastName FROM Contact WHERE Specialty__c LIKE :querySpecialty ORDER BY Account.Name, LastName];} 

 

else if (Name == '' && State != '' && Specialty == ''){

result = [SELECT Account.Name, Name, MailingState, Specialty__c, LastName FROM Contact WHERE MailingState LIKE :queryState ORDER BY Account.Name, LastName];} 

 

else if (Name != '' && Name != null && ( (State == '') || (State == null) ) && ( (Specialty == '') || (Specialty == null) ) ){

result = [SELECT Account.Name, Name, MailingState, Specialty__c, LastName FROM Contact WHERE Account.Name LIKE :queryName ORDER BY Account.Name, LastName];} 

 

else if (Name == '' && State == '' && Specialty == ''){

result = [SELECT Account.Name, Name, MailingState, Specialty__c, LastName FROM Contact ORDER BY Account.Name, LastName];} 

 

if (result.size() > 0)

SelectDisplay = true;

else

SelectDisplay = false;

return null; } 

 

public PageReference partSearch() {

String queryName2 = '%' + Name + '%';

String queryState2 = '%' + State + '%; 

 

if (Name != '' && State != ''){

result = [SELECT Account.Name, Name, MailingState, Specialty__c, LastName FROM Contact WHERE Account.Name LIKE :queryName2 AND MailingState LIKE :queryState2 ORDER BY Account.Name, LastName]; } 

 

else if (Name == '' && State != ''){

result = [SELECT Account.Name, Name, MailingState, Specialty__c, LastName FROM Contact WHERE MailingState LIKE :queryState2 ORDER BY Account.Name, LastName]; }

 

else if (Name != '' && State == ''){

result = [SELECT Account.Name, Name, MailingState, Specialty__c, LastName FROM Contact WHERE Account.Name LIKE :queryName2 ORDER BY Account.Name, LastName]; }

 

else if (Name == '' && State == ''){

result = [SELECT Account.Name, Name, MailingState, Specialty__c, LastName FROM Contact ORDER BY Account.Name, LastName]; }  

if (result.size() > 0)

SelectDisplay = true;

else

SelectDisplay = false;

return null; }  

 

/* Create Attendee Redord for Selected Contacts */

public class contactwrapper {

public contact con{get; set;}

public Boolean selected {get; set;}

public contactwrapper(contact c){ 

con = c;selected = false;

}}} 

 

 Test Method (so far):

@isTestprivate class DBGExtensionTest { 

 

// Unit Test for general record creation

static testMethod void createGCTest() {

PageReference pageRef = Page.GroupCallPageDBG;

Test.setCurrentPage(pageRef);

contactSearchDBGExtension controller = new contactSearchDBGExtension();

Group_Call__c GroupCall = new Group_Call__c (Call_Type__c = 'Journal Club', CallStart__c = system.now(), Session_Length__c = '45 mins', State_National_ACtivity__c = 'State', PeopleTrained__c = '1 - 5'); 

controller.save();

system.assertEquals('Journal Club', GroupCall.Call_Type__c);

system.assertNotEquals(null, GroupCall.CallStart__c);

system.assertEquals('45 mins', GroupCall.Session_Length__c);

system.assertEquals('1 - 5', GroupCall.PeopleTrained__c); }  

 

// Unit Test for fullSearch pageRef

static testMethod void fullSearchTest1() { 

PageReference pageRef = Page.GroupCallPageDBG;

Test.setCurrentPage(pageRef);

contactSearchDBGExtension controller = new contactSearchDBGExtension();

controller.setName('PRM');

controller.setState('VIC');

controller.setSpecialty('General Practice');

List<Contact> l1 = controller.getResult();

controller.fullSearch();

system.assert( l1.size() == 0 );

controller.getConRes();

system.assertEquals( 'PRM', controller.getName());

system.assertEquals( 'VIC', controller.getState());

system.assertEquals( 'General Practice', controller.getSpecialty());

controller.allContactselected = true;

controller.allCheckboxes = true;

controller.getselectedContacts();

controller.saveSelectedContacts();

controller.save(); }  

 

// Unit Test for partSearch pageRef

static testMethod void partSearchTest() {

PageReference pageRef = Page.GroupCallPageDBG;

Test.setCurrentPage(pageRef);

contactSearchDBGExtension controller = new contactSearchDBGExtension();

controller.setName('PRM');

controller.setState('NSW');

List<Contact> l2 = controller.getResult();

controller.partSearch();

system.assert( l2.size() >= 0 );

controller.getConRes();

system.assertEquals( 'PRM', controller.getName());

system.assertEquals( 'NSW', controller.getState());

controller.allContactselected = true;

controller.getselectedContacts();

controller.saveSelectedContacts();

}

}

 

 
Message Edited by Doctor on 02-18-2010 05:56 AM
Message Edited by Doctor on 02-18-2010 05:57 AM
Message Edited by Doctor on 02-18-2010 05:59 AM
  • February 18, 2010
  • Like
  • 0

I'm working on some unit test coverage code and currently have 77% of the controller covered.  I'm trying to get the remaining lines covered before adding my assert statements.

 

The lines missing code coverage are in my save() method (see the screenshot below).

 

In my test method, I've initialized the controller and passed in a new instance of the StandardSetController with a list of the sObject being used.  I have called all the properties and methods in the controller.

 

Can anyone provide some help on how I can get the missing lines in my save method covered?  I need to create a new task to use in the save method that is being attached to multiple records.

 

Here is my controller code:

 

public class MassAddActivityController { private List<Service_Delivery__c> sds; private Task assignedTo = new Task(); private Task status = new Task(); private Task activityDate = new Task(); private Task clientAttendees = new Task(); private Task hsgAttendees = new Task(); private Task presenter = new Task(); private Task purpose = new Task(); private Task dynamics = new Task(); private Task outcomes = new Task(); private Task description = new Task(); private Task sendContactReport = new Task(); private Boolean render; private Integer count; public Task task {get; set;} public Task getAssignedTo() { return assignedTo; } public Task getStatus() { return status; } public String subject { get; set; } public Task getActivityDate() { return activityDate; } public Task getClientAttendees() { return clientAttendees; } public Task getHsgAttendees() { return hsgAttendees; } public Task getPresenter() { return presenter; } public Task getPurpose() { return purpose; } public Task getDynamics() { return dynamics; } public Task getOutcomes() { return outcomes; } public Task getDescription() { return description; } public Task getSendContactReport() { return sendContactReport; } public MassAddActivityController(ApexPages.StandardSetController stdSetController) { init((List<Service_Delivery__c>) stdSetController.getSelected()); status.status = 'Completed'; subject = 'Presentation/Meeting'; assignedTo.OwnerId = UserInfo.getUserId(); DateTime dt = System.now(); Date currentDate = date.newinstance(dt.year(), dt.month(), dt.day()); activityDate.activityDate = currentDate; render = false; } public void init(List<Service_Delivery__c> sds) { List<Id> ids = new List<Id>(); for (Service_Delivery__c sd : sds) { ids.add(sd.id); } this.sds = [Select Id, Name From Service_Delivery__c Where Id in :ids]; count = [Select Count() From Service_Delivery__c Where Id in :ids]; } public Id getRecordTypeId() { RecordType rt = [Select Id From RecordType WHERE Name = 'Contact Reports Entry']; Id recordTypeId = rt.Id; return recordTypeId; } public List<Service_Delivery__c> getServiceDeliveries() { return sds; } public List<SelectOption> getItems() { Schema.DescribeFieldResult pklst = Schema.Task.Subject.getDescribe(); List<Schema.PicklistEntry> ple = pklst.getPicklistValues(); List<SelectOption> options = new List<SelectOption>(); for(Schema.PicklistEntry f : ple) { options.add(new SelectOption(f.getLabel(), f.getLabel())); } return options; } public PageReference save() { try { for (Service_Delivery__c sd : sds) { Task t = new Task(); t.recordTypeId = getRecordTypeId(); t.ownerId = assignedTo.OwnerId; t.status = 'Completed'; t.subject = subject; t.activityDate = activityDate.activityDate; t.whatId = sd.Id; t.Client_Company_Attendees__c = clientAttendees.Client_Company_Attendees__c; t.Health_Strategies_Group_Attendees__c = hsgAttendees.Health_Strategies_Group_Attendees__c; t.Meeting_Presenter__c = presenter.Meeting_Presenter__c; t.Purpose__c = purpose.Purpose__c; t.Dynamics__c = dynamics.Dynamics__c; t.Outcomes__c = outcomes.Outcomes__c; t.description = description.description; t.Send_Contact_Report__c = sendContactReport.Send_Contact_Report__c; t.Mass_Added_Date__c = Date.today(); insert t; } ApexPages.Message msg = new ApexPages.message(ApexPages.Severity.INFO, 'Activities added successfully.'); ApexPages.addMessage(msg); render = true; return null; } catch (Exception ex) { ApexPages.Message errMsg = new ApexPages.Message(ApexPages.Severity.ERROR, ex.getMessage()); ApexPages.addMessage(errMsg); return null; } } public boolean getRendered() { return render; } public Integer getCount() { return count; } static testMethod void test() { List<Service_Delivery__c> sds = [Select id, name From Service_Delivery__c LIMIT 5]; MassAddActivityController ctrl = new MassAddActivityController(new ApexPages.StandardSetController(sds)); ctrl.getAssignedTo(); ctrl.getStatus(); ctrl.getActivityDate(); ctrl.getClientAttendees(); ctrl.getHsgAttendees(); ctrl.getPresenter(); ctrl.getPurpose(); ctrl.getDynamics(); ctrl.getOutcomes(); ctrl.getDescription(); ctrl.getSendContactReport(); ctrl.getCount(); ctrl.getRendered(); ctrl.getRecordTypeId(); ctrl.getServiceDeliveries(); ctrl.getItems(); ctrl.save(); } }

 

screenshot

screenshot

I have developed (with much appreciated forum help) a custom search app that allows a user to search Contacts based on up to four field values. Now that I have that peice working, I need to add on the functionality of being able to select multiple contacts from the search results and create an event for all of them in one hit.

 

Can someone point me in the right direction?

Keep in mind I am fairly new to all of this.

 

Thanks in advance.

 

 

  • January 13, 2010
  • Like
  • 0
I am developing a custom search page based on the Contact object.
At the moment, the search is recognizing empty search fields as having a blank value, so if the search field is left blank the results only show records that have a blank value in the field.
I need it to work so that, essentially if the search field is left blank, the search ignores it and shows results for all values.
I hope that makes sense. Any help would be greatly appreciated.
Controller Code: 

public with sharing class contactSearchExtension { public contactSearchExtension(ApexPages.StandardSetController controller) { } public contactSearchExtension(ApexPages.StandardController controller) { } public String getName() { return null; } public String getState() { return null; } public List<Contact> result = new List<Contact>(); private String Name; private String State; public contactSearchExtension(){ } public List<Contact> getResult() { return result; } public void setName(String Name) { this.Name = Name; } public void setState(String State) { this.State = State; } public void search() { String queryName = '%' + Name + '%'; String queryState = '%' + State + '%'; result = [ SELECT Account.Name, Name, MailingState FROM Contact WHERE Account.Name like :queryName AND MailingState like :queryState]; } }

 

Message Edited by Doctor on 01-12-2010 02:44 PM
  • January 12, 2010
  • Like
  • 0