• ClintLee
  • SMARTIE
  • 1465 Points
  • Member since 2009
  • Principal
  • The Flywheel Group


  • Chatter
    Feed
  • 50
    Best Answers
  • 0
    Likes Received
  • 1
    Likes Given
  • 9
    Questions
  • 226
    Replies
Attempt to de-reference a null object - Need Help with Trigger

Hi, 
I need help with a trigger. Someone please help me on what I am doing wrong. Thank you.
My scenario is - For a person Account - Address, City & Zip are filled.
When a Case is created for that Customer - Address, City & Zip should automatically be filled. So that Sales reps don't have to fill those 3 fields again.
Here is my CODE
trigger CasesTrigger on Case (after insert){
    Set<Id> accIds = new Set<Id>();
    List<Case> lstCases = new List<Case>();
    for(Case objCase:trigger.new){
        accIds.add(objCase.AccountId);
        system.debug('ACCOUNTIDS'+accIds);
    }
    Map<ID, Account> MapAccIdtoAccount = new Map<ID, Account>([Select Id, Street__c, City__c, State__c, Zip__c from Account where Id IN:accIds]);
system.debug('ACCOUNTSMAP'+MapAccIdtoAccount);
    for(Case objCase:Trigger.new){
        Case oCase = new Case();
       
    if(MapAccIdtoAccount.containsKey(objCase.AccountId))
{
         oCase.Address_Line1__c = MapAccIdtoAccount.get(oCase.AccountId).Street__c ;
            system.debug('ADDRESS---'+oCase.Address_Line1__c); 
           oCase.City__c = MapAccIdtoAccount.get(oCase.AccountId).City__c ;
            oCase.State__c = MapAccIdtoAccount.get(oCase.AccountId).State__c ;
           oCase.Zip__c = MapAccIdtoAccount.get(oCase.AccountId).Zip__c ;
        lstCases.add(oCase);
         system.debug('oCASE'+oCase); 
            }
            }
    if(lstCases.size()>0){
        update lstCases;
    }
}
  • September 23, 2015
  • Like
  • 0
In  Trailhead, the instructions state:  
You've been given a requirement to keep Contact addresses in sync with the Account they belong to. Use Process Builder to create a new process that updates all child Contact addresses when the address of the Account record is updated. This process:Can have any name.
Must be activated.
Must update Contact mailing address fields (Street, City, State, Post Code, Country) when the parent Account shipping address field values are updated.
NOTE: You may have to deactivate the validation rule created from a previous challenge in order to complete this challenge.


I worked and reworked this module and I cannot figure out what is wrong.  I have deleted the previous validation I created in a previous module.  Is there something wrong in my criteria or actions?   

This is the error that I am getting when I check the challenge:  
     Challenge not yet complete... here's what's wrong: 
     An update to an account record failed to update the mailing address fields of all child contact        records. Make sure that the process is correct and that it is activated.

Here are my screenshots:
User-added imageUser-added image
Gurus, 
I am trying to insert data into Product2 and PriceBookEntry from a staging Object Product_Stage__c

The class is as follows:
global class batchPInsert  implements Database.Batchable<sObject>,Database.Stateful
{
  global integer SizeP = 0;
    global Database.QueryLocator start(Database.BatchableContext BCPI)
    {
        string operation;
        operation='Insert';
        String query = 'SELECT CCO_Standard_Cost__c,IsActive__c,Dealer_Price__c,Description__c,Discount_Code__c,IP_Classification__c,Item__c,Name,Product_Type__c,Salesforce_Id__c FROM Product_Stage__c';
        query=query +' WHERE Operation_Type__c = \'' + String.escapeSingleQuotes(operation) + '\'';
        return Database.getQueryLocator(query);
    }
   
    global void execute(Database.BatchableContext BCPI, List<Product_Stage__c> scope)
    {
        List<Product2> lstP = new List <Product2>();
        List<PriceBookEntry>lstPBE=new List <PriceBookEntry>();
        Id StandardPriceBookID=[SELECT Id FROM Pricebook2 WHERE Name = 'Standard Price Book'].Id;
        for(Product_Stage__c PStg : scope)
         {
           Product2 P = new Product2();
           PriceBookEntry PBE=new PriceBookEntry();
           P.CCO_Standard_Cost__c=PStg.CCO_Standard_Cost__c;
           P.Dealer_Price__c=PStg.Dealer_Price__c;
           P.Description__c=PStg.Description__c;
           P.Discount_Code__c=PStg.Discount_Code__c;
           P.IP_Classification__c=PStg.IP_Classification__c;
           P.Item__c=PStg.Item__c;  
           P.Name=PStg.Item__c;
           P.Product_Type__c=PStg.Product_Type__c;
			P.IsActive=PStg.IsActive__c;
           lstP.add(P);
           insert(lstP);
           PBE.Pricebook2Id=StandardPriceBookID;
           PBE.Product2Id=P.Id;
           PBE.UnitPrice=P.Dealer_Price__c; 
           PBE.IsActive=True;
           lstP.clear();
           lstPBE.add(PBE);
         }
        SizeP+=scope.size(); 
        insert(lstPBE);
        delete(scope);
    }   
    global void finish(Database.BatchableContext BCPI)
    {
        String email;
        //email='gagnihotri@pelco.com';
        AsyncApexJob a = [SELECT Id, Status, NumberOfErrors, JobItemsProcessed,TotalJobItems, CreatedBy.Email FROM AsyncApexJob WHERE Id =:BCPI.getJobId()];
        //SizeP= [SELECT Count() from Product_Stage__c WHERE Operation_Type__c = 'Insert'];
        Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
		mail.setToAddresses(new String[] {'gagnihotri@pelco.com','nhombal@pelco.com','dfisher@schneider-electric.com','ron.adolph@schneider-electric.com'});
		mail.setReplyTo('gagnihotri@pelco.com');
		mail.setSenderDisplayName('Batch Processing');
		mail.setSubject('Batch Process Completed for insert on Products');
		if (a.Status == 'Completed')
		mail.setPlainTextBody('The batch Apex job processed ' + a.TotalJobItems +' batches of batch size '+ SizeP+ ' with '+a.NumberOfErrors + ' failures.');		
        //if (a.Status == 'Failed')
        //mail.setPlainTextBody('The batch Apex job processed ' + a.TotalJobItems +' batches of batch size '+ SizeP+ ' with '+a.NumberOfErrors + ' failures. Failure Message: '+a.ExtendedStatus);	
        Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
    }
}

The Test class:
@istest
private class TestBatchPInsert {
	static testMethod void batchPMethod1(){
        Id SPBId=test.getStandardPricebookId();
        Product2 P=new Product2();
        P.CCO_Standard_Cost__c=109071.45;
        P.Dealer_Price__c=441373.0;
        P.Description__c='CM9770-992X128 High Density System';
        P.Discount_Code__c='D';
        P.IP_Classification__c='Analog';
        P.IsActive=true;
        P.Item__c='CM9770-992X128';
        P.Name='CM9770-992X128';
        P.Product_Type__c='Matrix';
        insert P;
        PriceBookEntry PBE=New PriceBookEntry();
        PBE.Pricebook2Id=SPBId;
        PBE.Product2Id=P.Id;
        PBE.UnitPrice=100;
        //PBE.Name='CM9770-992X128';
        //PBE.ProductCode='AU';
        Insert PBE;
      	Product_Stage__c PStg= new Product_Stage__c();
        PStg.CCO_Standard_Cost__c=109071.45;
        PStg.Dealer_Price__c=441373.0;
        PStg.Description__c='CM9770-992X128 High Density System';
        PStg.Discount_Code__c='D';
        PStg.IP_Classification__c='Analog';
        PStg.IsActive__c=true;
        PStg.Item__c='CM9770-992X128';
        PStg.Name='CM9770-992X128';
        PStg.Product_Type__c='Matrix';
        PStg.Salesforce_Id__c=P.Id;
        insert PStg;
        
        system.debug('Product Stage Id='+PStg.Id);
        //Test Start
      	Test.StartTest();
		batchPInsert  pr4= new batchPInsert ();
		database.executeBatch(pr4);
        //pr4.execute(null, new list<Product_Stage__c> {PStg});
        //pr4.execute(null, new list<Product_Stage__c> {PStg});
		Test.StopTest(); 
        //Test Stop
    }
}

The complete execute function  has zero code coverage.
Error Code Coverage in RED

Any suggestions?
Gaurav
Hello; I have two formula fields;
1 - "Days To Pay" - Which is a case
CASE(Location_State__c, 
"RI", "7", 
"MA", "8", 
"CT", "8", 
"NH", "14", 
"ME", "14", 
"VT", "14", 
"NJ", "8", 
"NY", "8", 
"")

2 - "Days Signed" which returns a number
IF(Date_Certified_Signed__c < TODAY(), TODAY() - Date_Certified_Signed__c , NULL)

The first formula (Picklist) returns a Text value, the second, returns a number value,
I am attempting to build a formula which will identify when the "Days Signed" number value exceeds the "Days to Pay" text value, each record.
I have had no luck and could use some help.
Thank You,
Chris

 
One of the challenges was to return names from leads and contacts. 
Code looks like this:
public class ContactAndLeadSearch {
    public static List<List<SObject>> searchContactsAndLeads(String FindName)
    {
        list<list<sObject>> ReturnName = [find :FindName IN ALL FIELDS Returning lead(FirstName, LastName), contact(firstname, lastname)];
        
        return ReturnName;
    }
}
When looking at the return ReturnName, how can you determine from what object the First/Last Name was retrieved? Lead?Contact?
Other examples used the  [0] and [1] in their examples when they were traversing multiple object but they only had one "find" in each object. 
Just curious as I do  understand the [x][y] notation in list<list> concepts.
I have 2 triggers which are nearly identical, one sends an email to Leads and the other sends emails to Contacts.  They both work but the HTML Status related list is only populated for the emails sent to Contacts.  When an email is sent to a lead it shows up under activity history but not HTML Status.  It is important to be able to see if/when an email was opened.

I have snippets from both the Lead and Contact triggers so you can see they are nearly identical.  Any thoughts on why HTML Status works for my Contacts but not my Leads?
 
if (combine==true){        
                   	contactlog = mapcontactToUpdate.get(e.id);	
                	mapcontactToUpdate.put(contactlog.id, contactlog);
                    Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
                    string etidasstring = a.ezwf__Email_Template_ID__c;
                    emailt = e.Lastname; 
                    mail.setSenderDisplayName(UserInfo.getName());
                    mail.setReplyTo(UserInfo.getUserEmail()); 
                    mail.setTargetObjectId(e.id);
                    mail.setTemplateId(etidasstring);
                    mail.setSaveAsActivity(true); 
                	myEmails.add(mail);	
            }
              if (myEmails.size() > 0)
            {
                       Messaging.sendEmail(myEmails);
            }

if (combine==true){        
                   	Leadlog = mapLeadToUpdate.get(e.id);	
                	mapLeadToUpdate.put(Leadlog.id, Leadlog);
                    Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
                    string etidasstring = a.ezwf__Email_Template_ID__c;
                    emailt = e.Lastname; 
                    mail.setSenderDisplayName(UserInfo.getName());
                    mail.setReplyTo(UserInfo.getUserEmail()); 
                    mail.setTargetObjectId(e.id);
                    mail.setTemplateId(etidasstring);
                    mail.setSaveAsActivity(true); 
                	myEmails.add(mail);	
            }
              if (myEmails.size() > 0)
            {
                       Messaging.sendEmail(myEmails);
            }

 
HI I have the following code but i get an error. I dont know why I cant show the recent opportunities 
public with sharing class OppExt {
    


     public List<Opportunity> myOpportunities { get; private set; }

     public OppExt(){
     myOpportunities = [ SELECT Id, Name, Account.Name
                 from Opportunity 
                 WHERE OwnerId = :UserInfo.getUserId()];

 }
 //Set<Opportunity> ids = new Set<Opportunity>();
        
public List<Opportunity> getOpp() {

 System.debug(myOpportunities);
   return myOpportunities;

}

}


Apex page


    <header>
        <div class="container">
            <div class="intro-text">
                               
                <a href="#services" class="page-scroll btn btn-xl">Create New Opportunity</a>
                   <a href="#services" class="page-scroll btn btn-xl">Add to Existing Opportunity</a>
                   <a href="#services" class="btn-custom">Add to Existing Opportunity</a>
                   <div class = "span4">
                           <button class="btn custom large f" >Foxtrot</button>
                   </div>
                   
            </div>
            <apex:outputText value="{!$User.Id}"/> 
            <apex:outputText value="{!$User.FirstName}"/>
            <apex:outputText value="{!$User.LastName}"/>
            <!-- <apex:outputfield value="{!currentuser.Id}"/> -->
            <apex:repeat >
            <apex:outputText value="{!myOpportunities.Name}"/>
            </apex:repeat>
            

        </div>
    </header>
</apex:page>
* How to overcome of if i want to use more than 150 DML statements in apex . as per governer limit we cant use than 150 DML , to overcome this what we need to do?

 
I am trying to create a validation rule which references a picklist field [Field A] and a formula field(text) [Field B]

Field A has options A1, A2, A3 = picklist 
Field B has options B1, B2, B3 = Formula

How would I create a validation rule that allows for the following conditions, if any are met: 
If Field A = A1 and Field B = B1
If Field A = A2 and Field B = B1 or B2
if Field A = A3 and Field B = B1 or B2 or B3

The formula I am attempting to write is : 
If (and( ispickval(Field A = A1, Contains(Field B = B1),,
If (and(ispickval(field A = A2, OR(Contains(Field B = B1, Contains(Field B = B2),,
If (and(ispickval(field A = A3, OR(Contains(field b = B1, Contains(Field B = B2, Contains(Field B = B3,,
)))

Is it appropriate to use a 'IF" statement or would an "OR" statement be more appropriate?

Any help would be grateful!

Thanks,

I have the following formula feild. Based on the average rent it receives an applicable score.
IF(Average_Rent__c > 2999, 14.00, 
IF(Average_Rent__c> 1099, 10.50, 
IF(Average_Rent__c > 699,7.00, 
IF(Average_Rent__c < 700, 1.75, NULL)))).

I need update it to include a multipler based on a picklist field "Region" and its values New York, Chicago, Los Angeles.

So if the picklist "Region", value is New York,  multiple the Average rent by 3, Chicago by 1.5 and Los Angeles by 2.

 


 

  • September 15, 2015
  • Like
  • 0
While run a following code i have got error like 
[Error] Error: Mycontroller Compile Error: Illegal assignment from List<Account> to Account at line 6 column 3
Can anybody give a solution ?
CODE:
<apex:page controller="Mycontroller" tabStyle="Account">
<apex:form >
<apex:pageBlock title="Account Details">
<apex:pageBlockSection title="Account information">
    <apex:inputField value="{!Account.Name}"/>
    <apex:inputField value="{!account.Phone}"/>
    <apex:inputField value="{!account.Industry}"/>
    <apex:inputField value="{!account.Website}"/>
</apex:pageBlockSection>
<apex:pageBlockSection title="Account Details">
    <apex:inputField value="{!Account.Fax}"/>
    <apex:inputField value="{!Account.Shippingcity}"/>
    <apex:inputField value="{!Account.AnnualRevenue}"/>     
</apex:pageBlockSection>
<apex:pageBlockButtons>
 <apex:commandButton action="{!Save}" value="Save"/>
</apex:pageBlockButtons>
</apex:pageBlock>
</apex:form>
</apex:page>
CLASS:
public with sharing class Mycontroller
{
 Public Account acc;
 Public Mycontroller()
 {
  acc=[SELECT id,Name,Phone,Industry,Website,Fax,Shippingcity,AnnualRevenue from account Where id=:ApexPages.currentpage().getparameters().get('id')];
  }
 Public account getaccount()
 {
  return acc;
  }
 Public Pagereference Save()
 {
 update acc;
 pagereference page=new Apexpages.StandardController(acc).view();
  return Page; 
 }
}
Hi, 

   I wrote a workflow to update account type when opportunity approval is approved ( approval in opportunity is tracled through a flag called status) but this is failing please suggest me I even wrote a trigger to update this is not firing when approval is approved when edited it is working 

 
trigger Account_Type_Update on Opportunity (After Update) 
{

Public List<Opportunity> Optys = New List<Opportunity>();
Public List<Account> Acct = new List<Account>(); 

  Optys = [SELECT Id,AccountID,Account.ID,Account.RecordTypeID, RecordType.name,RecordTypeID,Is_Approved__c 
            FROM Opportunity
            WHERE Id = :Trigger.newMap.keySet() ]; 
  
  
  for ( Opportunity  Opp : Optys )
   {
     if ( (Opp.RecordTypeID == '012250000008i5uAAA' || Opp.RecordTypeID ==  '01225000000ChlOAAS' || Opp.RecordTypeID == '01225000000ChlEAAS' ) && Opp.Is_Approved__c == True)
      {
        Acct = [SELECT RecordTypeID,Type FROM Account WHERE ID = :Opp.AccountID ]; 
        
          for ( Account Act : Acct )
           {
             Act.Type = 'Client';
             
             Update Act;
             }           
             
      
       }
     
     
   
     } 
   



}

Please suggest me 

Thanks
Sudhir
I logged into my cs9 sandbox this morning and debug logs look different.  You now have to create something called a "Trace Flag".  To do this, you have to specify the Debug Level, which I understand to be a value like "INFO", "FINE" or "FINER".  However, values like these don't appear to be accepted.  See screen shot.

User-added image

Clicking the lookup icon gets me nowhere -- it says there aren't any results, no matter what I enter.  Help!
I have a Schedulableclass which is scheduled to execute every night at 12:00 AM,  here is my class, 
global class SalesOrderSchedule implements Schedulable
{

global static void checkrun()
    {
 String day = string.valueOf(system.now().day());
                String month = string.valueOf(system.now().month());
                String hour = string.valueOf(system.now().hour());
                String minute = string.valueOf(system.now().minute());
                String second = string.valueOf(system.now().second());
                String year = string.valueOf(system.now().year());

                String JobName = 'Scheduled Job of sales Order';
                String strSchedule = second +' ' + minute+' '+ hour+' '+ day+' '+month+' ?'+' '+ year;
                system.schedule(JobName, strSchedule, new SalesOrderSchedule());    
    }    
  global void execute(SchedulableContext sc)
  {
  Opportunity opp;
    
  for (Sales_Order__c salesorders : [select id, Name, LastModifiedDate,    Quote__c, OrderNum__c from Sales_Order__c WHERE LastModifiedDate  >= LAST_N_DAYS:1])
         {
             String OppNewStage=null;
             if (salesorders.OrderNum__c=='QUOTE WON')
             {
             OppNewStage='Closed Won';
              }
             else if (salesorders.OrderNum__c=='QUOTE LOST')
             {
             OppNewStage='Closed Lost';
             }
             else 
             {
              OppNewStage='Quoted';
             }
             
       opp=[select id, Name, StageName from Opportunity where id=:salesorders.Quote__c]; 
     opp.StageName=OppNewStage;
     update opp;
     
    
     }
     

   
  }
}

here is my test class,  my code coverage is 13%. 
@isTest
public class SalesOrderScheduleTest {
    static testMethod void myTestMethod() {        
         test.starttest();
     SalesOrderSchedule.checkrun();
     
   String chron = '0 0 12 15 9 ? 2015' ;        
         system.schedule('job', chron, new SalesOrderSchedule());
         test.stopTest();
    }
}

 

Static checkrun method is not covering, how to increase the code coverage ?? Guys help 

I need to add account attachments to the chatter feed automatically. I have the following code which adds all attachments to the chatter feed, not just Account object attachments. How can I make it specific to the account object? Or make it specific to a file name?
 
trigger AttachFileToAccountFeed on Attachment (before insert) {   
    ID accountId; 
    list<FeedItem> listOfFeedFiles = new List<FeedItem>(); 
 
    if(Trigger.isBefore){
     
        for(Attachment attachment : trigger.new){
           string checkIfCase = string.valueof(attachment.Description);
          
           {
                //Adding a Content post
                accountId = attachment.ParentId;
                FeedItem post = new FeedItem();
                post.ParentId = accountId; //eg. Opportunity id, custom object id..
                post.Body = 'Attachment added';
                post.Type = 'ContentPost';
                post.ContentData = attachment.body;
                post.ContentFileName = attachment.Name;
                post.Title = attachment.Name;
                listOfFeedFiles.add(post);         
           }
        }
    }
     
    if(listOfFeedFiles!=null){
        insert listOfFeedFiles;
    }  
     
}

 
Hi,

I'm new to Salesforce and I want to know how can I get back the user details that I stored ID in string data type. Ex

public class vSFDCuseinfo{
public string auserid {get;set;}
public string aName{get;set;}
public vSFDCuseinfo (){
     
      auserid= UserInfo.getUserId();
      aName = auserID.username;    // how to get the username (firstname, lastname etc) from ID stored in string format? 
      

}
Thanks 

Vish
  • September 10, 2015
  • Like
  • 0
Hello,

I have a button on the Opportunity object that clones a record from a related custom object.  The clone works fine, but it opens the standard edit page for the custom object.  Instead, I would like the clone to open a custom VF edit page.  Is this possible to do?  My current URL for the button is:
 
onClick="window.open('/{!Opportunity.Sumary__r.Id}/e?clone=1','_blank')"

 
My Visualforce page has an extension has a public method: TopOneHundred();  which returns a JSON string.  Though there are ways to execute the class method using Javascript, I'm not sure how to obtain the returned JSON string for use in my Javascript. The TopOneHundred() method uses other variables from the extension in order to return the correct string.  This is done because the user is interacting with some picklists on the VF page and we're executing the TopOneHundred() method using the picklists choices. 

Because of this, I can't use Javascript remoting nor can I use the AJAX toolkit/sforce.apex.execute method because both require static keywords and the instance variables are not visible to static methods.  I'm greatful for any advice.

FYI The JSON string is used to populate a Datatables  (https://datatables.net/" target="_blank) table on the VF page.
 
Hi ,
Can some one please to add the space before FROM in Dynamic SOQL.
string query ='SELECT ' + qFields +
                       'FROM contact'+
                       ' WHERE user_num__c = \'' + String.escapeSingleQuotes(uNum) + '\''+
                       ' LIMIT 1';
  • September 08, 2015
  • Like
  • 0
Based on the SOSL documentation it appears that you can limit the searched fields to, among other things, Name Fields. The documentation makes it sound like you can designate certain fields to be Name Fields, but I have not been able to figure out how to do this.

Is it possible to designate an arbitrary field as a Name Field on an object, and if so, how is this done?

Hi guys,

 

I am using the mobile sdk in an existing project ( not using the template ).  To preface, this project is in xcode 4.3.3, targeting ios 5 and using storyboards. 

 

I've created a class which conforms to SFOAuthCoordinatorDelegate that is handling and displaying the OAuth dance.  This seems to all be working just fine and I can see that I'm being authenticated. 

 

However, this is where two strange things are happening.  First, in the oauthDidAuthenticate method I try to assign the coordinator to the SFRestAPI shared instance and I am getting an NSInvalidArgument exception that's referencing something to do with NSURL and queryParameters.  I believe it has something to do with the instanceUrl property on the coordinator's credentials, so I'm setting the instanceUrl to nil and then assigning the coordinator to the shared instance of SFRestAPI.

 

Next, I have a method that gets notified when the authentication has been successfully completed.  This method is in a class that conforms to SFRestDelegate.  Here I reset the instanceUrl property of the shared instance back to what it should be.  Then, I try to send a simple query for Contacts.  I can see in the logs that the request is being created with the proper endpoint, method, path, and queryParams, but none of the SFRestDelegate methods are getting any info back.  The flow just ends.

 

Has anyone else come across this and/or have any ideas?

 

Thanks as always,

 

Clint

 

I am having some trouble understanding the ability to Read Opportunities with the Authenticated Website License.

 

Overview:

We track the lifecycle and stages of our consumer customers with the Opportunity object.  I want to create a secure portal where they can simply view the information related to their Opportunities.  In order to do this they need to be authenticated. 

 

What I've Done:

I have a site which requires login and we are using the Authenticated Website license.  This profile does not have the option to grant Read access to Opportunities.  I have created a User with the Authenticated Website license and profile.  When logged in as this User I cannot display the Opportunities on a custom VF page. 

 

However, I wanted to test the ability to create an Opportunity when logged in as this user, so I created a button on the VF page that would create an Opportunity when clicked.  It worked and I was able to create an Opportunity when logged in as this User with the Authenticated Website License.  The Public Access Setting for this Site does grant Read and Create access on Opportunities but I don't know if that has anything to do with it.

 

This leaves me confused and having some questions:

1. I've been told that only the Partner Portal license has access to Opportunities.  If that's the case, why am I able to create Opportunities with the Authenticated Website license?

2. Do the Public Access Settings for the Site have any effect on access even when not using that particular license?

3. If I can create an Opportunity, why can I not view Opportunities when logged in with the Authenticated Website license?

 

Sharing settings for Opportunities are set to Public Read/Write.

 

Thanks in advance for any insight!

 

~ Clint

Hello All,

 

I have a question that I'm sure can be answered by the collective wisdom of the Salesforce community.

 

Background: 

I'm working on an application that utilizes Twilio to send SMS messages.  Sending outbound SMS messages is working fine.  If someone replies to one of these SMS messages Twilio will post an HTTP Request to a specified URL and it expects an HTTP response.  I set up a VF Sites page to act as a listener and execute the logic (i.e. attach the message to a custom object).  However, my dilemma is how can I control the HTTP response that my Sites page sends back?

 

Thanks in advance for your help,

 

Clint

 

http://www.clintslee.com

Hello,

 

I have spent some time searching the forums and reviewing the docs on Email Services and cannot find an answer to this, so I'm hoping the smart folks here can help me out.

 

I have an email service set up that accepts incoming emails.  Is there a way to check an incoming email to determine whether it is in HTML or PlainText format?

 

For example, something like this:

 

if (email is in HTML format) {

   do this code using email.htmlBody;

 

} else {

   do this code using email.plainTextBody;

}

 

Thanks in advance,

 

Clint

 

Hello,

 

I have spent some time searching the forums and reviewing the docs on Email Services and cannot find an answer to this, so I'm hoping the smart folks here can help me out.

 

I have an email service set up that accepts incoming emails.  Is there a way to check an incoming email to determine whether it is in HTML or PlainText format?

 

For example, something like this:

 

if (email is in HTML format) {

   do this code using email.htmlBody;

 

} else {

   do this code using email.plainTextBody;

}

 

Thanks in advance,

 

Clint

 

Hi,

 

I have a VF page with a form included on it that I am validating with jquery.  Thanks to some previous posts by @weznolte and @tehnrd I was able to create some pretty slick validation rules, but I am stumped on an issue with a checkbox that seems like it should be relatively straightforward.

 

What I need to accomplish is simply this - if the checkbox is checked then make a field required.  If the checkbox is not checked, then this field is not required. 

 

The variable "isdedicated" holds the ID of the checkbox.

The variable "recipFName" holds the ID of the field that needs to be conditionally required based on the checkbox.

The last rule in the first set of code is my (ump-teenth) attempt at making this work. 

 

It seems that the value of my rule function always returns true, because when the form validates "recipFName" is always required regardless of whether the checkbox is checked or not.

 

 

Here is the code to invoke the validate() method and includes the rules.

 

<script type="text/javascript">
var j$ = jQuery.noConflict();

j$(document).ready(function() {
j$(jq(f)).validate();

j$(jq(dFName)).rules("add",{
required: true,
minlength: 2
});

j$(jq(dLName)).rules("add",{
required: true,
minlength: 2
});

j$(jq(dEmail)).rules("add",{
required: true,
email: true
});

j$(jq(dAddress)).rules("add",{
required: true,
minlength: 5
});

j$(jq(dCity)).rules("add",{
required: true,
minlength: 5
});

j$(jq(dState)).rules("add",{
required: true,
minlength: 2
});

j$(jq(dZip)).rules("add",{
required: true,
minlength: 5
});

j$(jq(dCountry)).rules("add",{
required: true,
minlength: 2
});

j$(jq(dAmount)).rules("add",{
required: true
});

j$(jq(rFName)).rules("add",{
required: function jq() { return
j$(jq(isDedicated)).is(':checked') == true;
}
});

jQuery.validator.messages.required = "Oops! This field is required!";
});
</script>

 

 

And this is the form code.

 

<apex:form id="donForm">
<script type="text/javascript">
var dFName = "{!$Component.donorFirstName}";
var dLName = "{!$Component.donorLastName}";
var dEmail = "{!$Component.donorEmailAddress}";
var dAddress = "{!$Component.donorAddressStreet}";
var dCity = "{!$Component.donorAddressCity}";
var dState = "{!$Component.donorAddressState}";
var dZip = "{!$Component.donorAddressZip}";
var dCountry = "{!$Component.donorAddressCountry}";
var isDedicated = "{!$Component.isDedicated}";
var rFName = "{!$Component.recipFName}";
var dAmount = "{!$Component.donAmount}";
</script>

<apex:outputLabel for="donorFirstName">First Name</apex:outputLabel>
<apex:inputText id="donorFirstName" value="{!donorFName}" />

<apex:outputLabel for="donorLastName">Last Name</apex:outputLabel>
<apex:inputText id="donorLastName" value="{!donorLName}" />

<apex:outputLabel for="acctName">Company Name (optional)</apex:outputLabel>
<apex:inputText id="biz" value="{!acctName}" />

<apex:outputLabel for="donorEmailAddress">Email</apex:outputLabel>
<apex:inputText id="donorEmailAddress" value="{!donorEmail}" />

<h3>Address Information</h3>

<apex:outputLabel for="donorAddressStreet">Street Address</apex:outputLabel>
<apex:inputText id="donorAddressStreet" value="{!donorAddress}" />

<apex:outputLabel for="donorAddressCity">City</apex:outputLabel>
<apex:inputText id="donorAddressCity" value="{!donorCity}" />

<apex:outputLabel for="donorAddressState">State</apex:outputLabel>
<apex:inputText id="donorAddressState" value="{!donorState}" />

<apex:outputLabel for="donorAddressZip">Zip</apex:outputLabel>
<apex:inputText id="donorAddressZip" value="{!donorZip}" />

<apex:outputLabel for="donorAddressCountry">Country</apex:outputLabel>
<apex:inputText id="donorAddressCountry" value="{!donorCountry}" />

<h3>Dedication Info</h3>

<apex:outputLabel for="isdedicated">Dedicate in the name of a friend </apex:outputLabel>
<apex:inputCheckbox id="isDedicated" value="{!isDedicated}"/>


<apex:outputLabel for="recipFName">First Name</apex:outputLabel>
<apex:inputCheckbox id="recipFName" value="{!recipFName}" />

<--Rest of form code here-->
</apex:form>

<script type="text/javascript">
function jq(myid) {
return '#' + myid.replace(/(:|\.)/g,'\\\\$1');
}
var f = '{!$Component.donForm}';
</script>

 

Any help would be much appreciated!  Thanks.

 

Clint

 

Hello All,

 

We recently launced a solutions page for our customers by generating the HTML code through the Public Solutions feature in Salesforce.  The solutions display in an iframe on our page and everything is functioning correctly except for the fact that there are two unwanted columns that are visible to our customers, they are 'Number of Related Cases' and 'Last Modified Date'.  

 

I searched for a way to remove these columns as we do not want our customers to be able to see them.  I couldn't find any documentation around this so I submitted a case to Salesforce Support, whereby I was told that I needed to modify the HTML code but they could not tell me how and subsequently pointed me to the developer board.

 

Here is the HTML code that is generated -

 

<IFRAME title="Content" src="http://na4.salesforce.com/sol/public/search.jsp?orgId=00D300000006JjL" WIDTH="515" HEIGHT="360"></IFRAME>

 

Any ideas how I can modify the Public Solutions HTML to remove the two columns? 

 

Thanks for your help.

 

Clint

Hello All,

 

I am trying to determine the best route for displaying image attachments on a VF Page.  

 

More specifically, I have an object called Site_Development__c which contains information about construction projects.  I would like for a user to be able to attach image files to the record (as attachments) which will then be displayed via a VF Page.  

 

Ideally I would like to create the VF page so that it could be inserted into the Site_Development__c page layout.  However, this requires using the Site_Development__c standard controller so I would need to create a controller extension and I am having trouble doing that.

 

Another option that I thought might be easier would be to create a VF page that simply displays all of the image attachments and then create a button on the Site Development page layout that links to this page.  However, I'm not certain if there is a simple way to display the images (like if I wanted to show the user's first name I could just do {!$User.firstname}).

 

Looking over some of the other posting I tried to patch together some code for an extension but I'm getting error messages saying invalid constructor.  

 

Extension (sorry in advance if the code looks weird, I always have trouble posting code in here)

 

public class SiteDevExtension {

private final tfgff__Site_Development__c siteDev;

public SiteDevExtension(ApexPages.StandardController stdController) {
this.siteDev = (tfgff__Site_Development__c)stdController.getRecord();
}

public List<Attachment> pics {get;set;}

public SiteDevPicDisplay() {
pics = [Select a.ParentId, a.Name From Attachment a where ParentId=System.currentPageReference().getParameters().get('id')];
}
}

 

 VF Page Snippet

 

 

<apex:repeat value="{!pics}" var="p">
{!URLFOR($Action.Attachment.Download, p.Id)}
</apex:repeat>

 

 Any feedback or recommendations would be greatly appreciated.

 

Thanks!

 

 

 

 

Hi, 

 

I am fairly new to Apex development and programming in general.  My particular issue is that I am having trouble creating a test method for a custom controller.  I have a VF page with a simple form for submitting cases, and a custom controller to handle it.  I've deployed the VF page and controller to my developement org and everything works properly.  Now I want to deploy it to production but need test coverage.  

 

I have read through the Apex Developer's Guide and countless forum postings on developing test methods but I am still stumped.  

 

Below is the VF page, Custom Controller class, and my current (inadequate) test method.

 

VF Page: simple case submit form

 

<apex:page controller="SubmitCaseController"> <h1>Submit New Case</h1> <apex:form > <apex:pageMessages /> <table> <tr> <th>Your Name:</th> <td><apex:inputText value="{!c.SuppliedName}"/></td> </tr> <tr> <th>Your Email:</th> <td><apex:inputText value="{!c.SuppliedEmail}"/></td> </tr> <tr> <th>Your Account Number:</th> <td><apex:inputText required="true" value="{!acctNum}"/></td> </tr> <tr> <th>Title:</th> <td><apex:inputText required="true" value="{!c.Subject}"/></td> </tr> <tr> <th>Your Problem:</th> <td><apex:inputTextArea required="true" rows="5" value="{!c.Description}"/></td> </tr> <tr> <td><apex:commandButton value="Submit Case" action="{!submitCase}"/></td> </tr> </table> </apex:form></apex:page>

 

 Custom Controller: The general functionality is to use the acctnum field to match an existing account.  Then, find the appropriate contact by matching the account and email address.  Then insert the case.

 

public with sharing class SubmitCaseController { public Case c { get; set; } public String acctNum { get; set; } public SubmitCaseController() { c = new Case(); } public PageReference submitCase() { List<Account> accts = [SELECT Id FROM Account WHERE AccountNumber = :acctNum]; if (accts.size() != 1) { ApexPages.Message msg = new ApexPages.Message(ApexPages.Severity.FATAL, 'Invalid account number'); ApexPages.addMessage(msg); return null; } else { try { c.AccountId = accts.get(0).Id; // now look for an associated contact with the same email Contact cnt = [SELECT Id FROM Contact WHERE AccountId = :c.AccountId AND Email = :c.SuppliedEmail LIMIT 1]; if (cnt != null) c.ContactId = cnt.Id; // Specify DML options to ensure the assignment rules are executed Database.DMLOptions dmlOpts = new Database.DMLOptions(); dmlOpts.assignmentRuleHeader.useDefaultRule = true; c.setOptions(dmlOpts); // Insert the case INSERT c; return new PageReference('/thanks'); } catch (Exception e) { ApexPages.addMessages(e); return null; } } }}

 

 My current test method:

 

@isTestprivate class SubmitCaseControllerTests { public static testMethod void testSubmitCaseController() {PageReference pageRef = Page.PortalCaseSubmit; Test.setCurrentPage(pageRef); Account testaccount = new Account(name = 'Acme', AccountNumber='123456'); insert testaccount; Contact testcontact = new Contact(firstname='joe', lastname='smith', email='joe@smith.com'); insert testcontact; Case c; c.SuppliedName='Joe Smith'; c.SuppliedEmail='joe@smith.com'; c.Subject = 'Test'; c.Description = 'This is a test.'; String acctnum = '123456'; SubmitCaseController controller = new SubmitCaseController(); controller.submitcase(); Case cases = [Select ID, subject, description from Case Where account.id = :testaccount.id]; System.assertequals(cases.description, c.description); } }

 

My logic is to instantiate an account and contact and insert them into the database.  Then, mimic the process of someone completing the form and submitting it.  I could test both positive and negative results this way.  However, I am stumped as to how to populate the form fields and submit the form using Apex.  Any help would be appreciated.

 

Thanks,

 

Clint 

 

 

 

 

We are trying to use the function addError() of sObject instead of ApexPages.AddMessage() in the controller to display error message on the visualforce page right beneath to the inputfield. However when the error is displayed, it shows up on the general section of the tag <apex:pagemessages>, but it does not show up underneath the inputfield. 

Here is a screenshot
User-added image


Here is the test visualforce page with just one field to display for testing. 
<apex:page standardcontroller="Apttus__APTS_Agreement__c" extensions="RequestorALL_VF_Controller" id="page">
    <apex:sectionheader title="test"/>
    <apex:form id="formId">
        <apex:pagemessages/>
        <apex:pageblock>
            <apex:pageblockbuttons id="Buttons">
                <apex:commandbutton value="Save Request" action="{!Save}" />
                <apex:commandbutton value="Cancel" action="{!Cancel}"/>            
            </apex:pageblockbuttons>
                    
            <apex:pageblocksection id="MainInfoSection">
                <apex:inputField value="{!Apttus__APTS_Agreement__c.Name}" required="false"/>
            </apex:pageblocksection>
                
        </apex:pageblock>

        <apex:outputLabel value="{!Apttus__APTS_Agreement__c.Contracting_Party__r.International_Status__c}" rendered="false" />    
        <apex:outputLabel value="{!Apttus__APTS_Agreement__c.Contracting_Party__r.BillingCountry}" rendered="false" />
        <apex:outputLabel value="{!Apttus__APTS_Agreement__c.Contracting_Party__r.Type}" rendered="false" />
        <apex:outputLabel value="{!Apttus__APTS_Agreement__c.Contracting_Party__r.HCP__c}" rendered="false" />
        <apex:outputLabel value="{!Apttus__APTS_Agreement__c.Contracting_Party_2__r.International_Status__c}" rendered="false" />
        <apex:outputLabel value="{!Apttus__APTS_Agreement__c.Contracting_Party_2__r.BillingCountry}" rendered="false" />
        <apex:outputLabel value="{!Apttus__APTS_Agreement__c.Contracting_Party_2__r.Type}" rendered="false" />
        <apex:outputLabel value="{!Apttus__APTS_Agreement__c.Contracting_Party_2__r.HCP__c}" rendered="false" />
    </apex:form>    
</apex:page>

and the snippet of the controller code ...

private boolean showError(SObject sObj, string sName, string errMsg) {
        boolean hasError = false;
        if (sName == null || sName == '') {
            if (errMsg == null) sObj.addError('the value is required');
            else sObj.addError(errMsg);
            hasError = true;
        }
        return hasError;
    }
if (showError(obj, obj.Name, 'Agreement Name is required')) hasError = true;


Any help is appreciated.
  • September 27, 2015
  • Like
  • 0
Im trying get the selected recordtype into the controller to build additional rendering logic in showTranLog() method based on input selection but its always returning null. when i insert the record in saveproceed() method its getting set fine.
<apex:page standardController="Contact" extensions="TaskExtensionCtrl">

  <apex:form >
    <apex:pageBlock title="New Log" mode="edit" id='pb'>
    <apex:pageBlockSection id="selectedRecordType" columns="1">
        <apex:pageBlockSectionItem >
            <apex:outputLabel value="Choose Record Type" for="rt" />         
            <apex:panelGrid columns="2">
            <apex:selectList value="{!selectedrecType}" multiselect="false"  size="1" required="true">
                <apex:selectOptions value="{!rectypes}"/>
                <apex:actionSupport event="onchange" action="{!showTranLog}" reRender="pb" status="status" immediate="true"/>
            </apex:selectList> 
            </apex:panelGrid>       
        </apex:pageBlockSectionItem>
    </apex:pageBlockSection>
     <apex:pageBlockButtons location="bottom">
        <apex:commandButton value="Save" action="{!saveAndProceed}" />
      </apex:pageBlockButtons>
    </apex:pageBlock>
  </apex:form>
</apex:page>
 
Controller:

public with sharing class TaskExtensionCtrl {
    public String partId;
    public Task task {get;set;}
    public boolean isShowTranLog  {get;set;}{isShowTranLog=false;}
    public string selectedrecType{get;set;}

    public TaskExtensionCtrl(ApexPages.StandardController controller){
        partId=ApexPages.currentpage().getParameters().get('id');
        createTaskRecord();
    }

    public void createTaskRecord() {
        system.debug(LoggingLevel.error,'in creat task'+selectedrecType);
        task = new Task();
    }
    public PageReference showTranLog(){
          this.isShowTranLog = true;
          system.debug(LoggingLevel.error,'task record type in showTranLog#'+ task.RecordTypeID+Task);
          return null;
     }    
    public List<SelectOption> getrectypes() {

        List<SelectOption> options = new List<SelectOption>();
        options.add(new SelectOption('','--Select Record Type --'));
        for(RecordType rt:[select id,name from RecordType where sobjecttype='task']){
            options.add(new SelectOption(rt.id,rt.name));    
        }
        return options;
    }

    public String getselectedrecType() {
        return selectedrecType;
    }

    public void setselectedrecType(String selectedrecType) {
        this.selectedrecType= selectedrecType;
    }


 
  • September 23, 2015
  • Like
  • 0
Trying to create a custom button in VF page that grabs a field value and then subtracts 1 from the presently queried record.  Having trouble.  I can built a button with the underlying code that renders the button but when I click it I get the error of this thread post:

"Visualforce Error Help for this Page  Formula Expression is required on the action attributes."  

I presume this is due to how it's calling the record, but don't know what to change.
 
<apex:commandbutton value="Return to Prev Dept" action="{!RPP_Tracker__c.Present_Dept_Number__c - 1}" />
Probably a syntax error, what am I doing wrong?
 
Attempt to de-reference a null object - Need Help with Trigger

Hi, 
I need help with a trigger. Someone please help me on what I am doing wrong. Thank you.
My scenario is - For a person Account - Address, City & Zip are filled.
When a Case is created for that Customer - Address, City & Zip should automatically be filled. So that Sales reps don't have to fill those 3 fields again.
Here is my CODE
trigger CasesTrigger on Case (after insert){
    Set<Id> accIds = new Set<Id>();
    List<Case> lstCases = new List<Case>();
    for(Case objCase:trigger.new){
        accIds.add(objCase.AccountId);
        system.debug('ACCOUNTIDS'+accIds);
    }
    Map<ID, Account> MapAccIdtoAccount = new Map<ID, Account>([Select Id, Street__c, City__c, State__c, Zip__c from Account where Id IN:accIds]);
system.debug('ACCOUNTSMAP'+MapAccIdtoAccount);
    for(Case objCase:Trigger.new){
        Case oCase = new Case();
       
    if(MapAccIdtoAccount.containsKey(objCase.AccountId))
{
         oCase.Address_Line1__c = MapAccIdtoAccount.get(oCase.AccountId).Street__c ;
            system.debug('ADDRESS---'+oCase.Address_Line1__c); 
           oCase.City__c = MapAccIdtoAccount.get(oCase.AccountId).City__c ;
            oCase.State__c = MapAccIdtoAccount.get(oCase.AccountId).State__c ;
           oCase.Zip__c = MapAccIdtoAccount.get(oCase.AccountId).Zip__c ;
        lstCases.add(oCase);
         system.debug('oCASE'+oCase); 
            }
            }
    if(lstCases.size()>0){
        update lstCases;
    }
}
  • September 23, 2015
  • Like
  • 0
Hi there, 

I made 3 seperate triggers to update 3 different fields on the account level. How do I combine them into one trigger for best practices. Code is below. Thanks for the help.
trigger act_opp_subscrip on Account (before insert, before update) {
    List<Opportunity> oppList = new List<Opportunity>([SELECT Id, Name,AccountId FROM Opportunity WHERE AccountID in : trigger.new 
AND ((RecordType.Name = 'Subscription Renewal' AND Subscription_Status__c = 'Active') OR (RecordType.Name = 'Subscription Prospect' AND Web_Expire_Date__c != null))]);
    Map<Id,Opportunity> accIdwithOpp = new Map<Id,Opportunity>();
    
    for(Opportunity opp : oppList){
        if(!accIdwithOpp.containsKey(opp.AccountId)){
            accIdwithOpp.put(opp.AccountId,opp);
        }
    }
    
    for(Account acc : trigger.new){
        if(accIdwithOpp.containsKey(acc.id)){
            acc.Active_Subscription_Opportunity__c = accIdwithOpp.get(acc.id).id;
        }
        else{
            acc.Active_Subscription_Opportunity__c = null;
        }
    }
}
 
trigger act_opp on Account (before insert, before update) {
    List<Opportunity> oppList = new List<Opportunity>([SELECT Id, Name,AccountId FROM Opportunity WHERE AccountID in : trigger.new 
AND ((RecordType.Name = 'Membership Renewal' AND Active_Membership__c = 'Active') OR (RecordType.Name = 'Membership Prospect' AND Web_Expire_Date__c != null))]);
    Map<Id,Opportunity> accIdwithOpp = new Map<Id,Opportunity>();
    
    for(Opportunity opp : oppList){
        if(!accIdwithOpp.containsKey(opp.AccountId)){
            accIdwithOpp.put(opp.AccountId,opp);
        }
    }
    
    for(Account acc : trigger.new){
        if(accIdwithOpp.containsKey(acc.id)){
            acc.Active_Membership_Opportunity__c = accIdwithOpp.get(acc.id).id;
        }
        else{
            acc.Active_Membership_Opportunity__c = null;
        }
    }
}
 
trigger act_opp_comms on Account (before insert, before update) {
    List<Opportunity> oppList = new List<Opportunity>([SELECT Id, Name,AccountId FROM Opportunity WHERE AccountID in : trigger.new 
AND ((RecordType.Name = 'Communications Council Renewal' AND Comms_Status__c = 'Active') OR (RecordType.Name = 'Communications Council Prospect' AND Web_Expire_Date__c != null))]);
    Map<Id,Opportunity> accIdwithOpp = new Map<Id,Opportunity>();
    
    for(Opportunity opp : oppList){
        if(!accIdwithOpp.containsKey(opp.AccountId)){
            accIdwithOpp.put(opp.AccountId,opp);
        }
    }
    
    for(Account acc : trigger.new){
        if(accIdwithOpp.containsKey(acc.id)){
            acc.Active_Comms_Opportunity__c = accIdwithOpp.get(acc.id).id;
        }
        else{
            acc.Active_Comms_Opportunity__c = null;
        }
    }
}

 
Getting a Visualforce error on line 49 column 1
System.ListException: List index out of bounds: 0
Error is in expression '{!buy}' in component <apex:commandButton> in page confirmbuy: Class.StoreFront2.buy: line 49, column 1
Class.StoreFront2.buy: line 49, column 1

I'm trying to insert both a Purchase__c custom object record and a list of Merchandise__c line items at the same time. To do this I'm passing my "cart" values into a list and trying to add the merchanise items to the "counter" variable and insert them as "Merchandise__c" line items.
Apex
public virtual class StoreFront2 {    
    
    public String message { get; set; }
    List<DisplayMerchandise> products;
    Map<Id, DisplayMerchandise> cart;
    public Boolean incart{get;set;}
    public Id rowz;
    public id rowDel{ get;set; }
    public Boolean flip{ get;set; }
    public Boolean flag{ get;set; }
    public Boolean flag2 { get; set; }
    public Purchase_Line_Items__c ct{ get;set; }
    public Contact ct2{get;set;}
    
    public StoreFront2(){
        ct=new Purchase_Line_Items__c();
        ct2=new Contact();
        flag = false;
        flip = false;
        flag2 = true; 
      
    }
      
    public PageReference buy(){
        
        List<Merchandise__c> toMerch = new List<Merchandise__c>();
        
        List<id> updateMerch = new List<id>();
                
        PageReference send = new PageReference('/apex/StoreCart2');
        
        if(ct != null && cart !=null ){
            List<DisplayMerchandise> counter = new List<DisplayMerchandise>();
    		List<Merchandise_Line_Item__c> merchi = new List<Merchandise_Line_Item__c>();
            Decimal total = 0;
            counter = cart.values();
            system.debug(counter);
            
            
            for(Integer i = 0; i < counter.size(); i++){
                
                Decimal totalPrice = counter.get(i).count;
                
                total +=totalPrice;
                ct.Item_Quantity__c=total;     
                if(counter.size() > 0 || !counter.isEmpty()){
          		merchi.add(i,new Merchandise_Line_Item__c(Name =ct.Name,Purchases__c=ct.id,Merchandise_Item_Stable__c=counter.get(i).merchandise.id));
                }
            }	
            insert ct;
         	
            insert merchi;

      		
            
	
			
        }
        
        return send;     
    }
    
    
    public void doShow(){
        if(flip){
            flag = true;  
            flag2=false;
        }
        else{
            flag = false;
            flag2 = true;
        }
          
    }
 
    public PageReference shop(){
        handleTheBasket();
        message = 'You bought: ';
        for (DisplayMerchandise p:products){
            if(p.tempCount > 0){
               message += p.merchandise.name + ' (' + p.tempCount + ') ' ;
               }
            }
        return null;
    }
   
    
    public void remove(){
     rowz = (Id) ApexPages.currentPage().getParameters().get('rowDel');
        if(cart.containsKey(rowz)){
            cart.remove(rowz);
            if(cart.isEmpty()){
                incart = false;
            }      
        }  
       
    }
        public pageReference back(){
        PageReference doit = new PageReference('/apex/StoreCart');
        doit.setRedirect(false);
            return doit;
        }
    
    
    public Pagereference checkout(){
        if(cart.isEmpty()){
            ApexPages.Message myError = new ApexPages.Message(ApexPages.Severity.ERROR, 'Shopping Cart is Empty');
            ApexPages.addMessage(myError);
            return null;
        } 
        
        else{
        PageReference send = new PageReference('/apex/ConfirmBuy');
        return send;
        }
    } 
    
    
    public void handleTheBasket(){
        for(DisplayMerchandise c : products){
            if(c.tempCount > 0){
            if(cart.containsKey(c.merchandise.Id)){        
                cart.get(c.merchandise.Id).count += c.tempCount;
                
            }
            else{
                cart.put(c.merchandise.Id, c);
                cart.get(c.merchandise.Id).count = c.tempCount;
                incart = true;
      
            } 
        
        }
        }
        
    }
    
    public Map<Id, DisplayMerchandise> getCart() {
        if(cart == null){
            cart = new Map<Id, DisplayMerchandise>();
            incart = false;
                }
      
        return cart;
    }
    
    public class DisplayMerchandise {
        public Merchandise__c merchandise{get; set;}
        public Decimal count{get; set;}
        public Decimal tempCount{get;set;}
        public DisplayMerchandise(Merchandise__c item){
            this.merchandise = item;
            
        }
    }

    public List<DisplayMerchandise> getProducts() {
        if (products == null){
            products = new List<DisplayMerchandise>();
    
            for (Merchandise__c item :
            [SELECT id, name, description__c, price__c
            FROM Merchandise__c
            WHERE Total_Inventory__c > 0]) {
           
            products.add(new DisplayMerchandise(item));
            }
        }
        return products;
    }

}

Visualforce
<apex:page standardStylesheets="false" showHeader="false" sidebar="false" controller="StoreFront2">
    
    <apex:stylesheet value="{!URLFOR($Resource.styles)}"/>
    <h1>Store Front</h1>

    <apex:form >
        <apex:dataTable value="{!products}" var="pitem" rowClasses="odd,even">
            <apex:column headerValue="Product">
                <apex:outputText value="{!pitem.merchandise.name}" />
            </apex:column>
            <apex:column headervalue="Price">
                <apex:outputText value="{!pitem.merchandise.Price__c}" />
            </apex:column>
            <apex:column headerValue="#Items">
                <apex:inputText value="{!pitem.tempCount}"/>
            </apex:column>
        </apex:dataTable>

        <br/>

        <apex:commandButton action="{!shop}" value="Add to Cart" reRender="msg,cartPanel,cmdPanelId">
        </apex:commandButton>
    
        <apex:outputPanel id="msg">
            {!message}
        </apex:outputPanel>

        <br/>    

        <h1>Your Basket</h1>

        <apex:outputPanel id="cartPanel">
            <apex:dataTable id="cart" value="{!cart}" var="carti" rowClasses="odd,even">

                <apex:column headerValue="ID" rendered="false">
                    <apex:outputText value="{!cart[carti].merchandise.Id}" >
                    </apex:outputText>
                </apex:column>
                <apex:column headerValue="Product">
                    <apex:outputText value="{!cart[carti].merchandise.name}">
                    </apex:outputText>
                </apex:column>
                <apex:column headervalue="Price">
                    <apex:outputText value="{!cart[carti].merchandise.price__c}" />
                </apex:column>
                <apex:column headerValue="#Items">
                    <apex:outputText value="{!cart[carti].count}"/>
                </apex:column>
                <apex:column headerValue="Remove?">
                    <apex:commandButton action="{!Remove}" value="Remove" reRender="cart,cmdPanelId">
                        <apex:param name="rowDel" assignTo="{!rowDel}" value="{!carti}"/>
                    </apex:commandButton>
                </apex:column>             

            </apex:dataTable>
			<apex:outputPanel id="cmdPanelId">
				<apex:commandButton value="Checkout" action="{!checkout}" rendered="{!incart}" />
			</apex:outputPanel>
        </apex:outputPanel>

    </apex:form>

</apex:page>

 
In  Trailhead, the instructions state:  
You've been given a requirement to keep Contact addresses in sync with the Account they belong to. Use Process Builder to create a new process that updates all child Contact addresses when the address of the Account record is updated. This process:Can have any name.
Must be activated.
Must update Contact mailing address fields (Street, City, State, Post Code, Country) when the parent Account shipping address field values are updated.
NOTE: You may have to deactivate the validation rule created from a previous challenge in order to complete this challenge.


I worked and reworked this module and I cannot figure out what is wrong.  I have deleted the previous validation I created in a previous module.  Is there something wrong in my criteria or actions?   

This is the error that I am getting when I check the challenge:  
     Challenge not yet complete... here's what's wrong: 
     An update to an account record failed to update the mailing address fields of all child contact        records. Make sure that the process is correct and that it is activated.

Here are my screenshots:
User-added imageUser-added image
Challange : Create an Apex class that returns an array (or list) of formatted strings ('Test 0', 'Test 1', ...). The length of the array is determined by an integer parameter.The Apex class must be called 'StringArrayTest' and be in the public scope.
The Apex class must have a public static method called 'generateStringArray'.
The 'generateStringArray' method must return an array (or list) of strings. Each string must have a value in the format 'Test n' where n is the index of the current string in the array. The number of returned strings is specified by the integer parameter to the 'generateStringArray' method.

And this is the code I have written :

public class StringArrayTest {

    public static String[] generateStringArray(Integer arraynum){
        String[] returndata = new String[arraynum];
           String value = 'Test ';
        returndata.clear();
        for(Integer i=0;i<=arraynum;i++) {
             returndata.add(value+i);
            System.debug('The output' + returndata);
    }
        return returndata;
}
}

Error :

Challenge not yet complete... here's what's wrong: 
Executing the 'generateStringArray' method failed. Either the method does not exist, is not static, or does not return the proper number of strings.

Not sure what is the mistake done by me in the code, can some one help me out?

Thanks,
Sai
For Example to create calculator i want to use only one

<apex:page controller="classname">
<apex:inputText value="somevalue" action="{!someaction}"/>
</apex:page>

With this single inputText and On clicking the button , the values in the text field should be passed to the controller class and generates output.
Gurus, 
I am trying to insert data into Product2 and PriceBookEntry from a staging Object Product_Stage__c

The class is as follows:
global class batchPInsert  implements Database.Batchable<sObject>,Database.Stateful
{
  global integer SizeP = 0;
    global Database.QueryLocator start(Database.BatchableContext BCPI)
    {
        string operation;
        operation='Insert';
        String query = 'SELECT CCO_Standard_Cost__c,IsActive__c,Dealer_Price__c,Description__c,Discount_Code__c,IP_Classification__c,Item__c,Name,Product_Type__c,Salesforce_Id__c FROM Product_Stage__c';
        query=query +' WHERE Operation_Type__c = \'' + String.escapeSingleQuotes(operation) + '\'';
        return Database.getQueryLocator(query);
    }
   
    global void execute(Database.BatchableContext BCPI, List<Product_Stage__c> scope)
    {
        List<Product2> lstP = new List <Product2>();
        List<PriceBookEntry>lstPBE=new List <PriceBookEntry>();
        Id StandardPriceBookID=[SELECT Id FROM Pricebook2 WHERE Name = 'Standard Price Book'].Id;
        for(Product_Stage__c PStg : scope)
         {
           Product2 P = new Product2();
           PriceBookEntry PBE=new PriceBookEntry();
           P.CCO_Standard_Cost__c=PStg.CCO_Standard_Cost__c;
           P.Dealer_Price__c=PStg.Dealer_Price__c;
           P.Description__c=PStg.Description__c;
           P.Discount_Code__c=PStg.Discount_Code__c;
           P.IP_Classification__c=PStg.IP_Classification__c;
           P.Item__c=PStg.Item__c;  
           P.Name=PStg.Item__c;
           P.Product_Type__c=PStg.Product_Type__c;
			P.IsActive=PStg.IsActive__c;
           lstP.add(P);
           insert(lstP);
           PBE.Pricebook2Id=StandardPriceBookID;
           PBE.Product2Id=P.Id;
           PBE.UnitPrice=P.Dealer_Price__c; 
           PBE.IsActive=True;
           lstP.clear();
           lstPBE.add(PBE);
         }
        SizeP+=scope.size(); 
        insert(lstPBE);
        delete(scope);
    }   
    global void finish(Database.BatchableContext BCPI)
    {
        String email;
        //email='gagnihotri@pelco.com';
        AsyncApexJob a = [SELECT Id, Status, NumberOfErrors, JobItemsProcessed,TotalJobItems, CreatedBy.Email FROM AsyncApexJob WHERE Id =:BCPI.getJobId()];
        //SizeP= [SELECT Count() from Product_Stage__c WHERE Operation_Type__c = 'Insert'];
        Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
		mail.setToAddresses(new String[] {'gagnihotri@pelco.com','nhombal@pelco.com','dfisher@schneider-electric.com','ron.adolph@schneider-electric.com'});
		mail.setReplyTo('gagnihotri@pelco.com');
		mail.setSenderDisplayName('Batch Processing');
		mail.setSubject('Batch Process Completed for insert on Products');
		if (a.Status == 'Completed')
		mail.setPlainTextBody('The batch Apex job processed ' + a.TotalJobItems +' batches of batch size '+ SizeP+ ' with '+a.NumberOfErrors + ' failures.');		
        //if (a.Status == 'Failed')
        //mail.setPlainTextBody('The batch Apex job processed ' + a.TotalJobItems +' batches of batch size '+ SizeP+ ' with '+a.NumberOfErrors + ' failures. Failure Message: '+a.ExtendedStatus);	
        Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
    }
}

The Test class:
@istest
private class TestBatchPInsert {
	static testMethod void batchPMethod1(){
        Id SPBId=test.getStandardPricebookId();
        Product2 P=new Product2();
        P.CCO_Standard_Cost__c=109071.45;
        P.Dealer_Price__c=441373.0;
        P.Description__c='CM9770-992X128 High Density System';
        P.Discount_Code__c='D';
        P.IP_Classification__c='Analog';
        P.IsActive=true;
        P.Item__c='CM9770-992X128';
        P.Name='CM9770-992X128';
        P.Product_Type__c='Matrix';
        insert P;
        PriceBookEntry PBE=New PriceBookEntry();
        PBE.Pricebook2Id=SPBId;
        PBE.Product2Id=P.Id;
        PBE.UnitPrice=100;
        //PBE.Name='CM9770-992X128';
        //PBE.ProductCode='AU';
        Insert PBE;
      	Product_Stage__c PStg= new Product_Stage__c();
        PStg.CCO_Standard_Cost__c=109071.45;
        PStg.Dealer_Price__c=441373.0;
        PStg.Description__c='CM9770-992X128 High Density System';
        PStg.Discount_Code__c='D';
        PStg.IP_Classification__c='Analog';
        PStg.IsActive__c=true;
        PStg.Item__c='CM9770-992X128';
        PStg.Name='CM9770-992X128';
        PStg.Product_Type__c='Matrix';
        PStg.Salesforce_Id__c=P.Id;
        insert PStg;
        
        system.debug('Product Stage Id='+PStg.Id);
        //Test Start
      	Test.StartTest();
		batchPInsert  pr4= new batchPInsert ();
		database.executeBatch(pr4);
        //pr4.execute(null, new list<Product_Stage__c> {PStg});
        //pr4.execute(null, new list<Product_Stage__c> {PStg});
		Test.StopTest(); 
        //Test Stop
    }
}

The complete execute function  has zero code coverage.
Error Code Coverage in RED

Any suggestions?
Gaurav
how to create simple app in salesforce and publish to appexchange?
I will have 2 simple apex pages and 2apex classes. How to create and package and publish to app exchange(test free app)
Hello; I have two formula fields;
1 - "Days To Pay" - Which is a case
CASE(Location_State__c, 
"RI", "7", 
"MA", "8", 
"CT", "8", 
"NH", "14", 
"ME", "14", 
"VT", "14", 
"NJ", "8", 
"NY", "8", 
"")

2 - "Days Signed" which returns a number
IF(Date_Certified_Signed__c < TODAY(), TODAY() - Date_Certified_Signed__c , NULL)

The first formula (Picklist) returns a Text value, the second, returns a number value,
I am attempting to build a formula which will identify when the "Days Signed" number value exceeds the "Days to Pay" text value, each record.
I have had no luck and could use some help.
Thank You,
Chris

 
Good Morning,
    I'm trying to find a way to export Case details into an excel Templete (not all the cases collectively just for each case after the case is set up). Is there an easy way to do this? I want to be able to chose what Case Detail Fields are exported into the excel templete. It would be nice if there was a button to click on when your in the case details that just exports to the Excel Templete that I create. Any help would be much appreciated since I've tried to research this issue for a while now. 

Thanks, and have a great day! 

Case Detail

Hello,

How can i allow someone to upload resume in pdf or word format with maximum size and store it.
I wanted to have it included on page layout

 

thank you

hi
save ,cancel and save and new buttons are not working on my visualforce page. Below is the code
And I want the assigned to defaults to the current user. Can anybody Help!!!

Controller//
public class LatestTask {public Task ta{get;set;}

    public LatestTask(ApexPages.StandardController controller) {

    }
  public Attachment file;
        public Attachment getfile(){
            file = new Attachment();
            return file;
        }
        public PageReference saveattachment(){
            string recordid = System.currentPageReference().getParameters().get('id');
            Attachment attach = new Attachment(
                parentid = recordid,
                name = file.name,
                body = file.body);
            insert attach;
            return null;
        }
   
    
 public void Cancel() 
  { 
  }    
  public void SaveNewEvent()
  {           
  } 
  public void SaveNewTask() 
  {            
  }    
  public ApexPages.PageReference save() 
{
  // I can do custom logic here before I save the record.
  
ApexPages.StandardController controller = new ApexPages.StandardController (ta);

  try {

    controller.save();
  
}
  catch(Exception e) 
{
    return null;

  }
  
return controller.view();

}
}
VF Page//
 
<apex:page tabStyle="Task" id="page1" standardController="task" extensions="LatestTask"  standardStylesheets="false">
<apex:form >
        <apex:pageBlock title="CSR Call" mode="edit">
<apex:pageBlockButtons >
<apex:commandButton action="{!save}" value="save" title="save"/>
<apex:commandButton action="{!SaveNewTask}" value="Save & New Task" title="Save & New Task"/>
<apex:commandButton action="{!SaveNewEvent}" value="Save & New Event" title="Save & New Event"/>
<apex:commandButton action="{!Cancel}" value="Cancel" title="Cancel"/>
</apex:pageBlockButtons>

<apex:pageBlockSection Title="Information" columns="2">
               <apex:inputField value="{!task.Subject}" id="subject" required="true"/>
               <apex:inputField value="{!ta.ownerid}" id="user"/>
               
               <apex:inputField value="{!task.ActivityDate}" onfocus="DatePicker.pickDate(false, 'DueDate', false);"/>
                <apex:inputField value="{!task.Status}"/>
                
                
                
                <apex:inputField value="{!task.Priority}" />
                <apex:inputField value="{!task.Disposition__c}" />
                <apex:inputField value="{!task.Description}  " />
                <apex:inputField value="{!task.Call_Type__c}   " />          
                
                

</apex:pageBlockSection>


<apex:pageblockSection Title="Related To" columns="2"  >


                               
               
                
 <apex:inputField value="{!ta.WhatId}"/>
 <apex:inputField value="{!ta.WhoId}"/>
</apex:pageblockSection>

<apex:pageBlockSection Title="Recurrence">
<apex:pageBlockSection id="pbs3" >
<apex:inputfield value="{!task.IsRecurrence}" onclick="CheckDiv()"/> 

</apex:pageBlockSection>
</apex:pageBlockSection>
 
  <div id="Recurrencediv"  style="display:none;">   
            <apex:pageBlockSection columns="1" id="pbs4" > 
                <apex:pageBlockSectionItem id="pbsi1" >
                    
                    <table border="0px">
                            <tr>
                                <td style="width:120px;">&nbsp;</td>
                                <td><b>Frequency</b></td>
                                <td style="width:80px;"></td> 
                                </tr>  
                                </table>                                                                                                     
                                <div>
                                        <input type="radio" id="Dailydiv" checked="true"  name="checkrctype" value="RecursEveryWeekday"/>Daily<br/>
                                        <input type="radio" name="checkrctype"  value="Weekly"/>Weekly<br/>
                                        <input type="radio" name="checkrctype"  value="RecursMonthly"/>Monthly<br/>
                                        <input type="radio" name="checkrctype"  value="RecursYearly"/>Yearly
                                    </div>
                               
                               <div name="Daily" id="Daily">
                                                                
                                            <input type="radio" id="RecursEveryWeekday"   name="recurrencetype" value="RecursEveryWeekday"/>Every weekday<br/>
                                            <input type="radio" id="RecursDaily"   name="recurrencetype" value="RecursDaily"/>Every
                               </div>
                                      
                                    </apex:pageBlockSectionItem>
                                       </apex:pageBlockSection> 
                                        </div> 
                
<apex:pageBlockSection >
<apex:inputField value="{!task.RecurrenceStartDateOnly}  " />
</apex:pageBlockSection>
<apex:pageBlockSection >
<apex:inputField value="{!task.RecurrenceEndDateOnly}  " />
</apex:pageBlockSection>
     
        <apex:pageBlockSection Title="New Attachment" >
        <apex:inputFile value="{!file.body}" fileName="{!file.name}"></apex:inputFile>
        <apex:commandButton value="save" action="{!saveattachment}"/>
</apex:pageBlockSection>
<apex:pageBlockSection Title="Reminder" Columns="2">
<apex:inputField value="{!task.IsReminderSet }"   />
<apex:inputField value="{!ta.Reminder__c}" onfocus="DatePicker.pickDate(false, 'DueDate', false);" />

<div class="datePicker" id="datePicker">
<div class="dateBar">
<img src="/s.gif" alt="Previous Month"  class="calLeft" onblur="this.className = 'calLeft';" onclick="DatePicker.datePicker.prevMonth();" onfocus="this.className = 'calLeftOn';" onmouseout="this.className = 'calLeft';" onmouseover="this.className = 'calLeftOn';" title="Previous Month"/>
<select  id="calMonthPicker" name="calMonthPicker" title="Month">
    <option value="0">January</option>
    <option value="1">February</option>
    <option value="2">March</option>
    <option value="3">April</option>
    <option value="4">May</option>
    <option value="5">June</option>
    <option value="6">July</option>
    <option value="7">August</option>
    <option value="8">September</option>
    <option value="9">October</option>
    <option value="10">November</option>
    <option value="11">December</option>
</select>
<img src="/s.gif" alt="Next Month"  class="calRight" onblur="this.className = 'calRight';" onclick="DatePicker.datePicker.nextMonth();" onfocus="this.className = 'calRightOn';" onmouseout="this.className = 'calRight';" onmouseover="this.className = 'calRightOn';" title="Next Month"/><select  id="calYearPicker" name="calYearPicker" title="Year">
    <option value="2015">2015</option>
    <option value="2016">2016</option>
    <option value="2017">2017</option>
    <option value="2018">2018</option>
    <option value="2019">2019</option>
    <option value="2020">2020</option>
    <option value="2021">2021</option>
</select>
</div>
<div class="calBody">
<table  class="calDays" border="0" cellpadding="0" cellspacing="0" id="datePickerCalendar"><tr><TH class="dayOfWeek" scope="col">Sun</TH><TH class="dayOfWeek" scope="col">Mon</TH><TH class="dayOfWeek" scope="col">Tue</TH><TH class="dayOfWeek" scope="col">Wed</TH><TH class="dayOfWeek" scope="col">Thu</TH><TH class="dayOfWeek" scope="col">Fri</TH><TH class="dayOfWeek" scope="col">Sat</TH></tr>
<tr class="calRow" id="calRow1"><td onblur="hiOff(this);" onclick="DatePicker.datePicker.selectDate(this);" onfocus="hiOn(this);" onmouseout="hiOff(this);" onmouseover="hiOn(this);">&nbsp;</td><td onblur="hiOff(this);" onclick="DatePicker.datePicker.selectDate(this);" onfocus="hiOn(this);" onmouseout="hiOff(this);" onmouseover="hiOn(this);">&nbsp;</td><td onblur="hiOff(this);" onclick="DatePicker.datePicker.selectDate(this);" onfocus="hiOn(this);" onmouseout="hiOff(this);" onmouseover="hiOn(this);">&nbsp;</td><td onblur="hiOff(this);" onclick="DatePicker.datePicker.selectDate(this);" onfocus="hiOn(this);" onmouseout="hiOff(this);" onmouseover="hiOn(this);">&nbsp;</td><td onblur="hiOff(this);" onclick="DatePicker.datePicker.selectDate(this);" onfocus="hiOn(this);" onmouseout="hiOff(this);" onmouseover="hiOn(this);">&nbsp;</td><td onblur="hiOff(this);" onclick="DatePicker.datePicker.selectDate(this);" onfocus="hiOn(this);" onmouseout="hiOff(this);" onmouseover="hiOn(this);">&nbsp;</td><td onblur="hiOff(this);" onclick="DatePicker.datePicker.selectDate(this);" onfocus="hiOn(this);" onmouseout="hiOff(this);" onmouseover="hiOn(this);">&nbsp;</td></tr>
<tr class="calRow" id="calRow2"><td onblur="hiOff(this);" onclick="DatePicker.datePicker.selectDate(this);" onfocus="hiOn(this);" onmouseout="hiOff(this);" onmouseover="hiOn(this);">&nbsp;</td><td onblur="hiOff(this);" onclick="DatePicker.datePicker.selectDate(this);" onfocus="hiOn(this);" onmouseout="hiOff(this);" onmouseover="hiOn(this);">&nbsp;</td><td onblur="hiOff(this);" onclick="DatePicker.datePicker.selectDate(this);" onfocus="hiOn(this);" onmouseout="hiOff(this);" onmouseover="hiOn(this);">&nbsp;</td><td onblur="hiOff(this);" onclick="DatePicker.datePicker.selectDate(this);" onfocus="hiOn(this);" onmouseout="hiOff(this);" onmouseover="hiOn(this);">&nbsp;</td><td onblur="hiOff(this);" onclick="DatePicker.datePicker.selectDate(this);" onfocus="hiOn(this);" onmouseout="hiOff(this);" onmouseover="hiOn(this);">&nbsp;</td><td onblur="hiOff(this);" onclick="DatePicker.datePicker.selectDate(this);" onfocus="hiOn(this);" onmouseout="hiOff(this);" onmouseover="hiOn(this);">&nbsp;</td><td onblur="hiOff(this);" onclick="DatePicker.datePicker.selectDate(this);" onfocus="hiOn(this);" onmouseout="hiOff(this);" onmouseover="hiOn(this);">&nbsp;</td></tr>
<tr class="calRow" id="calRow3"><td onblur="hiOff(this);" onclick="DatePicker.datePicker.selectDate(this);" onfocus="hiOn(this);" onmouseout="hiOff(this);" onmouseover="hiOn(this);">&nbsp;</td><td onblur="hiOff(this);" onclick="DatePicker.datePicker.selectDate(this);" onfocus="hiOn(this);" onmouseout="hiOff(this);" onmouseover="hiOn(this);">&nbsp;</td><td onblur="hiOff(this);" onclick="DatePicker.datePicker.selectDate(this);" onfocus="hiOn(this);" onmouseout="hiOff(this);" onmouseover="hiOn(this);">&nbsp;</td><td onblur="hiOff(this);" onclick="DatePicker.datePicker.selectDate(this);" onfocus="hiOn(this);" onmouseout="hiOff(this);" onmouseover="hiOn(this);">&nbsp;</td><td onblur="hiOff(this);" onclick="DatePicker.datePicker.selectDate(this);" onfocus="hiOn(this);" onmouseout="hiOff(this);" onmouseover="hiOn(this);">&nbsp;</td><td onblur="hiOff(this);" onclick="DatePicker.datePicker.selectDate(this);" onfocus="hiOn(this);" onmouseout="hiOff(this);" onmouseover="hiOn(this);">&nbsp;</td><td onblur="hiOff(this);" onclick="DatePicker.datePicker.selectDate(this);" onfocus="hiOn(this);" onmouseout="hiOff(this);" onmouseover="hiOn(this);">&nbsp;</td></tr>
<tr class="calRow" id="calRow4"><td onblur="hiOff(this);" onclick="DatePicker.datePicker.selectDate(this);" onfocus="hiOn(this);" onmouseout="hiOff(this);" onmouseover="hiOn(this);">&nbsp;</td><td onblur="hiOff(this);" onclick="DatePicker.datePicker.selectDate(this);" onfocus="hiOn(this);" onmouseout="hiOff(this);" onmouseover="hiOn(this);">&nbsp;</td><td onblur="hiOff(this);" onclick="DatePicker.datePicker.selectDate(this);" onfocus="hiOn(this);" onmouseout="hiOff(this);" onmouseover="hiOn(this);">&nbsp;</td><td onblur="hiOff(this);" onclick="DatePicker.datePicker.selectDate(this);" onfocus="hiOn(this);" onmouseout="hiOff(this);" onmouseover="hiOn(this);">&nbsp;</td><td onblur="hiOff(this);" onclick="DatePicker.datePicker.selectDate(this);" onfocus="hiOn(this);" onmouseout="hiOff(this);" onmouseover="hiOn(this);">&nbsp;</td><td onblur="hiOff(this);" onclick="DatePicker.datePicker.selectDate(this);" onfocus="hiOn(this);" onmouseout="hiOff(this);" onmouseover="hiOn(this);">&nbsp;</td><td onblur="hiOff(this);" onclick="DatePicker.datePicker.selectDate(this);" onfocus="hiOn(this);" onmouseout="hiOff(this);" onmouseover="hiOn(this);">&nbsp;</td></tr>
<tr class="calRow" id="calRow5"><td onblur="hiOff(this);" onclick="DatePicker.datePicker.selectDate(this);" onfocus="hiOn(this);" onmouseout="hiOff(this);" onmouseover="hiOn(this);">&nbsp;</td><td onblur="hiOff(this);" onclick="DatePicker.datePicker.selectDate(this);" onfocus="hiOn(this);" onmouseout="hiOff(this);" onmouseover="hiOn(this);">&nbsp;</td><td onblur="hiOff(this);" onclick="DatePicker.datePicker.selectDate(this);" onfocus="hiOn(this);" onmouseout="hiOff(this);" onmouseover="hiOn(this);">&nbsp;</td><td onblur="hiOff(this);" onclick="DatePicker.datePicker.selectDate(this);" onfocus="hiOn(this);" onmouseout="hiOff(this);" onmouseover="hiOn(this);">&nbsp;</td><td onblur="hiOff(this);" onclick="DatePicker.datePicker.selectDate(this);" onfocus="hiOn(this);" onmouseout="hiOff(this);" onmouseover="hiOn(this);">&nbsp;</td><td onblur="hiOff(this);" onclick="DatePicker.datePicker.selectDate(this);" onfocus="hiOn(this);" onmouseout="hiOff(this);" onmouseover="hiOn(this);">&nbsp;</td><td onblur="hiOff(this);" onclick="DatePicker.datePicker.selectDate(this);" onfocus="hiOn(this);" onmouseout="hiOff(this);" onmouseover="hiOn(this);">&nbsp;</td></tr>
<tr class="calRow" id="calRow6"><td onblur="hiOff(this);" onclick="DatePicker.datePicker.selectDate(this);" onfocus="hiOn(this);" onmouseout="hiOff(this);" onmouseover="hiOn(this);">&nbsp;</td><td onblur="hiOff(this);" onclick="DatePicker.datePicker.selectDate(this);" onfocus="hiOn(this);" onmouseout="hiOff(this);" onmouseover="hiOn(this);">&nbsp;</td><td onblur="hiOff(this);" onclick="DatePicker.datePicker.selectDate(this);" onfocus="hiOn(this);" onmouseout="hiOff(this);" onmouseover="hiOn(this);">&nbsp;</td><td onblur="hiOff(this);" onclick="DatePicker.datePicker.selectDate(this);" onfocus="hiOn(this);" onmouseout="hiOff(this);" onmouseover="hiOn(this);">&nbsp;</td><td onblur="hiOff(this);" onclick="DatePicker.datePicker.selectDate(this);" onfocus="hiOn(this);" onmouseout="hiOff(this);" onmouseover="hiOn(this);">&nbsp;</td><td onblur="hiOff(this);" onclick="DatePicker.datePicker.selectDate(this);" onfocus="hiOn(this);" onmouseout="hiOff(this);" onmouseover="hiOn(this);">&nbsp;</td><td onblur="hiOff(this);" onclick="DatePicker.datePicker.selectDate(this);" onfocus="hiOn(this);" onmouseout="hiOff(this);" onmouseover="hiOn(this);">&nbsp;</td></tr>
</table>
<div class="buttonBar">
    <a href="javascript&colon;%20void%280%29%3B" class="calToday" onclick="DatePicker.datePicker.selectDate('today');return false;">Today</a>
</div>
</div>
</div>
  </apex:pageBlockSection>       
    

</apex:pageBlock>
</apex:form>

<script>
function CheckDiv()
    {
    
   document.getElementById("Recurrencediv").style.display='block';
   document.getElementById("Daily").style.display='block';
   


}  
</script>

</apex:page>




 
Hi,

I am trying to write test cases for a controller class I created.  Several of the functions in the controller set variables using page reference pararameters.  I think I am setting the parameters correctly, but when I try to retrieve data from other functions, the test fails. 

Thank you for any help or advice you can provide.

Roger

CONTROLLER:
    private List<Boolean> chkBoxValues = new List<Boolean>{false,false,false,false,false,false,false,false,false,false,false,
        false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,
        false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,
        false,false,false,false,false,false,false,false,false,false,false,false,false,false};

    public void setChkBoxValue()
    {
        integer boxNum = integer.valueOf(system.currentPageReference().getParameters().get('boxNum'));
        boolean before = chkBoxValues[boxNum];
        chkBoxValues[boxNum] = !chkBoxValues[boxNum];
        System.debug('boxNum:' + boxNum + ' before:' + before);
        System.debug(currentChkBoxValues);
    }
      
    public string currentChkBoxValues
    {
        get {
            return string.join(chkBoxValues, ', ');
        }
    }

TEST CASE:
    @istest static void TestSetChkBoxValue()
    {
        PageReference pg = Page.BoleteSearch;
        pg.getParameters().put('boxNum','49');
        Test.setCurrentPage(pg);
        BoleteController ctrl = new BoleteController();
       
        ctrl.setChkBoxValue();
       
        String chk = ctrl.currentChkBoxValues;
        system.assert(chk.contains('T'), chk);
       
    }