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


  • Chatter
    Feed
  • 50
    Best Answers
  • 0
    Likes Received
  • 1
    Likes Given
  • 9
    Questions
  • 226
    Replies
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.
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;
    }


 
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;
    }
}
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>