• Hawked
  • NEWBIE
  • 130 Points
  • Member since 2013

  • Chatter
    Feed
  • 4
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 25
    Replies
I did this code but developer console says "expecting right curly bracket, found catch". I don't find any missing curly bracket in my code. Please help!

​public class AccountHandler {
    
    public static Account insertNewAccount(String AccountName){
        try{  Account acct= new Account(Name=AccountName) ;
        insert acct;
        return acct;
           }
    }
    catch(DmlException e){
        System.debug('A DML exception has occurred: ' +e.getMessage());
        return(NULL)
    }
   
}
I have the following VF code:
<apex:page controller="Five9ScreenPop">
    <head></head>
    <body>
        <apex:form>
            <apex:commandLink name="link" action="{!NewCase}" />
        </apex:form>
    </body>
</apex:page>
Controller:
public with sharing class Five9ScreenPop{

    public PageReference NewCase(){     
               
        PageReference pr = new PageReference('http://www.google.com');        
        pr.setRedirect(true);        
        return pr;
    }
}
The SF documentation on <apex:commandLink> says "A link that executes an action defined by a controller, and then either refreshes the current page, or navigates to a different page based on the PageReference variable that is returned by the action." (http://www.salesforce.com/docs/developer/pages/Content/pages_compref_commandLink.htm)

When I load my VF page nothing happens.  No redirect, no nothing. 

What am I doing wrong here?

Thanks!!
 
I am very, very new to development and am working on my first Apex Class for a button that will update fields from a custom object (Production Details) to the Opportunity Product based on the matching of the data in two fields (Opportunity Product Number on both objects).I am getting a error message that there's an Unexpected Token 'FROM'. Any direction on materials that will help fix the error? Code below...

global class ProductionDetailConversion{
    webService
    static String copyProductionDetail(Id Production_DetailId){
        List<Production_Detail__c> lstProductionDetail =
            [
                SELECT 
                    Id, 
                    Shipping_Costs__c, 
                    Postage_Costs__c,
                    Per_Piece_Costs__c, 
                    
                FROM 
             Production_Detail__c 
                WHERE 
                    Id = :ProductionDetailId
            ];
 
    
       List <OpportunityProductLineItem> lstOpportunityProductLineItem = new 

List<OpportunityProductLineItem>();
 
        for(!OpportunityLineItem.Opportunity_Product_Number__c : Production_Detail__c.Opportunity_Product__c}){
              
                    lstOpportunityProductLineItem.add(
                        new OpportunityProductLineItem(
                            
                            Shipping_Costs__c = OpportunityLineItem.Shipping_Costs__c,
                            Postage_Costs__c = OpportunityLineItem.Postage_Costs__c,
                            Per_Piece_Costs__c = OpportunityLineItem.Per_Piece_Costs__c,
                       
                        )
                    );
               }     
      try{   
            INSERT lstOpportunityProductLineItem;
            return lstOpportunityProductLineItem[0].Id; 
        }
        catch (Exception ex){
            
            return('Error');
        }     
}
Hello,

I'm going through the Salesforce API REST guide, and I'm trying to authenticate via session id. My script is in python:

    import urllib, urllib2
    url = 'https://login.salesforce.com/services/oauth2/token'
    values = {
        "grant_type":"password",
        "client_id":"aaaaaaaaaaaa11111111111111",
        "client_secret":"1111111111111",
        "username":"myuser@domain.com",
        "password":"mypassword"
    }
    data = urllib.urlencode(values)
    req = urllib2.Request(url,data)
    sf = urllib2.urlopen(req)

I'm receiving a 400 Error:

    Traceback (most recent call last):
      File "/Users/ZR/Desktop/sf.py", line 14, in <module>
        sf = urllib2.urlopen(req)
      File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 127, in urlopen
        return _opener.open(url, data, timeout)
      File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 410, in open
        response = meth(req, response)
      File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 523, in http_response
        'http', request, response, code, msg, hdrs)
      File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 448, in error
        return self._call_chain(*args)
      File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 382, in _call_chain
        result = func(*args)
      File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 531, in http_error_default
        raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
    urllib2.HTTPError: HTTP Error 400: Bad Request
    [Finished in 0.4s with exit code 1]

Where have I gone wrong?

Thank you! 
Hello,

I'm trying to create a trigger class that will clone an Opportunity that is of a certain record type and reaches a Stage that contains Close Won.  Everything saves fine, but when I try to close out an Opp I get the error message:

System.NullPointerException: Attempt to de-reference a null object: Class.ClassRenewalOppClone.cloneOpp: line 8, column 1

Does anyone know why I might be getting this?

Trigger Class:
public class ClassRenewalOppClone {
        
        public void cloneOpp(List<Opportunity> cloneOpp){
    
        String recordTypeName = 'Renewals';
        Map<String,Schema.RecordTypeInfo> rtMapByName = Schema.SObjectType.Campaign.getRecordTypeInfosByName();
        Schema.RecordTypeInfo rtInfo =  rtMapByName.get(recordTypeName);
        id recType = rtInfo.getRecordTypeId();
    
            
            FOR(Opportunity opp1 : cloneOpp){
                IF(opp1.StageName.contains('Closed Won') && opp1.RecordTypeId == recType){
Before Update Trigger:
        
ClassRenewalOppClone updater4 = new ClassRenewalOppClone();
            updater4.cloneOpp(Trigger.new);


Our company is move towards decommissioning IE10 and sending out IE11 to all our users.   We need to know if SalesForce.com (SalesCloud, ServiceCloud) is IE11 certified/compliant.

Thanks
I am doing simple query thru salesforce soap webservice(even tried with rest service) "SELECT Id, Name FROM Lead order by Name limit 50". For this query I am getting the following error "QUERY_TIMEOUT: Your query request was running for too long". For the same query, I sometime get result in 2 seconds.

If I change the abouve query to "select Id, Name from Lead Order by Id limit 50", it always reponsds by 2 seconds. Is there some kind of index that has to done for "Name" column. 

Note: The Lead table contains about "983940" rows. 

Can anyone help me in solving this issue. 
Does anyone know if there is any plans or way to modify the 'Grouping' fields on a report when retrieved via the Reporting API?  i.e. with the Reporting API you can dynamically specify custom filters when requesting report data via POST by providing the 'reportFilters' JSON data with the request.  It would be awesome if you could also provide custom 'GroupingDown' or 'GroupingAcross' fields or sort orders etc with the request.  Any way to know if this is a feature that may one day be available?
I have a custom visual force page created on "Quote "Object in a PDF format where the data gets displayed .Writing Wrapper class i have achieved the data of opportunity forecast details.Now i would Like to get

1) To Filter the Product Name ,With Quantity and Amount for Every Quarter.

2)To Achieve the Subtotals and Grandtotals for the Quantity and Amount .

PFA Screen Shot

VISUAL FORCE CODE :

 
<h2>OpportunityForecast Details</h2>
 <table class="bordered">
        <thead>
            <tr>
                <td class="header-table-heading" bgcolor="#C0C0C0"> Part Numbers</td>
                <td class="header-table-heading" bgcolor="#C0C0C0">Quantity</td>
                <td class="header-table-heading" bgcolor="#C0C0C0"> Price</td>
                <td class="header-table-heading" bgcolor="#C0C0C0"> Amount</td>
               <!-- <td class="header-table-heading" bgcolor="#C0C0C0">Quarter</td>-->
                <td class="header-table-heading" bgcolor="#C0C0C0">Month</td>  
               <!-- <td class="header-table-heading" bgcolor="#C0C0C0">Actual Price</td>-->
                <td class="header-table-heading" bgcolor="#C0C0C0">Year</td>
               <!-- <td class="header-table-heading" bgcolor="#C0C0C0">Date</td> --> 
                <td class="header-table-heading" bgcolor="#C0C0C0">MonthText</td> 
                <td class="header-table-heading" bgcolor="#C0C0C0">ForecastDate</td> 
                <td class="header-table-heading" bgcolor="#C0C0C0">ForecastName</td>  
            </tr>
        </thead>
        <tbody>
           <apex:repeat value="{!disp_list}" var="opf">
            <tr>
                <td class="header-table-data"><apex:outputText value="{!opf.gmod_Product}"/></td>
                <td class="header-table-data"><apex:outputText value="{!opf.gmod_Quantity}"/></td>
                <td class="header-table-data"><apex:outputText value="{!opf.gmod_Price }"/></td>
                <td class="header-table-data"><apex:outputText value="{!opf.gmod_Amount }"/></td>
               <!-- <td class="header-table-data"><apex:outputText value="{!opf.gmod_Quarter }"/></td>-->
                <td class="header-table-data"><apex:outputText value="{!opf.gmod_Month }"/></td>
               <!-- <td class="header-table-data"><apex:outputText value="{!opf.Actual_Price }"/></td>-->
                <td class="header-table-data"><apex:outputText value="{!opf.gmod_Year }"/></td>
              <!--  <td class="header-table-data"><apex:outputText value="{!opf.gmod_date }"/></td> -->  
                <td class="header-table-data"><apex:outputText value="{!opf.gmod_Month_Text }"/></td> 
                <td class="header-table-data"><apex:outputText value="{!opf.Forecast_Date }"/></td> 
                <td class="header-table-data"><apex:outputText value="{!opf.Name }"/></td>
             </tr>
            </apex:repeat> 
        </tbody>
    </table>

APEX CODE :

 
public with sharing class QuoteContentController {

       public Competitor__c com{get;set;}
    
       public gmod__Opportunity_Forecast__c oppf{get;set;}
   
       public Id qId {get;set;}
    
//Declare a wrapper class  
   
       public class Wrapperclass{
      
 //custom wrapper datatype  
       
       Public string Name{get;set;}  
       Public string AccountType{get;set;}  
       Public date todaysDate{get;set;}  
       Public date Expected_Order_Date{get;set;}
       Public string Probability{get;set;}  
       Public string Internal_Comment{get;set;}  
       Public string External_Comment{get;set;}  
     
       Public string Segment{get;set;}  
       Public string Application{get;set;}  
       Public string Persona{get;set;}  
       Public string Geogrpahy{get;set;}  
       
       Public string PartNumbers{get;set;}  
       Public Decimal  Price{get;set;}  
       Public Decimal End_Customer_Price{get;set;}  
       Public Decimal Quantity {get;set;}  
       Public Decimal Total{get;set;}  
      
       Public string RFQ_justification{get;set;}  
       Public string Main_Customer_of_Account{get;set;}  
       Public string Bridgelux_competition_at_account{get;set;}
       Public string Geographic_regions_serviced{get;set;}  
       Public string Annual_lighting_revenue{get;set;}  
       Public string Annual_LED_revenue_or_percent{get;set;}  
       Public string Annual_purchases_of_LED_light_sources{get;set;}
       Public string Percent_of_LED_purchases_that_are_COB{get;set;}  
       Public string Other_information{get;set;}  
      
       Public string Product_Series{get;set;}  
       Public string Volume{get;set;} 
       Public string Date_Price_is_Valid{get;set;} 
      
       Public string gmod_Product{get;set;}
       Public Decimal gmod_Quantity{get;set;}
       Public Decimal gmod_Price{get;set;}
       Public Decimal gmod_Quarter{get;set;}
       Public Decimal gmod_Month{get;set;}
       Public Decimal gmod_Amount{get;set;}
       Public Decimal Actual_Price{get;set;}
       Public Decimal  gmod_Year{get;set;}
       Public Date gmod_date{get;set;}
       Public string gmod_Month_Text{get;set;}
       Public Date  Forecast_Date{get;set;}
       
       Public wrapperClass(){} 
      
  }
  
       Public QuoteContentController(){}
  
       Public QuoteContentController(ApexPages.StandardController controller) {
       
       qId=Apexpages.currentPage().getparameters().get('Id');
    
    }
    
       Public List<wrapperClass> disp_list {get;set;}{
      
     // Public List<wrapperClass> disp_list(){
    //define constructor to instantiate the wrapper data type 

       disp_list=new list<wrapperclass>();

    //Query all the list 
    
    list<Quote> q =[select id ,Name ,Effective_Date__c ,Comments__c ,
                    Quote.Opportunity.Probability ,Quote.Opportunity.AccSegment__c ,Quote.Opportunity.AccApplication__c,Quote.Opportunity.Persona__c,Quote.Opportunity.Region__c
                    from Quote where id=:apexpages.currentpage().getparameters().get('id')];
                     
    list<QuoteLineItem> qli =[Select QuoteId , PricebookEntry.Product2.Name ,Unitprice ,End_Customer_Price__c ,Quantity , TotalPrice from QuoteLineItem where QuoteId =:qId ];
    
    list<Account> a = [Select id ,Name ,Main_Customers_of_Account__c ,Bridgelux_Competition_at_Account__c,Servicing_Region__c ,
                      Annual_LED_Revenue__c,Annual_Purchases_of_LED_Sources_SAM__c ,Percent_of_LED_purchases_that_are_COB__c from Account where account.id =:qId ];
                      
   list<Competitor__c>  com = [Select id ,Part_Number__c,Product_Series__c,Price_Offered__c,Volume__c,Date_Price_is_Valid__c from Competitor__c ]  ; 
   
   opp =[select id ,Name , probability,AccSegment__c from Opportunity where opportunity.Id =:q[0].Id];
    
   list<gmod__Opportunity_Forecast__c>  opflist = [Select id ,Name ,gmod__Product__c,gmod__Quantity__c,gmod__Price__c ,   gmod__Quarter__c ,gmod__Amount__c ,Actual_Price__c,gmod__Year__c , gmod__Month__c, gmod__date__c ,gmod__Month_Text__c ,Forecast_Date__c from gmod__Opportunity_Forecast__c where name!=null   ];
   
    list<gmod__Opportunity_Forecast__c>  opflist = [Select id ,Name ,gmod__Product__r.name,gmod__Quantity__c,gmod__Price__c , gmod__Month__c,    gmod__date__c,  gmod__Quarter__c ,gmod__Amount__c ,Actual_Price__c ,gmod__Year__c ,gmod__Month_Text__c ,Forecast_Date__c from gmod__Opportunity_Forecast__c  where gmod__Product__r.name!=null and gmod__Opportunity__r;id=:opp.id order by  gmod__Month__c asc];
      

//SELECT  gmod__product__r.name ,gmod__opportunity__c,sum(gmod__Price__c) gmod__Price__c ,SUm(gmod__Amount__c) gmod__Amount__c,Sum(gmod__Quantity__c)gmod__Qunatity__c,COUNT(id) Quantity 
FROM gmod__Opportunity_Forecast__c 
GROUP BY  gmod__product__r.name ,gmod__opportunity__c
       //Iterate through each list to extract the values and add it to the custom wrapper data type  

         for (Quote qt :q){

            for(integer i=0;i<opflist.size();i++){

                //Instantiating the wrapper SObject 
                
                wrapperclass w = new wrapperclass();
  
  //Assigning the wrapper variables from the SObject Fields in the database. 
  
  w.gmod_Product = opflist[i].gmod__Product__c;
 
  w.gmod_Quantity =opflist[i].gmod__Quantity__c;
  
  w.gmod_Price=opflist[i].gmod__Price__c;
 
  w.Name =opflist[i].Name;
  
  w.gmod_Quarter=opflist[i].gmod__Quarter__c;
  
  w.gmod_Month=opflist[i].gmod__Month__c;
  
  w.gmod_Amount=opflist[i]. gmod__Amount__c;
  
  w.Actual_Price=opflist[i].Actual_Price__c;
  
  w.gmod_Year=opflist[i].gmod__Year__c;
  
  w.gmod_date=opflist[i].gmod__date__c;
  
  w.gmod_Month_Text=opflist[i].gmod__Month_Text__c;
  
  w.Forecast_Date=opflist[i].Forecast_Date__c;
  
      //Adding everthing to the List  
    
    
    // w.name =qt.name;
     
      disp_list.add(w);
      
      // return disp_list;  
       }
     }
   }  
 } //End of Class





Any Suggestion Plz.

TABLE1TABLE2
  • February 10, 2015
  • Like
  • 0
Hi All

I am a salesforce developer with 5 years experience in salesforce.I have no regular job and I am available to you all the time.

I am very good in apex(triggers,controllers) and visualforce(css,java script).I have done some good number of integration projects,

I can do any development work given to me without fail(communities,sites and any other) .Please send a mail to my gmail and we can get started right away.

gmail:salesforcelancer123@gmail.com

Note :I am not US based but available to you at US timings.
Hello Everyone,

I have visual force which uses 2 controller extesnion QP_SendRQQCntr &QP_UploadOnBaseDocController
<apex:page standardController="Contact" extensions="QP_SendRQQCntr,QP_UploadOnBaseDocController" >
 <style>
.right
{
  float:right;
  right:0Px;
}
</style>

 <apex:form id="frmId">
  <apex:pageBlock rendered="{!QPRQQ}">
   <apex:pageBlockButtons styleClass="right">
    <apex:commandButton value="Next" action="{!QPRQQNext}" reRender="frmId"/>
   </apex:pageBlockButtons>
   <apex:pageBlockSection columns="1">
    <apex:inputField value="{!ObjContact.Transition_Specialist__c}"/>
    <!--<apex:selectRadio value="{!SelectValue}" label="Is this the correct recruiter?">
    <apex:selectOptions value="{!Recruter}" />
  </apex:selectRadio>-->
   </apex:pageBlockSection>
  </apex:pageBlock>
  <!--
  <apex:pageBlock >
  <apex:pageBlockButtons styleClass="right">
    <apex:commandButton value="Previous" action="{!QPRQQNext}"/>
    <apex:commandButton value="Next" action="{!QPRQQNext}"/>
   </apex:pageBlockButtons>
  <apex:pageBlockSection columns="1">  
   <apex:inputText label="Recruter Name"/>
  </apex:pageBlockSection>
  </apex:pageBlock>
  -->
  <!--                                                       -->
  <apex:pageBlock rendered="{!recruit}">
  <apex:pageBlockButtons styleClass="right">
    <apex:commandButton value="Previous" action="{!previous}" reRender="frmId"/>
    <apex:commandButton value="Next" action="{!recruitInfoNext}" reRender="uploadId,frmId"/>
   </apex:pageBlockButtons>
  <apex:pageBlockSection columns="1">
  <p>Please select the appropriate Prospect Type type from the list provided.<br/></p>
    <apex:inputField value="{!ObjContact.Recruit_type__c}"/>
    Please review the following Prospect information and make any necessary changes.
    <apex:inputField value="{!Contact.CRD__c}"/>
    <apex:inputField value="{!Contact.FirstName}"/>
    <apex:inputField value="{!Contact.Middle_name__c}"/>
    <apex:inputField value="{!Contact.LastName}"/>
    <apex:inputField value="{!Contact.Suffix__c}"/>
    <apex:inputField value="{!Contact.Email}"/>
    <apex:inputField value="{!Contact.MailingStreet}"/>
    <apex:inputField value="{!Contact.MailingCity}"/>
    <apex:inputField value="{!Contact.MailingState}"/>
    <apex:inputField value="{!Contact.mailingpostalCode}"/>
    <apex:inputField value="{!Contact.phone}"/>
    <apex:inputField value="{!Contact.mobilephone}"/>
    </apex:pageBlockSection>
    </apex:pageBlock>
    
 
   <apex:pageBlock rendered="{!recruitConfirm}">
   <apex:pageBlockButtons styleClass="right">
    <apex:commandButton value="Previous" action="{!previous}" reRender="frmId,uploadId"/>
    <apex:commandButton value="Next" action="{!recruitInfoConfirm}" reRender="frmId"/>
   </apex:pageBlockButtons>
   <apex:pageBlockSection columns="1">
    <apex:outputField value="{!Contact.Recruit_type__c}"/>
    <apex:outputField value="{!Contact.CRD__c}"/>
    <apex:outputField value="{!Contact.FirstName}"/>
    <apex:outputField value="{!Contact.phone}"/>
    <apex:outputField value="{!Contact.mobilephone}"/>
    <apex:outputField value="{!Contact.Email}"/>
    <apex:outputField value="{!Contact.MailingStreet}"/>
    <apex:outputField value="{!Contact.MailingCity}"/>
    <apex:outputField value="{!Contact.MailingState}"/>
    <apex:outputField value="{!Contact.mailingpostalCode}"/>
   </apex:pageBlockSection>
   </apex:pageBlock>  
   
    <apex:pageBlock rendered="{!finish}">
    <apex:pageBlockButtons styleClass="right">
    <apex:commandButton value="Finish" action="{!confirmToSend}"/>
   </apex:pageBlockButtons>
    <apex:pageBlockSection >
    <h1>The Registered Rep Qualifying Questionnaire will be sent after clicking Finish.
    Thank you.</h1>
    </apex:pageBlockSection>
    </apex:pageBlock>
 </apex:form>
//THIS PART USES QP_UploadOnBaseDocController  ,but i have selection option on page which it's not pulling the values from second contoller.
 <apex:form id="uploadId" enctype="multipart/form-data">
 <apex:pageBlock rendered="{!uploadBlock}">
  
  <apex:pageBlockButtons styleClass="right">
    <apex:commandButton value="Previous" action="{!previous}" />
    <apex:commandButton value="Next" action="{!uploadNext}" />
   </apex:pageBlockButtons>
   <apex:pageBlockSection columns="1">
  <apex:selectRadio value="{!SelectValue}">
    <apex:actionsupport event="onclick" action="{!fileShowHide}" reRender="frmId,uploadId"/>
    <apex:selectOptions value="{!items}" />
  </apex:selectRadio>
  <br/>
  <apex:outputPanel rendered="{!Display}">
  
   <form enctype="multipart/form-data">
        <apex:pageBlock title="Upload a File" rendered="{!renderUploadForm}">
            <apex:pageBlockButtons location="bottom">
                <apex:commandButton action="{!uploadDocument}" value="Upload" />
                <apex:commandButton action="{!cancel}" value="Cancel" />
            </apex:pageBlockButtons>

            <apex:pageBlockSection showHeader="false" columns="1" id="block1">

                <apex:pageBlockSectionItem >
                    <apex:outputLabel value="Document Type" for="docType"/>
                    <apex:outputPanel styleClass="requiredInput" layout="block">
                        <div class="requiredBlock"></div>
                        <apex:selectList value="{!docType}" id="docType" multiselect="false" size="1">
                            <apex:selectOptions value="{!docTypeOpts}" />
                        </apex:selectList>
                    </apex:outputPanel>
                </apex:pageBlockSectionItem>

                <apex:pageBlockSectionItem >
                    <apex:outputLabel value="File" for="file" />
                    <apex:outputPanel styleClass="requiredInput" layout="block">
                        <div class="requiredBlock"></div>
                        <apex:inputFile value="{!doc.body}" filename="{!doc.name}" id="file" /> <br />
                        (Allowed file types: {!validFileExtensions})
                    </apex:outputPanel>
                </apex:pageBlockSectionItem>
            </apex:pageBlockSection>
        </apex:pageBlock>
      

        <apex:commandButton action="{!cancel}" value="Back" rendered="{!NOT(renderUploadForm)}" />
    </form>
      </apex:outputPanel>
     
   
   </apex:pageBlockSection> 
  </apex:pageBlock>
  </apex:form>
</apex:page>

First Extension Class

public class QP_SendRQQCntr {

    public String SelectValue{get;set;}
    public Attachment objAttach{get;set;}
    public Boolean Display{get;set;}
    Public Boolean QPRQQ{get;set;}
    public Boolean recruit{get;set;}
    public Boolean uploadBlock{get;set;}
    public Boolean recruitConfirm{get;set;}
    public Boolean finish{get;set;}
    public Contact ObjContact{get;set;}
    public User objUser{get;set;}
    public Boolean renderUploadForm {get; private set;}
    
    public QP_SendRQQCntr(ApexPages.StandardController controller) {
        
        ObjContact=new Contact();
        objAttach=new Attachment(); 
        objUser=new User();
        QPRQQ=true;
        recruit=false;
        uploadBlock=false;
        recruitConfirm=false;
    }
    public List<SelectOption> getItems() {
        List<SelectOption> options = new List<SelectOption>(); 
        options.add(new SelectOption('SendWithDocuSign','Send With Docusign'));
        options.add(new SelectOption('UplaodFile','Upload a File')); 
        return options; 
    }
    /*public List<SelectOption> getRecruter() {
        List<SelectOption> options = new List<SelectOption>(); 
        options.add(new SelectOption('Yes','Yes'));
        options.add(new SelectOption('No','No')); 
        return options; 
    }*/
    public void previous()
    {
        if(recruit)
        {
            QPRQQ=true;
            recruit=false;
        }
        else if(uploadBlock)
        {
            recruit=true;
            uploadBlock=false;
        }
        else if(recruitConfirm)
        {
            uploadBlock=true;
            recruitConfirm=false;
        }        
    }
     public void QPRQQNext()
    {
        QPRQQ=false;
        recruit=true;
    }
    public void recruitInfoNext()
    {     
        recruit=false;
        uploadBlock=true;
        system.debug('user name---------'+ObjContact.Transition_Specialist__c);
        if(ObjContact.Transition_Specialist__c !=null)
            objUser=[select id,email from user where id =:ObjContact.Transition_Specialist__c];
    }
    public void uploadNext()
    {
        uploadBlock=false;
        recruitConfirm=true;
        
        Blob fileBody = objAttach.body;

        // Create the email attachment
        Messaging.EmailFileAttachment efa = new Messaging.EmailFileAttachment();
        efa.setFileName(objAttach.name);
        efa.setBody(fileBody);
        
        String[] toAddresses = new String[] {objUser.email};
        //String toAddresses=''sarvendra;
        
        Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
        email.setSubject( 'Test subject');
        email.setToAddresses(toAddresses);
        email.setPlainTextBody('String'); 
        

        email.setFileAttachments(new Messaging.EmailFileAttachment[] {efa});
        if(fileBody !=null)
        {
        // Sends the email
        Messaging.SendEmailResult [] r = 
            Messaging.sendEmail(new Messaging.SingleEmailMessage[] {email});
       
       }
    }
    public void recruitInfoConfirm()
    {
        recruitConfirm=false; 
        finish=true;   
    }
    public void confirmToSend()
    {
    
    }
    public Void fileShowHide()
    {
        if(SelectValue=='UplaodFile')
        {
            Display=true;
            renderUploadForm=true;
            }
        else
            Display=false;
    }
    
}

Second Extension Class

public with sharing class QP_UploadOnBaseDocController {

    public QP_UploadOnBaseDocController(ApexPages.StandardController controller) {

    }


        public String objectName {get; set;}
        public ID recordId {get; set;}

        public Boolean renderUploadForm {get; private set;}
        public Document doc {get; private set;}
        public List<SelectOption> docTypeOpts {get; private set;}

        public String docType {get; set;}

        private String keywordName;
        private String keywordValue;

        public QP_UploadOnBaseDocController() {
                Map<String, String> params = ApexPages.currentPage().getParameters();
                this.objectName = params.get('objectName');
                this.recordId = params.get('recordId');
                this.doc = new Document();
                this.renderUploadForm = true;
                init();
        }

        private void init() {

                try {
                        QP_OnBaseService serv = new QP_OnBaseService();
                        OnBase_Doc_Related_List_Config__c config = serv.getRelatedDocumentsConfig(this.objectName, this.recordId);
                        SObject record = serv.getParentRecord(this.recordId, config);

                        if ( config != null && record != null ) {

                                this.keywordName = config.Keyword_Name__c;
                                this.keywordValue = (String) record.get(config.Keyword_Value_Field__c);

                                if (  this.keywordValue!= null )         {

                                        this.docTypeOpts = new List<SelectOption>{new SelectOption('', '--Select--')};
                                for( String docType : config.Document_Types__c.split(';') ) {
                                    this.docTypeOpts.add(new SelectOption(docType, docType));
                                }
                                } else if ( !ApexPages.hasMessages() ) {
                                        this.renderUploadForm = false;
                                        addMessage(
                                                ApexPages.Severity.ERROR, 'The Keyword field (' + config.Keyword_Value_Field__c + ') is blank.');
                                }
                        } else {
                                this.renderUploadForm = false;
                                addMessage(
                                        ApexPages.Severity.ERROR, 
                                        'Unable to process your request at this time.  Please contact your System Administrator.');
                        }
                } catch(Exception e) {
                        this.renderUploadForm = false;
                        addMessage(
                                ApexPages.Severity.ERROR, 
                                'Unable to process your request at this time.  Please contact your System Administrator.');
                }
        }

        private Boolean validate() {
                Boolean isValid = true;
                if ( this.docType == null || this.docType == '' ) {
                        isValid = false;
                        addMessage(ApexPages.Severity.ERROR, 'Please select Document Type.');
                }
                if ( this.doc == null || this.doc.Body == null ) {
                        isValid = false;
                        addMessage(ApexPages.Severity.ERROR, 'Please select a file to upload.');
                }
                if ( this.doc != null && this.doc.Name != null ) {
                        String[] namePieces = this.doc.Name.split('\\.');
                        System.debug('namePieces: ' + namePieces);
                        String extension = namePieces[namePieces.size() - 1];

                        String fileType = QP_GeneralUtility.getOnBaseFileTypeByExtension(extension);
                        if ( fileType == null ) {
                                isValid = false;
                                addMessage(ApexPages.Severity.ERROR, 'Invalid File Type');
                        }
                }
                return isValid;
        }

        public PageReference uploadDocument() {

                System.debug('doc: ' + this.doc);
                if ( validate() ) {

                        try {
                                IDMServiceDAO dao = new DAOFactory().getIDMServiceDAO();
                                IDMServiceDAO.OnBaseDocument uploadedDoc = 
                                        dao.uploadDocument(this.doc, this.docType, this.keywordName, this.keywordValue);
                                if ( uploadedDoc != null && uploadedDoc.handle != null ) {
                                        addMessage(ApexPages.Severity.CONFIRM, 'Document uploaded successfully.');
                                        this.renderUploadForm = false;
                                } else if ( uploadedDoc != null && uploadedDoc.errorMessage != null ) {
                                        addMessage(
                                                ApexPages.Severity.ERROR, 
                                                'Unable to process your request at this time because of the following error: \n' + uploadedDoc.errorMessage);
                                }
                        } catch (WSCommunicationException e) {
                                addMessage(
                                        ApexPages.Severity.ERROR, 
                                        'Unable to process your request at this time.  Please contact your System Administrator.');
                        }
                }
                this.doc = new Document();
                return null;
        }

        public PageReference cancel() {
                return new PageReference('/' + this.recordId);
        }

        private void addMessage(ApexPages.Severity sev, String msg) {
                ApexPages.addMessage(new ApexPages.Message(sev, msg));
        }

        public String getValidFileExtensions() {
                String validFileExts = String.valueOf(QP_GeneralUtility.getOnBaseValidFileExtensions());
                return validFileExts.length() > 2 ? validFileExts.substring(1, validFileExts.length() - 1) : null;
        }
}

Can you please help me out.

Regards,
Jyo
 
I am getting an Apex Test failure while deploying a change set. It says "OppPusherTests.myOppUnitTest(), Details: System.AssertException: Assertion Failed Class.OppPusherTests.myOppUnitTest: line 37, column 1"

I am trying to upload a Role hierarchy I created in the Sandbox but it keeps failing on the Apex test. There are no Deploy component errors.

Any ideas? Thanks
I did this code but developer console says "expecting right curly bracket, found catch". I don't find any missing curly bracket in my code. Please help!

​public class AccountHandler {
    
    public static Account insertNewAccount(String AccountName){
        try{  Account acct= new Account(Name=AccountName) ;
        insert acct;
        return acct;
           }
    }
    catch(DmlException e){
        System.debug('A DML exception has occurred: ' +e.getMessage());
        return(NULL)
    }
   
}
I can't believe I could get stuck on something that looks so easy! Step 1 was no problem. Step 2 should be a cinch, but I cannot find Position on my Custom Objects page. Did I miss this in a previous lesson?

To create the lookup relationship field that accomplishes this:
  1. From Setup, click Create | Objects.
  2. Click Position.
  3. In the Custom Fields & Relationships related list, click New.
  4. Select Lookup Relationship, and click Next.
screenshot of custom objects
Hello,

I have created a trigger that fires when a Task is Inserted, Updated, or Deleted. When it fires, it updates custom checkboxes on open Opportunities based upon the Subject of the Task and checks to see that the ActivityDate is within the effective and renewal dates of the Opp. All works fine, however, I am not able to get my test to cover the part of the code that works on checking one of the boxes after an update. Can anyone advise on how I can get the code covered below (Specifically line 14 and lines 19-37 of the Trigger Class?

Trigger:
IF(Trigger.IsUpdate){
    ClassRenewalTaskCount updater4 = new ClassRenewalTaskCount();
    updater4.taskCountUpdate(Trigger.new,Trigger.old);
}

Trigger Class:
public class ClassRenewalTaskCount {

Set<ID> OppIds = new Set<ID>();
Set<ID> TaskIdsRem = new Set<ID>();

    String acctPrefix = Account.SObjectType.getDescribe().getKeyPrefix();

public void taskCountUpdate(List<Task> checkTasks, List<Task> oldTasks) {

    for (Task t : checkTasks) {
        for (Task prev : oldTasks){
            //Adds a task that is updated to completed and current
            if (t.WhatId != null && t.Status == 'Completed' && t.RP_Prior_60__c <= t.ActivityDate && string.valueof(t.WhatId).startsWith(acctPrefix) ) {
                OppIds.add(t.WhatId);              
            }
        }
    }

    if (OppIds.size() > 0){

        List<Account> acctsWithTasks = [SELECT Id,(SELECT Id FROM Tasks)
                                        FROM Account
                                        WHERE Id IN : OppIds];

            List<Opportunity> oppsUpdatable = new List<Opportunity>();

                for(Account acct : acctsWithTasks){
                    for(Opportunity L : [SELECT Id,Account.Id,RP_Customer_Engagement__c,IsWon
                                        FROM Opportunity
                                        WHERE Account.Id =: acct.Id AND IsWon=FALSE]){
                    L.RP_Customer_Engagement__c = acct.Tasks.size();
                    oppsUpdatable.add(L);
                    }
                }

        if(oppsUpdatable.size()>0){
            update oppsUpdatable;
        }
    }
    }
}

Test Method:
static testmethod void testRenewalTasks3(){

    Account acct1 = TestCreateRecords.createAcct(0);
    insert acct1;

    Opportunity opp1 = TestCreateRecords.createOppNew(acct1.Id);
    insert opp1;
        opp1.RP_Customer_Engagement__c = 0;
        UPDATE opp1;

    Task task1 = TestCreateRecords.createTaskInitProg(acct1.Id);
    INSERT task1;

    Task task2 = new task();
    task2.WhatId = acct1.Id;
    task2.ActivityDate = Date.today().addDays(10);
    task2.Subject = 'User Training Complete';
    task2.Status = 'In Progress';
    task2.Priority = 'Normal';
    INSERT task2;


Test.startTest();
    Task tsk1 = [SELECT Id,ActivityDate,Status
                FROM Task
                WHERE Id =: task1.Id];
    tsk1.Status = 'In Progress';
    UPDATE tsk1;

    Task tsk2 = [SELECT Id,ActivityDate,Status
                FROM Task
                WHERE Id =: tsk1.Id];
    tsk2.Status = 'Completed';
    UPDATE tsk2;
Test.stopTest();
}

 
I have the following VF code:
<apex:page controller="Five9ScreenPop">
    <head></head>
    <body>
        <apex:form>
            <apex:commandLink name="link" action="{!NewCase}" />
        </apex:form>
    </body>
</apex:page>
Controller:
public with sharing class Five9ScreenPop{

    public PageReference NewCase(){     
               
        PageReference pr = new PageReference('http://www.google.com');        
        pr.setRedirect(true);        
        return pr;
    }
}
The SF documentation on <apex:commandLink> says "A link that executes an action defined by a controller, and then either refreshes the current page, or navigates to a different page based on the PageReference variable that is returned by the action." (http://www.salesforce.com/docs/developer/pages/Content/pages_compref_commandLink.htm)

When I load my VF page nothing happens.  No redirect, no nothing. 

What am I doing wrong here?

Thanks!!
 
Dear SF experts,
I have a drop down option in my visualforce page where the 'onchange' event calls a jQuery function called 'selectMapping()' that renders the appropriate outputpanel. There was a reason for using the onchange to trigger a jQuery function as opposed to using the native 'actionSupport' function along with the 'rerender' option in visualforce. It was because of performance issues due to the high viewstate size and took forever to re-render different sections of the page using the native approach.

However, an issue with the current implementation is that when clicking on 'save', even though the unused outputpanel is hidden from the page, the inputfields from the hidden outputpanel show a validation error, complaining an input is required. So I have tried disabling hidden inputfields to skip the validation on required fields, but had no luck.
I have tried the option of setting "immediate=true" on the save button, but this has caused some inputfields to be null.

Any help would be appreciated! 
 
<apex:pageBlockButtons location="bottom">
    <apex:commandButton value="Save" action="{!save}"/>
</apex:pageBlockButtons>

<apex:pageBlockSection columns="1">
    <apex:selectList id="chooseMappingOption" size="1" onchange="selectMapping()" label="Choose Option" multiselect="false">
        <apex:selectOption itemValue="MappingPanelAccountOnly" itemLabel="Map to Account Only" />
        <apex:selectOption itemValue="MappingPanelAccountBrand" itemLabel="Map to Account and Brand" />
    </apex:selectList>
</apex:pageBlockSection>

<apex:outputPanel id="MappingPanelAccountOnly">
    <apex:outputPanel>
        <apex:pageBlockSection columns="1">
            <apex:inputField label="Account Name" value="{!account.name}" id="accNameForAccOnly" />
        </apex:pageBlockSection>
        <apex:pageBlockSection columns="1">
            <apex:inputField label="Person Name" value="{!account.Person__c}" id="personNameForAccOnly" />
        </apex:pageBlockSection>
    </apex:outputPanel>
</apex:outputPanel>

<apex:outputPanel id="MappingPanelAccountBrand">
    <apex:inputField value="{!accBrandJunc.Account__c}" id="accNameForAccBrand" >
    ...
</apex:outputPanel>

<script type="text/javascript">
    j$('[id$=MappingPanelAccountBrand]').hide();

    function selectMapping() {
        if (j$('[id$=chooseMappingOption]').val() == "MappingPanelAccountOnly") {
            
            // Hide irrelevant fields
            j$('[id$=MappingPanelAccountBrand]').hide();

            // Disable hidden input fields
            j$('[id$=accNameForAccBrand]').prop('disabled', true);
            j$('[id$=brandNameForAccBrand]').prop('disabled', true);
            j$('[id$=personNameForAccBrand]').prop('disabled', true);
            
            // Show fields
            j$('[id$=MappingPanelAccountOnly]').show();
            j$('[id$=isAccountBrand]').val(false);
        } else {
            ...
        }
    }
</script>

 
This is kind of very weird behavior that's coming up only in this org. I'm trying to embed visualforce page to the Standard Layout of a Custom Object and using the Standard Controller in the VF page. Now if go to the standard listing page of that Custom Object and click on any one of the record and the detail page comes up which where i've the VF embedded but this is not showing the actual VF page it's showing the Home Page in that VF section.
Go To -> CustomObject Tab -> click on any of the record -> see the detail page -> instead of actual VF page it'll embed the Home Page in the same area
Screenshot
I am very, very new to development and am working on my first Apex Class for a button that will update fields from a custom object (Production Details) to the Opportunity Product based on the matching of the data in two fields (Opportunity Product Number on both objects).I am getting a error message that there's an Unexpected Token 'FROM'. Any direction on materials that will help fix the error? Code below...

global class ProductionDetailConversion{
    webService
    static String copyProductionDetail(Id Production_DetailId){
        List<Production_Detail__c> lstProductionDetail =
            [
                SELECT 
                    Id, 
                    Shipping_Costs__c, 
                    Postage_Costs__c,
                    Per_Piece_Costs__c, 
                    
                FROM 
             Production_Detail__c 
                WHERE 
                    Id = :ProductionDetailId
            ];
 
    
       List <OpportunityProductLineItem> lstOpportunityProductLineItem = new 

List<OpportunityProductLineItem>();
 
        for(!OpportunityLineItem.Opportunity_Product_Number__c : Production_Detail__c.Opportunity_Product__c}){
              
                    lstOpportunityProductLineItem.add(
                        new OpportunityProductLineItem(
                            
                            Shipping_Costs__c = OpportunityLineItem.Shipping_Costs__c,
                            Postage_Costs__c = OpportunityLineItem.Postage_Costs__c,
                            Per_Piece_Costs__c = OpportunityLineItem.Per_Piece_Costs__c,
                       
                        )
                    );
               }     
      try{   
            INSERT lstOpportunityProductLineItem;
            return lstOpportunityProductLineItem[0].Id; 
        }
        catch (Exception ex){
            
            return('Error');
        }     
}
Hello everyone,

We are running into a weird problem in our Salesforce org. We have some code that run on a child object and update the parent object and everything seemed to be working just fine. However, today, when trying to insert records via dataloader.io our insert failed because of a validation rule being triggered on the parent object. But here is the fun part, the validation rule should not have been triggered! I checked it and everything was fine, I deactivated it and then another validation rule was triggered on the parent object (also should not have triggered). And when manually inserting a child record everything worked just fine.

Am I missing something in regard to validation rules and triggers?

Thank you for your help.
This is my test class:

@isTest(seeAllData = true)
public with sharing class NUBSCartControllerTest{
    
    static testMethod void NUBSCartControllerTestMethod() {
       
       Contact c = new Contact();
       c.firstName = 'Charles';
       c.lastName = 'Cox';
       c.email = 'charliecox17@yahoo.com';
       insert c;
       
       Event_Registration__c er = new Event_Registration__c ();
       er.name = 'CharlesConference';
       er.hasPaid__c = false;
       er.Applicant_Name__c = c.id;
       insert er;
       
       Id stnd = Test.getStandardPricebookId();
       
       Product2 p = new Product2();
       p.name = 'Thursday, March 26, Opening Reception';
       insert p;
       
       ConProd_Bridge__c cpb = new ConProd_Bridge__c();
       cpb.Product__c = p.id;
       cpb.Contact__c = c.id;
       insert cpb;
       
       PricebookEntry pbe= new PricebookEntry();
       pbe.Product2Id = p.Id;
       pbe.unitPrice = 30;
       pbe.Pricebook2Id = stnd;
       pbe.isActive = true;
       insert pbe;
       
       Opportunity o = new Opportunity();
       o.Name = 'thisOpp';
       o.Amount = 30;
       o.stageName = 'Prospecting';
       o.closeDate = Date.TODAY().addYears(1);
       o.Contact__c = c.id;
       insert o;
       
       OpportunityLineItem ole = new OpportunityLineItem();
       ole.UnitPrice = 30;
       ole.OpportunityId = o.id;
       ole.PriceBookEntryId = pbe.id;
       ole.Quantity = 1;
       insert ole;
       
       Test.setCurrentPageReference(new PageReference('Page.myPage'));
       System.currentPageReference().getParameters().put('oppId', o.id);
       System.currentPageReference().getParameters().put('isConference', 'true');
     
       NUBSCartController contr = new NUBSCartController();
       
       contr.BillingFirst = 'Charles';
       contr.BillingLast = 'Cox';
       contr.BillingAddress = '26 West';
       contr.BillingCity = 'Austin';
       contr.BillingState = 'Texas';
       contr.BillingCountry  = 'United States';
       contr.BillingPostcode = '78681';
       
       contr.CardType = 'Visa';
       contr.CardNumber = '4111111111111111';
       contr.CardMonth = '12';
       contr.CardYear = '2038';
       contr.CardSecurity = '123';
       
       contr.cancel();     
       contr.preCharge();
       contr.processPayment();
    
       contr.isConference = 'false';
       contr.sendEmails(c);
    }    
}


I get the error 'TestMethod do not support Web service callouts' when I run the test with seeAlldata = true but not when seeAllData = false. I need to have seeAllData = true so I need to figure this error out. I don't see where I am using a web service call...

Any help would be great,

Thanks!