• Puja_mfsi
  • SMARTIE
  • 1892 Points
  • Member since 2013
  • Software Engineer
  • Mindfire Solutions Pvt. Ltd.

  • Chatter
    Feed
  • 54
    Best Answers
  • 0
    Likes Received
  • 1
    Likes Given
  • 1
    Questions
  • 237
    Replies
Hello!

I have a custom controller that I got online and customized for my own environment and use. I have tested it personally and I think it's ready for prod. But I don't know how to write a test case for this type of controller!  I've looked at lots of documentation, but can't seem to find what I"m looking for.

Basically what this controller does is supports the VF page below which dynamically adds or deletes rows in order to add multiple opportunities at a time.

I know how to write a test case for something like the save method, but I need help when it comes to page references and other methods like addrows or deleterows.  

Thank you so much for any help!!

User-added image

public class ManageListController
{
public List<OpportunityWrapper> wrappers {get; set;}
public static Integer toDelIdent {get; set;}
public static Integer addCount {get; set;}
private Integer nextIdent=0;
 
public ManageListController()
{
  wrappers=new List<OpportunityWrapper>();
  for (Integer idx=0; idx<5; idx++)
  {
   wrappers.add(new OpportunityWrapper(nextIdent++));
  }
}
 
public void delWrapper()
{
  Integer toDelPos=-1;
  for (Integer idx=0; idx<wrappers.size(); idx++)
  {
   if (wrappers[idx].ident==toDelIdent)
   {
    toDelPos=idx;
   }
  }
  
  if (-1!=toDelPos)
  {
   wrappers.remove(toDelPos);
  }
}
 
public void addRows()
{
  for (Integer idx=0; idx<addCount; idx++)
  {
   wrappers.add(new OpportunityWrapper(nextIdent++));
  }
}
 
public PageReference save()
{
  List<Opportunity> opps=new List<Opportunity>();
  for (OpportunityWrapper wrap : wrappers)
  {
   opps.add(wrap.opp);
  }
  
  insert opps;
  
  return new PageReference('/' + Schema.getGlobalDescribe().get('Opportunity').getDescribe().getKeyPrefix() + '/o');
}
 
public class OpportunityWrapper
{
  public Opportunity opp {get; private set;}
  public Integer ident {get; private set;}
  
  public OpportunityWrapper(Integer inIdent)
  {
   ident=inIdent;
   opp=new Opportunity(Name='Cash Donation',RecordTypeId='012i0000000Hrcv',StageName='Posted',Probability=100);
  }
}
}

Hi,

 

  Need a visual force page .

 

 Having all account list as picklist , based on selected account a contact picklist(contacts related to particular account) should be shown ..Whenever a contact is selected a text field contains a phone number of the contact will be dispalyed.

 

Can any one please help in developing this.

 

Thanks in advance.

 

Hi community,

 

I have a button on which I want to include a warning message, that is, when the user clicks on the button, a message appears asking if he/she wants to continue...

 

This is where I have gotten so far, when I click on the button I do have the message popping up and asking if I want to continue, however the change() action is called even if I close this window...I want the processing to take place only if the user clicks OK...

 

Thanks you!

 

 

<apex:page controller="HelloWorld">

<apex:form >
<apex:commandButton value="Warning" onclick="javascript&colon;window.alert('Do you want to proceed?');" action="{!change}"/>
</apex:form>

</apex:page>

 

  • November 27, 2013
  • Like
  • 0

Hello Everyone,

 

I am using following statement to retreive Logged in User role name from VFP.

 

{!Left($UserRole.Name,(FIND('CEO', $UserRole.Name) - 1))}  -->am able to get the expected value and it is working. but when I pass the merge field in FIND method the vfp shoiwng BLANK.

ex:

{!Left($UserRole.Name,(FIND('{!$Label.testLabel}', $UserRole.Name) - 1))} - How to use custom variable or class variable in Find method..

Do we have any workaround for this or FIND method does'nt accept Merge fields!

 

Thanks,

Balakrishna

 

  • November 12, 2013
  • Like
  • 0

Hi All,

 

I am trying to replace all occurances of a perticular string in javascript ,but the value is not getting change

Ex 

Var str = 'Hello_world_congrats';

str = str.replace(/_/g,'&');

 

In this code i am trying to convert all '_' characters with '&' but the value is not getting change.

 

 

Can any one please let me know what's wrong in this.

Thanks in advance.

 

 

Raj.

  • November 11, 2013
  • Like
  • 0

Hi,

 

I have displayed one image on visualforce page using outputField.

This field data type is TextArea(Rich) in the crm.

The problem is I am not able to keep its width constant thro attribute style="width:400px;".

Any solutions for this?

  • October 21, 2013
  • Like
  • 0

I have a trigger with recursive control that performs both Before Insert and Before Update, but I cannot figure out how to test the Before Update in my test class.  When I insert the test data in my unit test, the recursive variable is set to true and will block my update from setting off the trigger.  This is only desirable for when it runs in production, but not when I need to insert data in order to test situations where existing data is being updated.  I even tried inserting the test data above the test.startTest() line.  But this does not matter since every action in the test method occurs in the same context.

 

How do I write my test class to cover this?

 

 

Trigger code: 

 

trigger PriceModifierTrigger on OpportunityLineItem (before insert, before update) {

	if(!PriceModifierClass.hasAlreadyRunMethod()){
		if(trigger.isBefore && trigger.isInsert){
			PriceModifierClass.sortOppProducts(trigger.new, trigger.oldMap, 'Insert');
		}
		if(trigger.isBefore && trigger.isUpdate){
			PriceModifierClass.sortOppProducts(trigger.new, trigger.oldMap, 'Update');
		}
		PriceModifierClass.setAlreadyRunMethod();	
	}
}

 

 

Excerpt from class:

public static boolean hasAlreadyRun = false;
	
	public static boolean hasAlreadyRunMethod(){
		return hasAlreadyRun;
	}
	
	public static void setAlreadyRunMethod(){
		hasAlreadyRun = true;
	}

 

Hi,

I'm facing a weird error "Formula Expression is required on the action attributes".

 

My VF Page:

<apex:commandButton value="Log-in"  action="{!loginTest}"/>

 

My Class:

public pagereference loginTest(){
pagereference redirect = new PageReference('apex/newPage');
redirect.setRedirect(true);
system.debug('Hello@@'+redirect);
return redirect;
}

 

But when I click on login button i'm facing a weird error 'Formula Expression is required on the action attributes'.

 

Syntax looks fine,but some how it is not working.

Any help is much appreciated :)

 

Dear Salesforce experts,

I was having issues with copying text over from an inputfield to a textfield upon clicking on a checkbox.

The current visualforce page contains an inputfield (Id=companyId in the code below) that consists of a lookup to a company. This field is rendered if the "Create New" checkbox is not checked.

Upon clicking on the checkbox, the inputfield is replaced by a textfield for the user to enter the company name. At this very moment, the textfield that is rendered needs to be auto-populated with the text that was entered in the inputfield. I have attempted to use javascript to accomplish this, but so far have had no luck.

  

Visualforce page below:

 

<apex:page controller="CompanyUpdate" deferLastCommandUntilReady="true" >
    <script>
    function setObjectValues(input, companyId, companyText) {
 
        if(input.checked) {
            document.getElementById(companyText).value = document.getElementById(companyId).value; //copy the inputfield value over to the text field
            document.getElementById(companyId).value = ''; //set company lookup field to blank, to avoid the lookup validation
        }
    }
    </script>
   
    <apex:form >
        <apex:pageBlock >
            <apex:outputPanel id="entryPanel">
                <apex:pageBlockSection columns="1" collapsible="false"> 
                    <apex:pageBlockTable value="{!newUpdates}" var="n" width="100%" cellpadding="2" cellspacing="0" columnsWidth="30%,70%" styleClass="summaryTable">
                        <apex:column headerValue="Company">
                            <apex:inputField id="companyId" value="{!n.entry.Company__c}" rendered="{!NOT(n.create)}" />
                            <apex:inputText id="companyText" value="{!n.company}" rendered="{!(n.create)}"/>
                            <apex:outputLabel value="Create New" for="create"/>
                            <apex:inputCheckbox value="{!n.create}" id="create"  onchange="setObjectValues(this,'{!$Component.companyId}','{!$Component.companyText}');">
                                <apex:actionSupport event="onclick" rerender="entryPanel"/>
                            </apex:inputCheckbox>
                        </apex:column>
                    </apex:pageBlockTable>
                 </apex:pageBlockSection>
            </apex:outputPanel>
        </apex:pageBlock>
    </apex:form>
</apex:page>

 

  If anyone could provide some advice, it will be much appreciated! Thanks in advance!

 

  • October 10, 2013
  • Like
  • 0

I created the following VF email template. However I am recieving the following Error: Unknown property 'core.email.template.EmailTemplateComponentController.Opportunity'

 

See VF email template below:

<messaging:emailTemplate subject="Channel Special Pricing Approval Request:{!relatedTo.name}" recipientType="User" relatedToType="Opportunity">
<messaging:plainTextEmailBody >
<html>
<body>
<p>
A new Channel Special Pricing Request has been submitted for your review and is pending your approval.  The link provided will take you to the opportunity in Salesforce.com.  If you are receiving this on your mobile devise, a summary of the opportunity details follows below the link.
</p>
<p>
You can approve or deny this request from your mobile devise by replying to this message and typing approved or rejected in the first line of the email body.  You may add any additional comments in the second and subsequent lines.  The additional comments will be added to your approval or denial record.
</p>
 <STYLE type="text/css">
               TH {font-size: 11px; font-face: arial;background: #CCCCCC; border-width: 1;  text-align: center } 
               TD  {font-size: 11px; font-face: verdana } 
               TABLE {border: solid #CCCCCC; border-width: 1}
               TR {border: solid #CCCCCC; border-width: 1}
         </STYLE>
        <font face="arial" size="2">  
 <table border="0" >
                 <tr > 
                     <th>Action</th><th>Product Name</th><th>Quantity</th><th>Disti Price</th><th>Discount%</th><th>Discount $</th><th>Discount Price</th>
                  </tr>
    <apex:repeat var="opp" value="{!relatedTo.OpportunityLineItems}">
       <tr>
           <td><a href="https://na1-blitz01.soma.salesforce.com/{!opp.id}">View</a> |  
           <a href="https://na1-blitz01.soma.salesforce.com/{!opp.id}/e">Edit</a></td>
           <td>{!opp.PriceBookEntry.name}</td>
           <td>{!ROUND(opp.Quantity,0)}</td>
           <td>{!ROUND(opp.ListPrice,0)}</td>
           <td>{!ROUND(opp.Discount__c,0)}</td>
           <td>{!ROUND(opp.Discount,0)}</td>
           <td>{!ROUND(opp.Requested_Price__c,0)}</td>
       </tr>
    </apex:repeat>                 
       </table>
       <p />
 </font>
<h4>Opportunity Detials:</h4>
<table border="1">
<tr>
<th>Opportunity Name: {!Opportunity.Name}</th>
<th>Channel Request Authorization: {!Opportunity.ChannelRequestAuthorization__c}</th>
</tr>
<tr>
  <td>QLogic Sales Person (Opportunity Owner):</td>
  <td>{!Opportunity.OwnerFullName}</td>
</tr>
<tr>
  <td>Distributor:</td>
  <td>{!Opportunity.Distributor__c}</td>
</tr>
<tr>
  <td>Reseller:</td>
  <td>{!Opportunity.Reseller__c}</td>
</tr>
<tr>
  <td>End User:</td>
  <td>{!Opportunity.Account}</td>
</tr>
<tr>
  <td>End User Website:</td>
  <td>{!Account.Website}</td>
</tr>
<tr>
  <td>Competitor:</td>
  <td>{!Opportunity.Competitor1__c}</td>
</tr>
<tr>
  <td>Partner Status:</td>
  <td>{!Opportunity.Partner_Status__c}</td>
</tr>
<tr>
  <td>Opportunity Comments:</td>
  <td>{!Opportunity.OpportunityComments__c}</td>
</tr>
<tr>
  <td>Opportunity Amount:</td>
  <td>{!Opportunity.Amount}</td>
</tr>
<tr>
  <td>Approved Opportunity Value:</td>
  <td>{!Opportunity.Approved_Opportunity_Value__c}</td>
</tr>
<tr>
  <td>POS Value Claimed:</td>
  <td>{!Opportunity.POS_Value_Claimed__c}</td>
</tr>
<tr>
  <td>Net Opportunity POS:</td>
  <td>{!Opportunity.Net_Opportunity_POS__c}</td>
</tr>
<tr>
  <td>Total Credit Claimed:</td>
  <td>{!Opportunity.Total_Credit_Claimed__c}</td>
</tr>
<tr>
  <td>Max Discount %:</td>
  <td>{!Opportunity.Max_Discount__c}</td>
</tr>
</table>
</body>
</html>
</messaging:plainTextEmailBody>
</messaging:emailTemplate>

Hi all, i would need some help to display a list of result in list view (pageBlockTable)

 

i have a very simple VF page just to display result (retrieve from webservive in format [aaa;bbb;ccc;ddd;eee]) in list view after clicking a button.

 

this is my VF code:

<apex:page standardController="Contact" extensions="SalesforceDB" recordSetVar="contacts">
    <apex:sectionHeader title="External DB Conn" subtitle="Getting data from Local DB"/>
    <apex:form >
        <apex:pageBlock title="Policy Listing">
                <apex:pageBlockButtons >
                    <apex:commandButton value="Confirm" action="{!getDBInfo}" />
                    
                    <apex:pageBlockTable value = "??" var = "c">
                
                    </apex:pageBlockTable>
                
                </apex:pageBlockButtons>
            <apex:pageblocksection >
                <!--apex:pageBlockSectionItem -->
                    <!--apex:outputlabel value="{!'Label'}"></apex:outputlabel-->
                    <!--apex:inputText /-->
                <!--/apex:pageBlockSectionItem-->
                
                                                      
            </apex:pageblocksection>
            
        </apex:pageBlock>
    </apex:form>
</apex:page>

 

this is my extensions class:

 

public class SalesforceDB{
        
    private final Contact conc;
    private List <String> result;
    
    public SalesforceDB(ApexPages.StandardSetController stdcontroller) {
        this.conc = (Contact)stdcontroller.getRecord();

    }

    public List<String> getDBInfo() {
        string MyReturn;
        salesforceconLocalConDB.Contactdetails stub = new salesforceconLocalConDB.Contactdetails();
        stub.timeout_x = 120000 ;     
        result = stub.getname(conc.Policy_No__c);
        System.debug('* Result:' + result);
        MyReturn = result[0];
        System.debug('* MyRetrun:' + MyReturn);
        return result;
    }
}

 

what should i put to display the result in list view??

I am trying to create a visualforce that will render as a pdf. I am recieving the following error: 

 

Error: Unknown property 'Funded_Program_Request__c.Funded_Request_Status__c' referenced in Approved_Funded_Program_Request

 

I am not sure why I am getting this error. Code is listed below.

 

<apex:page > standardController="Funded_Program_Request__c" standardStylesheets = "false" showHeader="false" renderAS="pdf" extension="ApprovedFundedProgramRequestPDF">
    <body>
        <apex:stylesheet value="{!URLFOR($Resource.styles, 'styles.css')}"/>
         <center><apex:image value="{!URLFOR($Resource.QLogicLogos,'ultimate_logo_horiz_blue_on_white_small.jpg')}"/></center>
        <center><u>
            <apex:outputText value="{!$Organization.Street}" style="font-size:12px"/>&nbsp;&nbsp;&nbsp;&nbsp;
            <apex:outputText value="{!$Organization.City}, {!$Organization.State} {!$Organization.PostalCode}" style="font-size:12px"/>&nbsp;&nbsp;&nbsp;&nbsp;
            <apex:outputText value="{!$Organization.Phone}" style="font-size:12px"/>  
        </u></center>   
        <br></br><br></br>
        <br></br><center><apex:outputText value="Approved Funded Program Request" style="font-weight:bold; font-size:30px" /></center><br></br>
        <b> Date: </b> <apex:outputText value=" {!NOW()}" /><br></br><br></br>
        <br></br><center><apex:outputText value="Program Summary" style="font-weight:bold; font-size:20px" /></center><br></br>
        <b> Funded Request status: </b> <apex:outputText value="{!Funded_Program_Request__c.Funded_Request_Status__c}" />
        <b> Funded Program Name: </b> <apex:outputText value="{!Funded_Program_Request__c.Name}" />
        <b> Funded Request status: </b> <apex:outputText value="{!Funded_Program_Request__c.Funded_Request_Status__c}" />
        <b> Source of Funding: </b> <apex:outputText value="{!Funded_Program_Request__c.Source_Of_Funding__c}" />
        <b> Other Source of Funding: </b> <apex:outputText value="{!Funded_Program_Request__c.Other_Source_of_Funding__c" />
        <b> Theater: </b> <apex:outputText value="{!Funded_Program_Request__c.Theater__c}" />
        <b> Goal Alignment: </b> <apex:outputText value="{!Funded_Program_Request__c.Goal_Alignment__c}" />
        <b> Product Focus: </b> <apex:outputText value="{!Funded_Program_Request__c.Theater__c}" />
        <b> Other Product: </b> <apex:outputText value="{!Funded_Program_Request__c.Other_Product__c" /><br></br><center><apex:outputText value="Payment Information" style="font-weight:bold; font-size:20px" /></center><br></br><br></br>
    <b> Partner(Company Name): </b> <apex:outputText value="{!Funded_Program_Request__c.Partner__c}" />
        <br></br> <br></br><b>
        <apex:panelGrid columns="3" width="100%">
            <apex:outputText value="{!Funded_Program_Request__c.Street_Name__c}" />  
            <apex:outputText value="{!Funded_Program_Request__c.City__c}" />   
            <apex:outputText value="{!Funded_Program_Request__c.PostalCode__c}" />
        </apex:panelGrid></b>
        <apex:panelGrid columns="3" width="100%">
            <apex:outputText value="{!Funded_Program_Request__c.Partner_Contact__c}" />  
            <apex:outputText value="{!Funded_Program_Request__c.Contact_Email__c}" />   
            <apex:outputText value="{!Funded_Program_Request__c.Contact_Phone__c}" />
        </apex:panelGrid>
        <br></br><br></br>
        <br></br><br></br>
    </body>
</apex:page>

 

Please help!

 

I am very new to Apex. I have pulled together about 15 Apex triggers, and I need help building test classes for them. I need to have them ready to deploy very quickly and I do not know enough about Apex yet to really be able to build the test classes. Is there anyone that may be able to help me build test classes for these triggers?

 

Thanks,

 

Gustav

  • September 26, 2013
  • Like
  • 0

public with sharing class ProductSearchController
    {
    // the soql without the order and limit
     private String soql {get;set;}
     // the collection of products to display
    public List<Product2> Products {get;set;}
    // the current sort direction. defaults to asc
    public String sortDir
    {
    get 
    {
        if (sortDir == null)
        { 
        sortDir = 'asc';
        }
    return sortDir; 
    }
    set;
    }
 
  // the current field to sort by. defaults to  name
    public String sortField
    {
    get 
    {
    if (sortField == null)
        {
        sortField = 'Name';
        }
         return sortField; 
      }
    set;
    }
 
  // format the soql for display on the visualforce page
  public String debugSoql {
    get { return soql + ' order by ' + sortField + ' ' + sortDir + ' limit 20'; }
    set;
  }
 
  // init the controller and display some sample data when the page loads
  public ProductSearchController() {
    soql = 'select name,productcode from Product2 where name != null';
    runQuery();
  }
 
  // toggles the sorting of query from asc<-->desc
  public void toggleSort()
  {
    // simply toggle the direction
    sortDir = sortDir.equals('asc') ? 'desc' : 'asc';
    // run the query again
    runQuery();
  }
 
  // runs the actual query
  public void runQuery()
  {
 
    try {
      Products = Database.query(soql + ' order by ' + sortField + ' ' + sortDir + ' limit 20');
    } catch (Exception e) {
      ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'Ooops!'));
    }
 
  }
 
  // runs the search with parameters passed via Javascript
  public PageReference runSearch() {
  
    String name = Apexpages.currentPage().getParameters().get('name');
    String productcode = Apexpages.currentPage().getParameters().get('productcode');
    soql = 'select name,productcode from product2 where name != null';
    if (!name.equals(''))
      soql += ' and name LIKE \''+String.escapeSingleQuotes(name)+'%\'';
    if (!productcode.equals(''))
      soql += ' and productcode LIKE \''+String.escapeSingleQuotes(productcode)+'%\'';
 // run the query again
    runQuery();
 
    return null;
  }

 

 

 

<apex:page controller="ProductSearchController" sidebar="false">
  <apex:form >
  <apex:pageMessages id="errors" />
  <apex:pageBlock title="Find Me A Product" mode="edit">
  <table width="100%" border="0">
  <tr> 
    <td width="200" valign="top">
 
      <apex:pageBlock title="Parameters" mode="edit" id="criteria">
 
      <script type="text/javascript">
        function doSearch()
        {
        searchServer
        (document.getElementById("name").value,
         document.getElementById("productcode").value,);
        }
      </script>         
          
      <apex:actionFunction name="searchServer" action="{!runSearch}" rerender="results,debug,errors">
          <apex:param name="name" value="" />
          <apex:param name="productcode" value="" />
          </apex:actionFunction>
    <table cellpadding="2" cellspacing="2">
      <tr>
        <td style="font-weight:bold;">Name<br/>
        <input type="text" id="name" onkeyup="doSearch();"/>
        </td>
      </tr>
      <tr>
        <td style="font-weight:bold;">Product Code<br/>
        <input type="text" id="productcode" onkeyup="doSearch();"/>
        </td>
      </tr>
      </table>
 
      </apex:pageBlock>
      </td>
 
<td valign="top">
 
    <apex:pageBlock mode="edit" id="results">
 
        <apex:pageBlockTable value="{!Products}" var="Product">
 
            <apex:column >
                <apex:facet name="header">
                    <apex:commandLink value="Name" action="{!toggleSort}" rerender="results,debug">
                        <apex:param name="sortField" value="name" assignTo="{!sortField}"/>
                    </apex:commandLink>
                </apex:facet>
                <apex:outputField value="{!Product.name}"/>
            </apex:column>
 
            <apex:column >
                <apex:facet name="header">
                    <apex:commandLink value="productcode" action="{!toggleSort}" rerender="results,debug">
                        <apex:param name="sortField" value="productcode" assignTo="{!sortField}"/>
                    </apex:commandLink>
                </apex:facet>
                <apex:outputField value="{!Product.productcode}"/>
            </apex:column>
 
          </apex:pageBlockTable>
       </apex:pageBlock>
 
    </td>
  </tr>
  </table>
 
  <apex:pageBlock title="Debug - SOQL" id="debug">
      <apex:outputText value="{!debugSoql}" />
               
  </apex:pageBlock>   
 
  </apex:pageBlock>
 
  </apex:form>
 
</apex:page>

 

 

i am unable to search product either by name or by product code,i tried a lot but i am unable to find tghe solution,can anyone please go through the code and say what i am doing wrong in the code.

  • September 25, 2013
  • Like
  • 0

Hi,

 

I need to convert some s-controls to vf page. But I do not have any idea about s-control. There are some s-controls are created. I want to know how to run s-control. (i.e. we can run vf page using url https://..../apex/testvf,  how to run s-control).

 

And what are the steps we need to keep in mind while converting s-controls to vf page. Is there any easiest way to do this?

if there is a visualforce element then we set visibility according to the redered attribute . =but i have to set visibility of visualforce according to data of html element

    <p style="display:{! IF(userSettings == null && $Profile.Name !='System Administrator','visible','hidden')}">Click on the authorize to authorize your self to Google GLASS Account &nbsp;<apex:commandButton value="Authorize" action="{! authorizeApp}"  />

i want to set visibility but its showing me the p element in every case.please guideline how to do this ??

  • September 22, 2013
  • Like
  • 0

Hi,

I'm looking for changing the default highlight background color used with a PageBlockTable.

I haven't seen a special property for the selectedDataRow (like selectedDataRowClasses by example) in apex:PageBlockTable.

 

I use two classes to alternate color (even/odd), but the selected row isn't really visible with the default color (I think it's #E3F3FF ) so i'd want to change it.

 

<apex:PageBlockTable id="TableContact" value="{!Contacts}" var="c" rendered="{!IsContact}" rowClasses="even,odd" >

 

I have a look into the HTML page source and I found a class "highlight" applied on the seledtedrow (i think)

 

I've tried to override this class in my page

 

<style>
.highlight  {background-color: Violet !important;}
</style>

 but it didn't change anything...

 

I also searched on the net with google and i didn't find anything about this possibilities...

 

I only found how to change the current cell background color with an OnMouseMove / OnMouseOut event on the columns

 

<apex:column onmousemove="DoOnMouseMoveOrOutCell(this, '{!HighlightColorCell}')" onmouseout="DoOnMouseMoveOrOutCell(this, '{!IF(!c.IsPresent,'',PresentColor)}')">

 and i added this script function

 

function DoOnMouseMoveOrOutCell(aComponent, aColor)
{
    aComponent.style.backgroundColor = aColor;
}

 

Is it possible to change this (default) color for the entire row and how ?

 

Thanks

We would like to create a bar code of the case number. This would then go onto a PDF document that is generated via visualforce.  How do i generate the code to produce the barcode with visualforce and an Apex controller?   Any help or suggestions would be appreciated. 

I must be doing something wrong, but I can't figure it out. Here's my code:

 

...

	List<List<String>> name1 = new List<List<String>>();
        List<String> name2 = new List<String>();
        name2.add('Fred');
        name2.add('Joe');
        System.debug(name2); //<--- Outputs DEBUG|(Fred, Joe)
        
	name1.add(name2);
        System.debug(name1); //<--- Outputs DEBUG|((Fred, Joe))
        
	name2.clear();
        name2.add('Mary');
        name2.add('Jane');
        System.debug(name2); //<--- Outputs DEBUG|(Mary, Jane)
        
	name1.add(name2);
        System.debug(name1); //<--- DEBUG|((Mary, Jane), (already output))

 


I would have expected that last one to output ((Fred, Joe), (Mary, Jane))
Any idea of what's going on?

 

Thanks, Dave

As you can see in this question, I am new in Test Classes.

 

i have a page wich have 3 opportunity fields,and these fields can be modified.

 

In the test class I need to instanciate the controller and  assign a new value in the opportunity name field.

 

In the controller, I get the opportunity querying to the database using the Id of the Opportunity that I get through Get parameter.

 

Can you help me in achieve it? (I suppose that it should be very easy, but after a long search in internet, I haven't found it)

Hi,

Anyone have any idea about how we verify the address in apex. i.e. suppose user fill the detail with their address and now i want to verify that address whether this address is valid or valid.

 

PLEASE HELP !!!!!! it's urgent

 

Thanks in advanced

Hi,

I want to remove "Save & New" button on a custom object. I created a home page component and gave this (<script src="015Z0000000FJf7" type="text/javascript"></script>) in the body of the component.

I have placed this component on my home pagelayout.

I have created a .js file with below and uploaded to salesforce in Documents. Gave this document id above on the home page component

window.onload = hideBtns;

    function hideBtns()
    {
     this.bodyOnLoad();
    if(document.getElementsByName("save_new")[0]!=null)
    document.getElementsByName("save_new")[0].style.display = 'none';
    if(document.getElementsByName("save_new")[1]!=null)
    document.getElementsByName("save_new")[1].style.display = 'none';
    }

It is not working for me. I am able to see the button. Am I missing something? How to make this work? Also how to remove the button on a single custom object and leave the button on all other objects. I would appreciate your help.

Thank you.
Hello!

I have a custom controller that I got online and customized for my own environment and use. I have tested it personally and I think it's ready for prod. But I don't know how to write a test case for this type of controller!  I've looked at lots of documentation, but can't seem to find what I"m looking for.

Basically what this controller does is supports the VF page below which dynamically adds or deletes rows in order to add multiple opportunities at a time.

I know how to write a test case for something like the save method, but I need help when it comes to page references and other methods like addrows or deleterows.  

Thank you so much for any help!!

User-added image

public class ManageListController
{
public List<OpportunityWrapper> wrappers {get; set;}
public static Integer toDelIdent {get; set;}
public static Integer addCount {get; set;}
private Integer nextIdent=0;
 
public ManageListController()
{
  wrappers=new List<OpportunityWrapper>();
  for (Integer idx=0; idx<5; idx++)
  {
   wrappers.add(new OpportunityWrapper(nextIdent++));
  }
}
 
public void delWrapper()
{
  Integer toDelPos=-1;
  for (Integer idx=0; idx<wrappers.size(); idx++)
  {
   if (wrappers[idx].ident==toDelIdent)
   {
    toDelPos=idx;
   }
  }
  
  if (-1!=toDelPos)
  {
   wrappers.remove(toDelPos);
  }
}
 
public void addRows()
{
  for (Integer idx=0; idx<addCount; idx++)
  {
   wrappers.add(new OpportunityWrapper(nextIdent++));
  }
}
 
public PageReference save()
{
  List<Opportunity> opps=new List<Opportunity>();
  for (OpportunityWrapper wrap : wrappers)
  {
   opps.add(wrap.opp);
  }
  
  insert opps;
  
  return new PageReference('/' + Schema.getGlobalDescribe().get('Opportunity').getDescribe().getKeyPrefix() + '/o');
}
 
public class OpportunityWrapper
{
  public Opportunity opp {get; private set;}
  public Integer ident {get; private set;}
  
  public OpportunityWrapper(Integer inIdent)
  {
   ident=inIdent;
   opp=new Opportunity(Name='Cash Donation',RecordTypeId='012i0000000Hrcv',StageName='Posted',Probability=100);
  }
}
}
dasari123
i created a site with login page as active site home page with controllers as login ,cancel,register ,i have site templete code which is active also but in my site iam unable to see the site template can you please help me out.

my created site addresses is 
survey234-developer-edition.ap1.force.com

Hi, I have a table that needs to pull the result of one custom field multipled by 12 (the current month for the year), for example.

 

I found this post: http://boards.developerforce.com/t5/Visualforce-Development/simple-calculation-within-page/m-p/532611#M57220 and tried it on my code, but my VF page is not returning any results (it's just blank).

 

Say the custom field is called "Quantity_This_Year__c" and I need "Quantity_This_Year__c*MONTH(TODAY())" result on the Vf Page.''

 

I have tried both MONTH(TODAY()) and just the number 12, and still, Vf page is blank next to this field.

 

Is that other post out of date? Anyone else know a way to perform a calculation where my result will not be blank?

  • December 16, 2013
  • Like
  • 0

Hi,

 

  Need a visual force page .

 

 Having all account list as picklist , based on selected account a contact picklist(contacts related to particular account) should be shown ..Whenever a contact is selected a text field contains a phone number of the contact will be dispalyed.

 

Can any one please help in developing this.

 

Thanks in advance.

When i click list view  button -selected records custom field are updated in corresponding records..Usong onclick javascript

My code :

{!REQUIRESCRIPT("/soap/ajax/19.0/connection.js")} //adds the proper code for inclusion of AJAX toolkit 
var url = parent.location.href; //string for the URL of the current page 
var records = {!GETRECORDIDS($ObjectType.Training__c)}; //grabs the Lead records that the user is requesting to update 
var updateRecords = []; //array for holding records that this code will ultimately update 

if (records[0] == null) {  

//if the button was clicked but there was no record selected 
alert

("Please select at least one record to update."); //alert the user that they didn't make a selection 
} else { //otherwise, there was a record selection 
for (var a=0; a<records.length; a++) { //for all records 
var update_Train = new sforce.SObject("Training__c"); //create a new sObject for storing updated record details 
update_Train.Id = records[a]; //set the Id of the selected Lead record 
update_Train.Training_Status__c= 'Pass'; or  update_Train.Status__c = true;
updateRecords.push(update_Train); 

result = sforce.connection.update(updateRecords); 
parent.location.href = url; //refresh the page 
}

Above code doesnt update record .When i click Please give ur idea when click  list button update or insert  the custom field - please help me.

  • December 13, 2013
  • Like
  • 0

In My pageblock table 5 rows.. 1st field is a commandlinks[1,2,3,4 and 5 values]..

 

If i click 1 means , 1 will be highlighted red color, other numbers 2,3,4,5 are asusual color,

click 2 means , 2 will be change red color , other numbers are 1,3,4,5 are asusual color,

cick 3 , means ,......

click 4 means .........

click 5 means ......

 

  • December 12, 2013
  • Like
  • 0

I got 60 % code coverage but i struck over here can anyone please  help me to cover the try  and catch blocks 

 

if(Q_AircraftType && Q_Position && Q_Hours && Q_Dateoflastflight && Q_DateoflastSim)
{
System.debug('AAAAAAAAAAAAAAA');
if (InsertCnt==0){
system.debug('In the final if line 116');
Aircraft_Contact__c actype = new Aircraft_Contact__c();
actype.RecordType = [select Id from RecordType where Name = 'Aircraft Type Pilot Layout' and SobjectType = 'Aircraft_Contact__c'];

actype.Candidate__c=[Select ts2__Application__r.ts2__Candidate_Contact__c FROM ts2__Prescreen2__c where ts2__Application__c =:ps.ts2__Application__c Limit 1].ts2__Application__r.ts2__Candidate_Contact__c;
actype.Aircraft_Type__c=[select Id from Aircraft_Type__c where name = :A_AircraftType ].Id;
actype.Position_on_A_C_Type__c=A_Position;

try{
actype.Total_Hours__c= integer.valueof(A_Hours);
}
catch(exception e)
{
ps.addError('Please ensure you enter a numeric number in the Total Hours.');
}

A_DateoflastSim=A_DateoflastSim.mid(3, 2)+'/'+A_DateoflastSim.left(2)+'/'+A_DateoflastSim.right(4);
A_Dateoflastflight=A_Dateoflastflight.mid(3, 2)+'/'+A_Dateoflastflight.left(2)+'/'+A_Dateoflastflight.right(4);

try{
actype.Date_of_Last_SIM__c=date.Parse(A_DateoflastSim); }
catch(exception e)
{
ps.addError('Please ensure that you enter you last SIM in the date format of DD-MM-YYY Ie. 31-01-2013');
}
try{

actype.Date_of_Last_Flight__c=date.Parse(A_Dateoflastflight); }
catch(exception e)
{
ps.addError('Please ensure that you enter you last flight in the date format of DD-MM-YYY Ie. 31-01-2013');
}

insert actype;
InsertCnt=InsertCnt+1;
}
}

I have a requirement where user would select an image(using apex:inputFile) and clicks preview button to see the preview of the selected image and once satisfied save button will save the image to the related attachment object. Transient keyword is not helping here as the selected image has to be show as preview first and I am running into view state error for large size images as blob variable for image has to be in view state. Any workarounds with out using Javascript is appreciated.


thanks in advance.

 

 

Hi community,

 

I have a button on which I want to include a warning message, that is, when the user clicks on the button, a message appears asking if he/she wants to continue...

 

This is where I have gotten so far, when I click on the button I do have the message popping up and asking if I want to continue, however the change() action is called even if I close this window...I want the processing to take place only if the user clicks OK...

 

Thanks you!

 

 

<apex:page controller="HelloWorld">

<apex:form >
<apex:commandButton value="Warning" onclick="javascript&colon;window.alert('Do you want to proceed?');" action="{!change}"/>
</apex:form>

</apex:page>

 

  • November 27, 2013
  • Like
  • 0

Hello there

 

I'm at my first Apex coding project. When testing my code, I receive errors saying that an insert failed because I tried to de-reference a null-pointer. In the Debug Log I found a section that is, in my opinion, the source for this null pointer exception.

 

In the code below, I have a method to add my Handler with its corresponding action. The method is called from a trigger which creates a new instance of my Handler and uses it along with the action as parameters.

 

The handler list is not yet initiated and this is done by passing it a list of Handlers out of the actionHandlerMapping. Usually actionHandlerMapping is empty upon first run of this method and so also handlerList is empty. That's why the handlerList is added the Handler passed by the method and the actionHandlerMapping is set a key-value pair with the name of the action and the list of handlers.

 

 

/**
*	Add handler to list of action type. Handler is an interface that my Apex class implements to handle certain
*	actions of a trigger. TriggerEvent is an Enum. actionHandlerMapping is a Map<String, Handler>
*/

public void addOneHandler(Handler theHandler, TriggerEvent theEvent)
{
	List<Handler> handlerList = actionHandlerMapping.get(theEvent.name());
	if (handlerList == null)
	{
		handlerList = new List<Handler>();
		handlerList.add(theHandler);
		actionHandlerMapping.put(theEvent.name(), handlerList);
	}
	else
	{
		handlerList.add(theHandler);
	}
}

 
Now in the "Variables" window of the Developer Console on Salesforce in the debug log, the list handlerList is always null. I have no clue why this list remains null even though I add a Handler object to it. The Handler Object itself exists as I can see on the Variables window, so I am not actually adding a null value.

 

Any help appreciated.

I have a custo object  Business. and i have a field  'Amount' on this object. On Account i want to display average of this  'Amount' field. I have created a Roll Up on Account but it was giving only Count , SUM,MIN,MAX. Then How to calculate Average? for this
  • November 22, 2013
  • Like
  • 0

Hi All,

 

This Apex trigger to automatically create the child record when a new parent record is created.But  If i am going to update on Studentname then  Error is thrown.pls help on this.

 

Error:Apex trigger createchildobj caused an unexpected exception, contact your administrator: createchildobj: execution of AfterUpdate caused by: System.DmlException: Update failed. First exception on row 0; first error: MISSING_ARGUMENT, Id not specified in an update call: []: Trigger.createchildobj: line 13, column 1

Parent:Student__c

Child:Class__c

 

 

trigger createchildobj on Student__c(after insert,after update)

{

List<Class__c> lstclass=new List<Class__c>();  

   for(Student__c s:Trigger.new)

{  

 if(s.name!=null){  

  lstclass.add(new Class__c(Name=s.name,Age__c=s.Age__c,classstu__c=s.id));

  }  

}

 if(lstclass.size()>0){

 

 update lstclass;  }

}

My Custom Visualforce page.
<apex:page controller="UnapprovedList">
<apex:pageBlock title="Opportunities">
<apex:pageBlockTable value="{!Opportunity}" var="item">
<apex:column value="{!item.Name}"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:page>

My Controller
public class UnapprovedList{
private final Opportunity opportunity;

public UnapprovedList() {
opportunity = [SELECT Id, Name FROM Opportunity limit 1];
// the page displays error if i remove limit 1.
//System.QueryException: List has more than 1 row for assignment to SObject
}

public Opportunity getOpportunity () {
return opportunity;
}
}

where is the problem?? i want to show more than one row but when i return multiple row the error pops up..
Any help would be appricated.

Here's a portion of a VF component.  I'm trying to get a command button to display an action Status.  But it doesn't work.

 

Will the "status=" option not work on a commandButton when it performs a regular action method?  I'm thinking maybe to get it to work you have to remove the action, add an onClick and then have an actionFunction call the actionMethod and have a refresh specified on the actionFunction.

 

 

	        <apex:actionStatus id="refreshStatus" layout="block"  >
              <apex:facet name="start" > 
              <apex:outputPanel >
                  <apex:image value="{!$Resource.Loader}"  rendered="true"/>&nbsp;&nbsp;&nbsp;
                  <apex:outputLabel value="Working . . ." style="font-weight:bold; color:red;"/>
              </apex:outputPanel>
              </apex:facet>
     	</apex:actionStatus>
	<br/>
	<apex:pageBlock >
	  <apex:pageBlockButtons >
	    <apex:commandButton value="Go to 1" action="{!theController.goto1}" disabled="true"/>
	    <apex:commandButton value="Go to 2" action="{!theController.goto2}" status="refreshStatus"/>
	    <apex:commandButton value="Go to 3" action="{!theController.goto3}" status="refreshStatus"/>
	  </apex:pageBlockButtons>

 

Hi All,

 

I am trying to replace all occurances of a perticular string in javascript ,but the value is not getting change

Ex 

Var str = 'Hello_world_congrats';

str = str.replace(/_/g,'&');

 

In this code i am trying to convert all '_' characters with '&' but the value is not getting change.

 

 

Can any one please let me know what's wrong in this.

Thanks in advance.

 

 

Raj.

  • November 11, 2013
  • Like
  • 0

In our custom app we are running VF pages that are all showheader=false

 

I don't want a user to be able to edit the URL and remove the VF page name that then allows them to get in the native salesforce pages and then they are out of the VF app.

 

Any way to prevent this?