• soof
  • NEWBIE
  • 430 Points
  • Member since 2006

  • Chatter
    Feed
  • 16
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 112
    Replies

Hi all,

 

I'm working for a non-profit and new to apex. I'm having a hard time thinking through how to do a SOQL query and update fields inside a trigger.

 

I have a custom object Application__c which is related to a Contact (field name on application Contact__c) and has a couple fields I want to update from related fields on the Contact. Both fields are lookup relationships so I cannot use workflow.

 

the two fields are: on application Specific_Organization__c = on Contact Specific_Organization__c

                                 on application Specific_Visit__c = on Contact Specific Visit__c

 

and this needs to happen if a field on the application Status__c = "Applicant" and one on the contact Alum__c = False.

 

Any help to get me started in the right direction would be appreciated.

 

Thanks!

Chris

 

 

I am trying to write a test for a visualforce page where user is searching for a keyword to choose a record to add to the opportunity. How do I solve my error?

 

error

System.NullPointerException: Attempt to de-reference a null objectClass.AddCustomerProductStage1create.processSelected: line 76, column 1 Class.TestAddCustomerProductStage1create.myUnitTest: line 48, column 1

 

Test Class

@IsTest public class TestAddCustomerProductStage1create {

    /* This is a basic test which simulates the primary positive case for the 
       save method in the AddCustomerProduct class. */
Static AddCustomerProductStage1create ext;
public static testMethod void myUnitTest() {
    
    Account acc1=new Account(Name='test', BillingStreet='test', BillingCity='NY', BillingState='test',
                BillingCountry='US', BillingPostalCode='test', ShippingStreet='test', ShippingCity='test',
                ShippingState='NY', ShippingCountry='US', ShippingPostalCode='test');
insert acc1;                


Opportunity op = new Opportunity(Name='TestOppty',closedate=date.parse('1/1/2222'),
                    stagename = 'prospecting',AccountID=acc1.id,Equip_Services_Options_to_be_quoted__c='test', 
                    Opportunity_Region__c='test');
insert op;   

    System.assertEquals('TestOppty', op.name);
            
    PageReference pageRef = Page.CustomerProductStage1create;
    
    pageRef.getParameters().put('oppid', op.id);

    Test.setCurrentPageReference(pageRef);
    
    Customer_Product_Line_Item__c c = new Customer_Product_Line_Item__c(name='Apple', opportunity__c=op.id);
    insert c;
    
    Customer_Product__c cp = new Customer_Product__c(name='Apple');
    
    System.assert (true, [select name from Customer_Product_Line_Item__c where name = 'Apple']);

               ApexPages.StandardController sc = new ApexPages.StandardController(New Customer_Product_Line_Item__c());     
               
                ext = new AddCustomerProductStage1create(sc );           
    
     String cpUrl = '/apex/customerproductstage1create?oppid=' + op.id;
     
        System.Debug('++++++++++++'+cpUrl);
    
     PageReference ref = new PageReference(cpUrl);
          
     Test.setCurrentPage(ref); 
     
     ApexPages.currentPage().getParameters().put(cp.name, 'ap');
     
     PageReference proc = ext.processSelected();
 
}
}

 Class

public class AddCustomerProductStage1create{

/* Constructor Function. The CustomerProduct id is captured in this function */

public Customer_Product_Line_Item__c cpl {get;set;}
public Opportunity o;
public AddCustomerProductStage1create(ApexPages.StandardController c)
{
            o = [select id from Opportunity where id =
                       :ApexPages.currentPage().getParameters().get('oppid')];
}

      public Opportunity getOpportunity() {
            return o;
      }

/* Variable declarations */

public List<cCustomer> cpList {get; set;}                              // Wrapper class which stores customer product data and a boolean flag.
public List<cCustomer> cpsel{get; set;}
public ID oid {get; set;}

String userinput;                                                               // cp Name
String userinp;  



Public List<Customer_Product__c> results = new List<Customer_Product__c>();                 // Customer_Product__c search results.

Public List<Customer_Product__c> selproduct = new List<Customer_Product__c>();                 // Customer_Product__c selectedproduct.

/* End of Variable declarations */

/* Getter and setter methods for getting the user input ie. Customer_Product__c name from the UI */

public String getuserinput(){return userinput;}
public void setuserinput(String userinp)
{

this.userinput=userinp;
system.debug('*****SFDC-TEST-1**********'+userinput+'='+userinp);

}
public String getselproduct(){return null;}

/*End of Getter and Setter methods */

/* Method to Search the Customer_Product__c database to return the query results */
public List<Customer_Product__c> cpsearch()
{
     cpList = new List<cCustomer>();
     for(Customer_Product__c c : [select id, name from Customer_Product__c where Name like :userinput+'%'order by Name asc])
     {
         cpList.add(new cCustomer(c));
        
     }
system.debug('*****SFDC-TEST-2**********'+cpList);
 return null;
}
/* End of method */


/* Method for returning the Customer Product search results to the UI */
public List<cCustomer> getresults(){
    
 return cpList;

}
    public PageReference processSelected() {

                //We create a new list of Customer Products that we be populated only with Customer Products if they are selected
        List<Customer_Product__c> selectedProduct = new List<Customer_Product__c>();

        //We will cycle through our list of cCustomer and will check to see if the selected property is set to true, 
        //if it is we add the Customer Product to the selectedProduct list
        for(cCustomer cCon : getresults()) {
            if(cCon.selected == true) {
                selectedProduct.add(cCon.con);
                
                
            }
        }
system.debug('*****SFDC-TEST-3**********'+selectedProduct);
        // Now we have our list of selected products and can perform any type of logic we want
        System.debug('These are the selected Products...');
        for(Customer_Product__c cCon : SelectedProduct ) {
            system.debug(cCon);
            
            selproduct.add(cCon);
            
        }
         system.debug('*****SFDC-TEST-4**********'+selproduct.size());

    cpsel = new List<cCustomer>();
     for(Customer_Product__c p : [select name from Customer_Product__c where id =:selproduct])
     {
     system.debug('*****SFDC-TEST-p**********'+p.name);
       cpsel.add(new cCustomer(p));
       
        Customer_Product_Line_Item__c cpli = new Customer_Product_Line_Item__c(Name = cpsel[0].con.name, 
                Opportunity__c = o.id);
      
      insert cpli;
      system.debug('*****test cpli.name**********'+cpli.name);     
     }
         PageReference home = new PageReference('/' + o.id);
        home.setRedirect(true);
        return home;

  system.debug('*****SFDC-TEST-5**********'+cpsel.size());
        return null;
    }


/* Wrapper class to contain contact record and a boolean flag */
public class cCustomer{
 public Customer_Product__c con {get; set;}
 public Boolean selected {get; set;}

 /*This is the contructor method. When we create a new cContact object we pass a
 Contact that is set to the con property. We also set the selected value to false*/
 public cCustomer (Customer_Product__c c)
 {
     con = c;
     selected = false;
 }
}

/* end of Wrapper class */    

}

 How do I solve this test coverage error?

 

Thank you

Hi,

I am new developer to Salesforce.. I have a custom object of 'Value' having the following feilds,

 

Name(Primary Key)

VSDesc__c(Description)

Parent_Value__c(Parent Value)

Child_Parent_Value__r(Look up)

 

now i want to have nested table in which each Parent should display its childs as shown here:

 

http://www.forcetree.com/2010/04/nested-tables-and-nested-queries-in.html

 

I have made the controller as :

 

//Control Class

 

public class ValueManager
{  
  public List<Seg1__c> getValue()
   {
List<Seg1__c> Values = [Select Name, (Select Name, VSDesc__c From Child_Parent_Value__r where Parent_Value__c <> null) From Seg1__c p where p.Parent_Value__c= null] ;
      return Values;  
  }
}

 

 

//Visual Page

 

<apex:page controller="ValueManager" showheader="false">

<apex:pageblock >

<apex:pageblocktable value="{!Value}" var="par">

<apex:column headervalue="Parent Value">
<apex:outputtext value="{!par.Name}"/>
</apex:column>

<apex:pageblocktable value="{!Value}" var="ch">
<apex:column headervalue="Description">
<apex:outputtext value="{!ch.Name}"/>
</apex:column>
</apex:pageblocktable>


</apex:pageblocktable>
</apex:pageblock>

</apex:page>

 

Can any one help me how can i acheive???


  • February 17, 2012
  • Like
  • 0
String assesment_query = 'SELECT a,b,c,d,e,f,g,h,i,j'+ 
+'FROM Assesment__c WHERE Candidate__c IN '													+'(SELECT Candidate_Contact__c '+																		+'FROM Application__c '+																		+'WHERE Job__c =:'+JobOrder+' '+																		+'AND Stage__c =:'+offer+')'+
		        +' AND RecordTypeId =:'+ProfileId+';';
List<Assesment__c> assesment = Database.query(assesment_query);

 Hi all,

 

I have the code above and gives me this error:

 

System.QueryException: unexpected token: WHERE 

 If I execute this directly (eg.: List<Assessment__c> assessment = [the query here]; Works perfectly.

 

In the string query:

JobOrder is an ID.

offer is a String.

ProfileId is an ID.

 

Does anyone knows why this happens?. Do you know of any solution?

 

Thank you!,

 

MGA

I want list of all Standard objects.

 

please help.

 

reply asap.

 

thnaks.

  • February 16, 2012
  • Like
  • 0

Hi all,

 

I am developing a managed package with VisualforcePages containing a lot of Javascript code.

This Code contains Function-calls to a Javascript "Class" Customizations. 

 

When I deploy a package to an end customer the packaged VisualforcePages are read-only. Therefore I need a way to provide the possibility to our end customers that they can create a new VisualforcePage where they define a Javascript Object Customizations which is being called by our packaged code.

 

The part where I want to include the Custom VisualforcePage

The intention here is, that the VisualforcePage is only imported into the code if the Page exists

 

<apex:outputPanel rendered="{!!ISBLANK($Setup.cnx__Settings__c.cnx__Custom_Pagename__c)}">
    // This code is only executed if the custom pagename is defined
    <apex:include pageName="{!JSENCODE($Setup.cnx__Settings__c.cnx__Custom_Pagename__c)}" />
    <script type="text/javascript">
        // init customer configuration
        if(typeof Customizations === 'function') { 
            var custom = new Customizations();
        }
    </script>
</apex:outputPanel>

 

The custom VisualForce Page not part of the managed package 

This VisualforcePage is created by the Customer and is not part of the managed package and will be included with the code-listing above if the page exists

 

<apex:page >
    <script type="text/javascript">
        function Customizations()
        {
            this.GetSettings = function(data) {
                //manipulate the data here
                return data;
            }
            this.ContactLookup = function(data) {
                //create a ContactLookup here
                return data;
            }

            // ...
        }
    </script>
</apex:page>

 

This code works flawlessly if the ...Custom_Pagename__c Custom Setting is defined and contains a value. The problem arises if the custom setting is set to ''.

 

I always get the following error:

The name '' can only contain underscores and alphanumeric characters. It must begin with a letter and be unique, and must not include spaces, end with an underscore, or contain two consecutive underscores. 


In my understanding the code between <apex:outputPanel></apex:outputPanel> should only be evaluated if the rerended attribute is TRUE. correct?

 

Does anyone have a suggestion how to solve this issue?

 

 

Thanks

 

Lorenz

  • February 15, 2012
  • Like
  • 0

Hi,

 

     I know how to compare strings and Integers, but i am looking for something like below:

  I have 3 strings :

 

 String str1 =  ' abcd' ;

String  str2 = ' cded' ;

String str3 = ' ==' ; ( This is a oparator and can be any != OR > OR < OR any operator) 

 

Now i need a method or any way to check the above three so that i get a boolean value back based on these three arguments.

 

 

Thanks

Bramha

 

 

I need to have an apex-class which can close open Cases. 

I tried to update Case.status = "Closed", but the Case is not closed after this update. 
Case.isclosed is not writeable. Is there a possibility to close a case with apex? 

i.e. like Database.leadconvert() ? 

Is there a option to use Metadata API within Salesforce? If yes, Please give some documentation or relevant code.

 

Thanks.

Public class utility{
    @future
    public static void updatehmt(List<customobject__c> colist){
        Update colist;
    }
}

 When I try to save the above class it doesnt save and gives error Unsupported parameter type LIST<customobject__c> at line 5 column 24

If I change the parameter to a set of ids the class gets saved. Any idea what am I doing wrong??

Hi 

 

I am trying to parse the wsdl in salesforce and get struck with this error

 

Failed to parse wsdl: attribute name can not be null at: 42:94. The following is the part of the WSDLand the line in red where the error is throwing.

 

<complexType name="ArrayOfReplyInfo">
<complexContent>
<restriction base="soapenc:Array">
<attribute ref="soapenc:arrayType" wsdl:arrayType="intf:ReplyInfo[]"/>
</restriction>
</complexContent>
</complexType>


I am having an issue with something that sounds so simple to me.  Here is the APEX trigger:

 

trigger LinkTimeCard on Timecard__c (after insert) {
    System.debug('Starting...');
    for (Timecard__c tc : Trigger.new) {
        tc.Account = tc.Case__r.Account;
    }
}

 

The Timecard custom object has a lookup relationship with Account and Master-Detail relationship with Case.  The other odd thing to me is the following:

 

trigger LinkTimeCard on Timecard__c (after insert) {
    System.debug('Starting...');
    for (Timecard__c tc : Trigger.new) {
        System.debug(tc.Case__r.CaseNumber);
    }
}

 

That shows "null" in the debug log.  I can't really find any API documentation in APEX that shows a class library like you would find for Java or .NET.  Why can't I access the object Case__r?

Is it possible to do dynamic SOQL statements do updates similar to how you do Select statements like this Database.query like Database.update

Hi,


This is my first simple/mini visual force project I am having some difficulties pass variable back and forth between my visual force page and my control (Apex class)

 

What is the proper approach to pass a var Id from a input field from vforce page to control , then control's logic queies some data and returns the result back to the v force page. It should be very somple pass contact id from vforce page query and return contact name based on the id.

 

Any help will be extremely appreciated.

 

Here is my code as well:

 

VForce Page:

 

<apex:page id="pageForm" controller="ContactLookup">
  <apex:form id="form">
    <apex:inputText id="textFld" value="{!myObject.paramId}" />
    <apex:commandButton value="Lookup" id="btnLookup" rerender="newData"/>
   
    <br/>
    <!--  <apex:outputPanel id="newData">
        Result value: {!myObject.result}<br/>
        Action Result: {!myObject.lookup}<br/>
      </apex:outputPanel>
      -->
  </apex:form>
 
  <!-- <apex:outputPanel id="newData">
    Result value: {!myObject.result}<br/>
    Action Result: {!myObject.lookup}<br/>
  </apex:outputPanel> -->
 
</apex:page>

 

 

My Control Code:

 

 public class ContactLookup {

    public class MyObject {
        
        private String paramId = null;
        private String result = null;
 
    
        public String getParamId() { return paramId; }
        public void setParamId(String param) { paramId = param; }
        
        public String getResult(){return result;}
        public void setResult(String val){result = val;}
    
        public void getLookup() {

          //Contact c = [Select Id, Name from Contact where Id = :paramId];
          result = 'Kiril Minev';
 
        }
      }
    
      private myObject my_object;
    
      public MyObject getMyObject() {
        if (my_object == null) { my_object = new MyObject(); }
        return my_object;
    }
}

 

 

 

Thank you.

 

I am working on a projecto create a custom pront document with only the information from the opportunity, account, and other custom objects that are pertinent to the quote. What I would like to do is create a custom header that will appear on every page dynamically based upon the opportunity. How do I do this?
Hi all, I'm trying to run a simple trigger before delete. The error I'm getting is:

System.NullPointerException: Attempt to de-reference a null object


Code:
trigger deleteMultiday on SFDC_Special_Event__c (before delete) {

        for (SFDC_Special_Event__c co : Trigger.new)
        {

        }//end main for

}//end trigger

 I originally had logic in the loop but removed it to see if it was causing the error. But the error is still showing with this code. The above code works perfectly in insert/update triggers.

I'm trying to execute the simplest of codes in a future method, but when I call the method, it fails with the following exception:

System.AsyncException: Failed to enqueue future method

 

Here's my code:

 

global class OpptyEmailNotificationUtil {

@future public static void sendEmails1() {

System.debug('test');

}

}

 

I actually want to do a lot of other stuff in the future method, but am unable to even get this simple code to work.  Can anyone help?

 

Thanks. 

 

  • August 25, 2009
  • Like
  • 0

I'm trying to make an outbound callout to our internal server. I know Salesforce requires a valid cert by a trusted 3rd party vendor to be installed on that server. Now Salesforce provides the ability to use a CA -Signed Cert. I've gone ahead and created one of these types of certs on Salesforce, and provided back a signed Cert. This is being tested within my Sandbox, where this cert was created and reuploaded to and is now actived, I'm still getting: 

 

FATAL_ERROR System.CalloutException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

 

 

HttpRequest request = new HttpRequest();
        request.setMethod('POST');
        request.setHeader('Host', '<host url>');
        request.setHeader('api_key', '<api key>');           
        request.setClientCertificateName('<cert unique name on salesforce>');
        request.setEndpoint('<endpoint url>');
        
Http callout = new Http();
        HttpResponse response = new HttpResponse();
        response = callout.send(request);

 

 

Any idea what I might be doing wrong?

 

Hi all,

 

I'm working for a non-profit and new to apex. I'm having a hard time thinking through how to do a SOQL query and update fields inside a trigger.

 

I have a custom object Application__c which is related to a Contact (field name on application Contact__c) and has a couple fields I want to update from related fields on the Contact. Both fields are lookup relationships so I cannot use workflow.

 

the two fields are: on application Specific_Organization__c = on Contact Specific_Organization__c

                                 on application Specific_Visit__c = on Contact Specific Visit__c

 

and this needs to happen if a field on the application Status__c = "Applicant" and one on the contact Alum__c = False.

 

Any help to get me started in the right direction would be appreciated.

 

Thanks!

Chris

 

 

I want to make sure I understand view state.  I have a controller that also uses other classes and those class read a lot of data, only some of which is displayed on the page at a time.

 

Is the view state all data going to/from the page?

 

Or is view state all data my controller is owning, including class instances it has references to that have data?

 

 

I have an application where there will be lots of data handled by the controller but the user will page through it.  I don't want to exceed view state size.  That's why I ask the question.  I did notice that static data is not part of the view state.  A follow up question is if I keep my large set of data in statics instead of instance variables will that help?

 

 

I have a class called Constants, which is full of various constants.   What is teh syntax of accessing one of them from a VF page?

 

Something like below.  The syntax below directs the page to the controller.  I need it to look in the Constants class instead.  

 

<apex:outputLabel value="{!Constants.constantOne}"/>
<apex:outputLabel value="{!$Constants.constantOne}"/>

 

I've overridden the edit button with a redirect link that directs users to a visualforce edit page.  Using this link below:

 

<apex:page standardController="Guest_Card__c" showheader="false" sidebar="false">

<meta http-equiv="REFRESH" content="0;url=../apex/editguestcard?id={!Guest_Card__c.Id}&mode=edit&returl=%2F{!Guest_Card__c.Id}" />

</apex:page>

 

The custom edit page has a standard controller with sharing.  So, when a user tries to edit a record they do not have access too, it will not let them save.  How can I make it so the user doesn't even get redirected to the edit page as it would be confusing for them to allow them to fill the page out, but not let them save.  

 

Is there a way to detect the permissions of the user on the redirect page, and if they have permission to edit the record to direct them to the edit page, but if not, direct them to another page that displays an error?

 

 

Thanks for any suggestions!

My Asset objects have a boolean field called Opt_Out__c.

 

A single account can have multiple Asset objects.

 

I need to list each Asset object's Opt_Out__c field as a checkbox

and be able to update each Asset object's Opt_Out__c field.

 

 

Any suggestions to get this to work?

 

The page shows nicely, but how can I capture the selected ID for each Asset object.

Keep in mind that if an Account previously decided to 'opt out,' the check box should be selected

when the page loads!

 

VisualForce: Not sure which pageBlockSectionItem I should go with?

<!-- in this one, how do I get the id for the Asset object?-->	
<apex:pageBlockSectionItem >
                        <apex:outputPanel >
                            <apex:dataTable value="{!assets}" var="a">
                                    <apex:column >
                                        <apex:outputField value="{!a.Name}" />
                                    </apex:column>
                                    <apex:column >
                                        <apex:facet name="header">Opt Out</apex:facet>
                                        <apex:inputCheckbox value="{!a.Opt_Out__c}" />
                                    </apex:column>
                                </apex:dataTable>
                            </apex:outputPanel>
                        </apex:pageBlockSectionItem>
                        
                        
     <!-- in this one, how do set the check box as selected, if need be, for the Asset object?-->                    
                        <apex:pageBlockSectionItem >
                            <apex:outputPanel id="thePanel">
                                <apex:outputLabel value="Select the items you would like to receive:" />
                                <apex:selectCheckboxes value="{!assetsToSave}"
                                    layout="pageDirection">

                                    <apex:selectOptions value="{!options}" />
                                </apex:selectCheckboxes>
                            </apex:outputPanel>
                        </apex:pageBlockSectionItem>

Hi!

I am trying to put members in groups by using a popup with a pageblocktable inside with inputcheckboxes. So far, so good. But after I've chosen and processed the chosen groups, I want the popup to disappear. I thought it would be enough by setting isLookupfld to false and then rerender the popup (reRender="popup" in commandbutton). But it doesn't work. What is wrong in my code?

 

<apex:page standardcontroller="xx" extensions="ChooseNumberController,PopupController">
    <apex:form >
        
        <apex:pageBlock >

            
            <apex:pageBlockSection >
            <apex:pageBlockTable value="{!joinName}" var="j" width="100" columns="4">
                <apex:column value="{!j.jnd.usr.name}" headerValue="Name" />
                <apex:column headerValue="Popup">
                  <apex:commandLink rendered="{!lookupvisible}" value="..." id="lookupButton" action="{!setlookupmethod}" styleclass="btn" style="color:black;text-decoration:none;">
                 </apex:commandLink>
                </apex:column>
            </apex:pageBlockTable><br/>
         </apex:pageBlockSection>
         
         <apex:pageblockSection showheader="false">
             <apex:outputPanel id="popup" rendered="{!isLookupfld}" styleClass="customPopup" layout="block" >
                 <apex:pageBlockTable value="{!joinedWrp}" var="j">
                    <apex:column ><apex:inputCheckbox value="{!j.selected}" id="checkedone" >
                    </apex:inputCheckbox></apex:column>
                    <apex:column value="{!j.g.name}"/>
                 </apex:pageBlockTable>
                 <apex:commandButton value="Add Groups" action="{!processChosenGroups}" reRender="popup"/>
             </apex:outputPanel>
         </apex:pageblockSection>
        
         </apex:pageBlock> 
    </apex:form>
    
    <style type="text/css">
     .customPopup{
         background-color: white;
         border-color: grey;
         border-style: solid;
         border-width: 2px;
         left: 50%;
         padding:10px;
         position: absolute;
         z-index: 9999;
         width: 400px;
         margin-left: 160px;
         top:100px;
     }
    </style>

</apex:page>

    public Pagereference processChosenGroups() {
        
        List<Group__c> chosenGroups = new List<Group__c>();
        for(jnwrapper j : joinedlist){
            if(j.selected == true){
                chosenGroups.add(j.g);
            }
        }
        isLookupfld = false;
        return null;
    }  

 

Best regards!

  • February 21, 2012
  • Like
  • 0

i have a VF page code

<apex:pageBlockSection collapsible="false"  columns="2" >

                <apex:inputField value="{!Opp.field1__c}"/> 
                <apex:inputField value="{!Opp.field2__c}"/> 
                <apex:outputField value="{!Opp.field3__c}"/>    
                <apex:outputField value="{!Opp.field4__c}"/>    
        </apex:pageBlockSection>

 I want to have a command button inside the blockSection. Can we have something like a colspan on table to merge the first line to a single column to hold the command button?

Hi

 

I need to save the original JSON I'm getting in the REST POST call-in to later send it in a callout.

To do that I have a text field on the object I create which holds the JSON string.

 

The problem is that a backslash is added before each double quote, and the system that gets this JSON when I callout can't process it.

 

Does anyone know why isn't the JSON saved in its original format and how can I work around this?

 

Many Thanks

 

 

 

  • February 20, 2012
  • Like
  • 0

I have an object rules which has records with one of the fields(rule Name) as  rule 1 , rule 2 , rule 3 etc......

Now on some other page or object I want to have a picklist which fetches values from rule object i.e. rule name.

I essence the value of picklist should be rule 1 , rule 2, rule 3 etc..........

 

How can we achieve this?

Hi,

 

I'm new to salesforce so please excuse the silly questions.

 

My problem is this:

 

I have a need for a section which contains 6 assorted fields (free text and picklist), and there must be a possible 10 children for this layout. Currently I have an issue where all 6 fields sit on the same line and exceed the page width.

 

My Questions are:

 

1. Is there a minimum width for fields on a page?

 

2. Is there a way to make the fields display across two rows per child? I'm currently using pageBlockTable which may restrict this?

 

Thanks

 

Chris

I am trying to write a test for a visualforce page where user is searching for a keyword to choose a record to add to the opportunity. How do I solve my error?

 

error

System.NullPointerException: Attempt to de-reference a null objectClass.AddCustomerProductStage1create.processSelected: line 76, column 1 Class.TestAddCustomerProductStage1create.myUnitTest: line 48, column 1

 

Test Class

@IsTest public class TestAddCustomerProductStage1create {

    /* This is a basic test which simulates the primary positive case for the 
       save method in the AddCustomerProduct class. */
Static AddCustomerProductStage1create ext;
public static testMethod void myUnitTest() {
    
    Account acc1=new Account(Name='test', BillingStreet='test', BillingCity='NY', BillingState='test',
                BillingCountry='US', BillingPostalCode='test', ShippingStreet='test', ShippingCity='test',
                ShippingState='NY', ShippingCountry='US', ShippingPostalCode='test');
insert acc1;                


Opportunity op = new Opportunity(Name='TestOppty',closedate=date.parse('1/1/2222'),
                    stagename = 'prospecting',AccountID=acc1.id,Equip_Services_Options_to_be_quoted__c='test', 
                    Opportunity_Region__c='test');
insert op;   

    System.assertEquals('TestOppty', op.name);
            
    PageReference pageRef = Page.CustomerProductStage1create;
    
    pageRef.getParameters().put('oppid', op.id);

    Test.setCurrentPageReference(pageRef);
    
    Customer_Product_Line_Item__c c = new Customer_Product_Line_Item__c(name='Apple', opportunity__c=op.id);
    insert c;
    
    Customer_Product__c cp = new Customer_Product__c(name='Apple');
    
    System.assert (true, [select name from Customer_Product_Line_Item__c where name = 'Apple']);

               ApexPages.StandardController sc = new ApexPages.StandardController(New Customer_Product_Line_Item__c());     
               
                ext = new AddCustomerProductStage1create(sc );           
    
     String cpUrl = '/apex/customerproductstage1create?oppid=' + op.id;
     
        System.Debug('++++++++++++'+cpUrl);
    
     PageReference ref = new PageReference(cpUrl);
          
     Test.setCurrentPage(ref); 
     
     ApexPages.currentPage().getParameters().put(cp.name, 'ap');
     
     PageReference proc = ext.processSelected();
 
}
}

 Class

public class AddCustomerProductStage1create{

/* Constructor Function. The CustomerProduct id is captured in this function */

public Customer_Product_Line_Item__c cpl {get;set;}
public Opportunity o;
public AddCustomerProductStage1create(ApexPages.StandardController c)
{
            o = [select id from Opportunity where id =
                       :ApexPages.currentPage().getParameters().get('oppid')];
}

      public Opportunity getOpportunity() {
            return o;
      }

/* Variable declarations */

public List<cCustomer> cpList {get; set;}                              // Wrapper class which stores customer product data and a boolean flag.
public List<cCustomer> cpsel{get; set;}
public ID oid {get; set;}

String userinput;                                                               // cp Name
String userinp;  



Public List<Customer_Product__c> results = new List<Customer_Product__c>();                 // Customer_Product__c search results.

Public List<Customer_Product__c> selproduct = new List<Customer_Product__c>();                 // Customer_Product__c selectedproduct.

/* End of Variable declarations */

/* Getter and setter methods for getting the user input ie. Customer_Product__c name from the UI */

public String getuserinput(){return userinput;}
public void setuserinput(String userinp)
{

this.userinput=userinp;
system.debug('*****SFDC-TEST-1**********'+userinput+'='+userinp);

}
public String getselproduct(){return null;}

/*End of Getter and Setter methods */

/* Method to Search the Customer_Product__c database to return the query results */
public List<Customer_Product__c> cpsearch()
{
     cpList = new List<cCustomer>();
     for(Customer_Product__c c : [select id, name from Customer_Product__c where Name like :userinput+'%'order by Name asc])
     {
         cpList.add(new cCustomer(c));
        
     }
system.debug('*****SFDC-TEST-2**********'+cpList);
 return null;
}
/* End of method */


/* Method for returning the Customer Product search results to the UI */
public List<cCustomer> getresults(){
    
 return cpList;

}
    public PageReference processSelected() {

                //We create a new list of Customer Products that we be populated only with Customer Products if they are selected
        List<Customer_Product__c> selectedProduct = new List<Customer_Product__c>();

        //We will cycle through our list of cCustomer and will check to see if the selected property is set to true, 
        //if it is we add the Customer Product to the selectedProduct list
        for(cCustomer cCon : getresults()) {
            if(cCon.selected == true) {
                selectedProduct.add(cCon.con);
                
                
            }
        }
system.debug('*****SFDC-TEST-3**********'+selectedProduct);
        // Now we have our list of selected products and can perform any type of logic we want
        System.debug('These are the selected Products...');
        for(Customer_Product__c cCon : SelectedProduct ) {
            system.debug(cCon);
            
            selproduct.add(cCon);
            
        }
         system.debug('*****SFDC-TEST-4**********'+selproduct.size());

    cpsel = new List<cCustomer>();
     for(Customer_Product__c p : [select name from Customer_Product__c where id =:selproduct])
     {
     system.debug('*****SFDC-TEST-p**********'+p.name);
       cpsel.add(new cCustomer(p));
       
        Customer_Product_Line_Item__c cpli = new Customer_Product_Line_Item__c(Name = cpsel[0].con.name, 
                Opportunity__c = o.id);
      
      insert cpli;
      system.debug('*****test cpli.name**********'+cpli.name);     
     }
         PageReference home = new PageReference('/' + o.id);
        home.setRedirect(true);
        return home;

  system.debug('*****SFDC-TEST-5**********'+cpsel.size());
        return null;
    }


/* Wrapper class to contain contact record and a boolean flag */
public class cCustomer{
 public Customer_Product__c con {get; set;}
 public Boolean selected {get; set;}

 /*This is the contructor method. When we create a new cContact object we pass a
 Contact that is set to the con property. We also set the selected value to false*/
 public cCustomer (Customer_Product__c c)
 {
     con = c;
     selected = false;
 }
}

/* end of Wrapper class */    

}

 How do I solve this test coverage error?

 

Thank you

HI , 

i wanna display a date picker on my visualforce page

How is this possible using Apex code, 

could any one help me how would i achieve

would be helpful if any example or sample is shown for 

better understanding

 

 

thanks

Hi,

I am new developer to Salesforce.. I have a custom object of 'Value' having the following feilds,

 

Name(Primary Key)

VSDesc__c(Description)

Parent_Value__c(Parent Value)

Child_Parent_Value__r(Look up)

 

now i want to have nested table in which each Parent should display its childs as shown here:

 

http://www.forcetree.com/2010/04/nested-tables-and-nested-queries-in.html

 

I have made the controller as :

 

//Control Class

 

public class ValueManager
{  
  public List<Seg1__c> getValue()
   {
List<Seg1__c> Values = [Select Name, (Select Name, VSDesc__c From Child_Parent_Value__r where Parent_Value__c <> null) From Seg1__c p where p.Parent_Value__c= null] ;
      return Values;  
  }
}

 

 

//Visual Page

 

<apex:page controller="ValueManager" showheader="false">

<apex:pageblock >

<apex:pageblocktable value="{!Value}" var="par">

<apex:column headervalue="Parent Value">
<apex:outputtext value="{!par.Name}"/>
</apex:column>

<apex:pageblocktable value="{!Value}" var="ch">
<apex:column headervalue="Description">
<apex:outputtext value="{!ch.Name}"/>
</apex:column>
</apex:pageblocktable>


</apex:pageblocktable>
</apex:pageblock>

</apex:page>

 

Can any one help me how can i acheive???


  • February 17, 2012
  • Like
  • 0
Hi,
 

I downloaded the salesforce client certificate from salesforce website, but when I use keytool to import this certificate to keystore. the error message comes as below.

keytool -import -alias sforce -file sfdc_client.cert -keystore trust.keystore
Enter keystore password:  tangquan
keytool error: java.lang.Exception: Input not an X.509 certificate

but it is successful with the verisign public certificate. the salesforce certificate ends with cert file extension, but verisign's ends with cer file extension. It will be helpful if you guys provide information on this.