• Sarge
  • SMARTIE
  • 645 Points
  • Member since 2010

  • Chatter
    Feed
  • 25
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 5
    Questions
  • 134
    Replies

Hello All,

 

Can somebody help me pleaseeeeeeeeeee............???

 

Problem -

if someone enters Number__c then Company__c should become as required..... But the problem here is Company__c is a Picklist value.

 

Validation Rule -

ISCHANGED( Number__c ) && (isblank(Company__c))

 

 

Error: Field Company__c is a picklist field. Picklist fields are only supported in certain functions.

 

Thanks,

Dan 

Hi All,

 

I am trying to write a test method for controller extension Apex class.I want to test the "save" functionality of an Apex class.Follwing is the code.

public class jobcntroller {

 

    public Job_Details__c job{ get; set; }

     public String CompanyName;

     public void setCompanyName(String CompanyName)

    {

        this.CompanyName = CompanyName;

    }

    ApexPages.StandardController controller;   

    String s;

 

 

 

 

    public jobcontroller(ApexPages.StandardController stdController) {

        job = new Job_Details__c ();    

        controller = stdController;

 

    }   

 

   public PageReference mysave() {

     Schema.DescribeSObjectResult result = ob_Details__c.sObjectType.getDescribe();    

     controller.save();

 

 

    PageReference pageRef = New PageReference('/' + result.getKeyPrefix() + '/e');

 

     pageRef.setRedirect(true);

     return pageRef;

 

     }

      static testMethod void testMyController() {

      //Use the PageReference Apex class to instantiate a page

        PageReference pageRef = Page.jobpage;

        //In this case, the Visualforce page named 'jobpage' is the starting point of this test method.

        Test.setCurrentPage(pageRef);

        //Instantiate and construct the controller class. 

       ApexPages.StandardController thecontroller;       

        jobcontroller controller = new jobcontroller(thecontroller);

        controller.setCompanyName('abc');

        //The .getURL will return the page url the Save() method returns.

        String nextPage = controller.mysave().getUrl();

        //Check that the save() method returns the proper URL.

        System.assertEquals('/apex/failure?error=noParam', nextPage);

 

     }

 

     }

 

When I do the runtest, I am getting the following message:

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

 

stack trace:

Class.jobcntroller.mysave: line 25, column 25

Class.jobcntroller.testMyController: line 44, column 27 External entry point

 

I am not able to correct the nullpointerexception. Any help on how to resolve this is greatly appreciated.

 

  • September 26, 2010
  • Like
  • 0
I have created a Custom Button in Opportunity tab called Invoice,and wen Click the custom Button It has to generate a Invoice for a particular Opportunity ID in a apex Page, Using Condition Only when Opportunity Name Equal to 'Testing' if not it has to be null.I have tried Several times using IF Control Statement,but im getting a error of URL NO LONGER EXIST, Here is my CUstom Button Code {!IF( Opportunity.Name = 'Testing' , '/apex/Invoice_1?id='&Opportunity.Id , null)} but its working fine wen the code is like below /apex/Invoice_1?id={!Opportunity.Id} Kindly Suggest me a Example for how to use IF statemnts in Calling URL Thanks in advance Sathish

Anyone know of a way to get the Week of the Month (number 1 to 5 depending on month/calendar) in Apex Classes?

If there is custom code that someone has built, please let me know.  THANKS.

 

 

I only found Day of Year for the Salesforce datetime methods.

 

example:  Day of Year

 

Datetime myDate = datetime.newInstance(2008, 2, 5, 8, 30, 12);
system.assertEquals(myDate.dayOfYear(), 36);

Hi,

 

Am still a newbie on APEX and testing scripts.  The APEX code itself works exactly right.  The Testing script contained is successful with 0% coverage.

 

What the controller does

 

We have an object called meeting note, and an object called attendee.  Attendee appears as a related list on a new meeting note. When a user clicks new a visualforce page loads with a very simple input form.  When the user hits save they are returned back to the meeting note note the saved attendee record.

 

Any pointers / help on the test script would be much appreciated.

 

 

public class attendeeExt {

    Attendee__c attendee;

    public attendeeExt(ApexPages.StandardController ctlr){
        
        this.attendee = (Attendee__c)ctlr.getRecord();
    }   
    
    public Attendee__c getAttendee(){
        if(attendee == null) attendee = new Attendee__c();
        return attendee;
    }    

    public PageReference Save(){
        try{
            insert attendee;
        }
        catch(DmlException ex){
            ApexPages.addMessages(ex);
        } 
        PageReference pr = new PageReference('/'+attendee.Meeting_Note__c);
        pr.setRedirect(True);
            return pr;
    }
    public static testMethod void testattendeeExt() {        
        Contact c = new Contact(FirstName='Test', LastName='Contact');
        insert c;
        
        Meeting_Note__c m = new Meeting_Note__c(Subject__c='Test');
        insert m;
        
        Attendee__c a = new Attendee__c(Meeting_Note__c = m.id, Contact__c = c.id);
        insert a;
                
        System.assertEquals(c.id,a.contact__c);
    }
}

 

 

Thanks

 

Ross

 

 

Hello everyone-

This should be a quick slam dunk for any trigger masters out there and should help me to start learning myself.

 

Goal-

When a task is added to an Opportunity the lookup field Rep_Team__c on the opportunity record is checked. If the field is populated then it will take that value and convert it to the corresponding task record picklist value Rep_Tm__c.

 

This is 1:1 conversion or nothing. (meaning if the picklist value is not available then it will be left alone.)

 

I really wish I could give more information than this but I don't understand the syntax and am hoping that by seeing the working code I can learn to create my own.

 

Thanks for any help!!

 

 

 

 

 

  • September 08, 2010
  • Like
  • 0

I'm trying to create a vforce page that lists select activities one after another, similar to the "View All" notes and attachments page.

 

I'd like to put each record in a pageblocksection, but the first one never renders correctly:

 

http://screencast.com/t/NGI4ZjMwNTct

 

Here's my page:

 

 

<apex:page standardController="Contact" extensions="ContactRelatedListController" title="View All Completed Activities">
    <table border="0" >
    	<apex:sectionHeader title="View All Completed Activities" />
	    <apex:repeat value="{!AllClosedTasks}" var="act">
			<apex:pageBlock >
		        <apex:pageBlockSection columns="1">
		            <apex:outputfield value="{!act.Subject}"/>
		            <apex:outputfield value="{!act.WhatId}"/>
		            <apex:outputfield value="{!act.ActivityDate}"/>
		            <apex:outputfield value="{!act.OwnerId}"/>
		            <apex:outputfield value="{!act.Type}"/>
		            <apex:outputfield value="{!act.Description}"/>
				</apex:pageBlockSection>
			</apex:pageBlock>
		</apex:repeat> 
    </table>
</apex:page>

 

 

and here are the relevant parts of my controller:

 

 

public class ContactRelatedListController {
    private final Contact cont;
    
    private final List<Task> closedTasks;
    private final List<Task> allClosedTasks;
    private final String completedActivitiesNumber;
    private final String massEmailNumber;

    public ContactRelatedListController(ApexPages.StandardController stdController) {
        this.cont = (Contact)stdController.getRecord();
        this.closedTasks = new List<Task>([
        	select Id, Subject, WhatId, ActivityDate, WhoId, Type, OwnerId, Description
        	from Task where WhoId = :cont.Id and IsClosed = true
			order by ActivityDate desc]);
    }
    
	public List<Task> getClosedTasks() {
		List<Task> x = new List<Task>();
		for (Task e : this.closedTasks) {
			if (!e.Subject.startsWith('Mass Email:') && x.size() < 5){
				x.add(e);
			}
		}
		return x;
	}
	
	public List<Task> getAllClosedTasks() {
		List<Task> x = new List<Task>();
		for (Task e : this.closedTasks) {
			if (!e.Subject.startsWith('Mass Email:')){
				x.add(e);
			}
		}
		return x;
	}

 

 

Any thoughts?

 

Thanks,

 Drew

 

hello all,

 

I am trying to create a custom button on a standard page that redirects to one or the other external url based on a value in the record.  So far I have not been able to get sf to do this - and if statement in javascript keeps giving me errors (don't know javascript that well so that could be my fault).  Any ideas?

 

-Hassab

  • September 07, 2010
  • Like
  • 0

I have been working on a visualforce page for the standard quote object intended to be pdf quote page. I am having a problem with creating a list of products on the page. When I attempt to add the product name from the quote line item table, I recieve the following error about line 30.

 

Error: Unknown property 'String.product2'

 

Below is the code:

 

<apex:page standardController="Quote">
    <apex:form id="theForm"> 
   
        <apex:pageBlock >
            <apex:pageMessages />
   
            <apex:pageBlockSection title="Essential Information" columns="2"  showHeader="false">
                <apex:outputField value="{!quote.Opportunity.AccountId}" />
                <apex:outputField value="{!quote.quotenumber}" />
                <apex:outputLabel value="Bill To">
                    <apex:outputField value="{!quote.Opportunity.Account.BillingCity}" />
                    <apex:outputField value="{!quote.Opportunity.Account.BillingState}" />
                    <apex:outputField value="{!quote.Opportunity.Account.BillingPostalCode}" />
                    <apex:outputField value="{!quote.Opportunity.Account.BillingCountry}" />
                </apex:outputLabel>
                <apex:outputField value="{!quote.createdDate}" />
                <apex:inputHidden />
                <apex:outputField value="{!quote.expirationDate}" />
             </apex:pageBlockSection>
            <apex:pageBlockSection title="Contact Info" columns="2"  showHeader="true">
                <apex:outputField value="{!quote.contactid}"/>
                <apex:outputField value="{!quote.Phone}"/>
                <apex:outputField value="{!quote.email}"/>
                <apex:outputField value="{!quote.fax}"/>
             </apex:pageBlockSection>
             </apex:pageBlock>
           <apex:pageBlock title="test">
        <apex:pageBlockTable value="{!quote.Quote_Line_Item__c}" var="qli">
        <apex:dataTable value="{!qli}" var="item">
           <apex:column value="{!qli.product2}"/>*/
            <apex:column value="{!qli.Quantity}"/>
        </apex:dataTable>
        </apex:pageBlockTable>
        </apex:pageBlock>    

      </apex:form>
</apex:page>

 

How I correct this error?

I have a dropdown on Visual Force page with the options look like the following:

 

January -- FY 2010

February -- FY 2010

March -- FY 2010

April -- FY 2010

......

......

 

On the visual force page, how should I parse the selected option to pass them to two hidden fields: hiddenMonth, hiddenYear so that hiddenMonth will have value of month and hiddenYear will have value of year?

 

Any help will be greatly appreciated.

I have a simple custom object with Contact and Account lookup.

 

When the contact is populated and the account is not, what is the most efficient trigger code to populate the account lookup from the contact?

 

Thanks!

I have 2 list views defined for Apex Classes. There's one named Unit Tests that filters based on the Apex class name (all my unit test classes have a particular string in their name) and one named All. When I go to Setup | Develop | Apex Classes, the Unit Tests list view is displayed. I change it to All, and it shows me all classes, but when I go to Setup | Develop | Apex Classes again, it goes back to showing me the Unit Tests list view again. How can I make All (which is first alphabetically) the default list view for Apex Classes?

  • August 22, 2010
  • Like
  • 0

Hi,

 

I have modified the code from the site : http://blog.jeffdouglas.com/2009/07/14/visualforce-page-with-pagination/comment-page-1/#comment-930


I have one issue that i cannot able to solve. It is not rerendering. When i remove the following piece of code from visualforce page, it works fine


-----------------------------------------------------------------------------
 <apex:pageBlockSection columns="1">



<apex:pageblockSectionItem >


<apex:outputText value="Account" />
<apex:inputField value="{!account.ParentID}" id="LookupAccount" required="true" />

</apex:pageblockSectionItem>

</apex:pageBlockSection>
----------------------------------------------------------------------------

Full Visual force code:

<apex:page controller="PagingController">
<apex:form >
<apex:pageBlock>

<apex:pageBlockSection columns="1">

<apex:pageblockSectionItem >

<apex:outputText value="Account" />
<apex:inputField value="{!account.ParentID}" id="LookupAccount" required="true" />

</apex:pageblockSectionItem>

</apex:pageBlockSection>

<apex:pageBlockButtons location="top">
</apex:pageBlockButtons>
<apex:pageMessages />

<apex:pageBlockSection title="Account Results - Page #{!pageNumber}" columns="1" id="pageblock">

<apex:pageBlockTable value="{!accounts}" var="c">
<apex:column value="{!c.Name}" headerValue="Name"/>
</apex:pageBlockTable>
</apex:pageBlockSection>

</apex:pageBlock>

<apex:panelGrid columns="4">
<apex:commandLink action="{!first}" rerender="pageblock">First</apex:commandlink>
<apex:commandLink action="{!previous}" rendered="{!hasPrevious}" rerender="pageblock">Previous</apex:commandlink>
<apex:commandLink action="{!next}" rendered="{!hasNext}" rerender="pageblock">Next</apex:commandlink>
<apex:commandLink action="{!last}" rerender="pageblock">Last</apex:commandlink>
</apex:panelGrid>

</apex:form>
</apex:page>

Controller Code:

public with sharing class PagingController {

public Account getAccount()
{
return [Select a.ParentID From Account a Limit 1];
}

// instantiate the StandardSetController from a query locator
public ApexPages.StandardSetController con {
get {
if(con == null) {
con = new ApexPages.StandardSetController(Database.getQueryLocator([Select Name FROM Account Order By Name limit 100]));
// sets the number of records in each page set
con.setPageSize(5);
}
return con;
}
set;
}

// returns a list of wrapper objects for the sObjects in the current page set
public List<Account> getAccounts() {
return (List<Account>)con.getRecords();
}

// indicates whether there are more records after the current page set.
public Boolean hasNext {
get {
return con.getHasNext();
}
set;
}

// indicates whether there are more records before the current page set.
public Boolean hasPrevious {
get {
return con.getHasPrevious();
}
set;
}

// returns the page number of the current page set
public Integer pageNumber {
get {
return con.getPageNumber();
}
set;
}

// returns the first page of records
public void first() {
con.first();
}

// returns the last page of records
public void last() {
con.last();
}

// returns the previous page of records
public void previous() {
con.previous();
}

// returns the next page of records
public void next() {
con.next();
}


}


Can anyone help me?

Hi,

 

    Pressing enter key on form with commandButton not working in IE, but it works fine in firefox. Its a search box and when I type something I want to hit enter to initiate the search. Any pointers...that I can try...

Can I write a controller for a Visualforce page that 'extends' the functionality of the standardController?

 

I have a custom object, and want to add some function to that supplied by the standard controller for the custom object.

 

At the moment I am using the standard controller to access the custom objects fields and the quick save method.

 

is there something like

 

public class CustomController extends StandardController {

 

 

syntax available?

 

What is best practice for extending the functionality of a standard controller?

Hey, quick question...

 

I am attempting to implement a filtering system where I render certain elements based on their type. I am trying to use a javascript method to control the rendering, but it is always returning false, does anyone know what the issue might be?

 

 

<apex:inputText value="{!def.myDef.Name}" rendered="getFilter()" />
 <script>
  function getFilter(){
   var myBool = true;
   return myBool;
  }
 </script>

 This is simply not rendering the element, which leads me to believe the javascript is not being evaluated, but I am not sure why that would be the case.

 

My requirement as follows...

 

 

 

1. There are 2 fields on Oppty - Stage and Disposition Reason. Disposition Reason is dependent on Stage. (already built)

2. The following action should happen whenever Stage is any of the values with the word "Closed", so closed won, closed lost etc.

3.  Say I choose Stage as Closed Won, and Disposition as Cyhicle.
4. On the Oppty Prod Line item related list i.e (Products), all products where Primary Quote = TRUE, the Stage and Disposition Reason should be updated with the values chosen on the Oppty. Please note ALL line items should be updated and the condition is Primary Quote field is checked. So, prodcut should also have Stage as Closed Won, and Disposition as Cycle.

Hint - there should be a apex trigger written on the Oppty Object and it should run on AFTER INSERT and AFTER UPDATE functions.

Thanks

 

Rekha

  • June 15, 2010
  • Like
  • 0

Hey all,

 

So right now I am having an issue with a popup opened by javascript not closing itself. I am executing the self.close() javascript on the "save" button in the window, but the window simply refreshes itself rather than closing. Does anyone know if visualforce is stopping the close() action, and if so, is there a known workaround to close the popup?

 

Thanks,

Derrek

How to hide or disable the Edit Button depending upon some condition say for example if particular check box is checked then edit button should no longer be visible.

 

Is there any way to do a Count() query without hitting governor limits and without using batch apex when the number of records to be counted is greater than the governor limit?

 

 

Integer affected = [SELECT COUNT() FROM Account WHERE CustomField__c = 'TestValue'];

 This code runs in a trigger so will fail if there are more than 100 records in the count (assuming a batch size of 1).

 

 

Thanks

 

Dave

Hi ,

 

   I have a requirement to show the text appearing in formula field in red colour . Is it achievable? The exact requirement is to show a auto Number type field in red if the Target Date field value is behind today's date. And the styling should be seen not only in detail page but also in search results. I am wondering if this could be achieved using formula field.

  • March 17, 2011
  • Like
  • 0
Hi , I have a requirement to show the text appearing in formula field in red color . Is it achievable? The exact requirement is to show a auto Number type field in red if the Target Date field value is behind today's date. And the color should be seen not only in detail page but also in search results. I am wondering if this could be achieved using formula field.
  • March 17, 2011
  • Like
  • 0

Hi everyone,

 

        If there are multiple field updates configured in an workflow actions, does the individual field update fire according to the list or in random order?

 

      Ideally I assume it to be in the order of the list displayed in workflow actions page, but has anyone witnessed it?

 

 

Thanks

  • February 10, 2011
  • Like
  • 0

Hi,

 

      I am trying to change the Partner Portal Administrator. When I select a user  I am getting "This user has insufficient permissions to be a portal administrator" error.

I have checked the help documentation and it tells that "a User with "Manage Partners" permmsion and acces to folder with portal header content is allowed to be portal Admin".

 

The selected user is having both the permissions. But still it is throwing the same error. If some one knows what are the permissions required to be a portal administrator, please hep me out listing them.

 

Thanks in advance.

  • July 07, 2010
  • Like
  • 0

Hi,

 

       Is it possible to hide the todays date link present adjacent to any Date field in Standard edit layout?

 

  If not possible in Standard edit layout can we remove it in Visualforce page when we use <apex:inputField/> ?

 

Thanks in advance.

  • June 24, 2010
  • Like
  • 0

Could NOT install force.com IDE in eclipse (Kepler). Also http://www.adnsandbox.com/tools/ide/install/ is not working. Can you please give right location path?

Hi everyone,

 

        If there are multiple field updates configured in an workflow actions, does the individual field update fire according to the list or in random order?

 

      Ideally I assume it to be in the order of the list displayed in workflow actions page, but has anyone witnessed it?

 

 

Thanks

  • February 10, 2011
  • Like
  • 0

Hi,

       I am new to force.com. I have integrated force.com IDE with Eclipse to create my application.

I found a file called salesforce.schema which contains list of default objects. Also i have created custom object, that also be listed.

At this point, i have a doubt that is salesforce.schema is a XSD or DBMS?

 

waiting for your valuable suggestions

 

 

Thanks

paul

 

Hi,

 

I have a custom button which has "Onclick" execute java script.

I am looking at the status of a field and then redirecting the user appropriately.

But i am encountering an error, which i am unable to figure out.

 

if({!Opportunity.StageName}=='Prospecting')

{

 alert('You cannot perform action');

}

 

else

{

 

&serverUrl={!API.Partner_Server_URL_80}
&id={!Opportunity.Id}
&reportid=00O600000023k2f?pv0={!Opportunity.Id}
&reportid=00O600000023k2k?pv0={!Contact.Id}
&reportid=00O600000023k3O?pv0={!Opportunity.Id}
&reportid=00O600000023k3T?pv0={!Opportunity.Id}
&reportid=00O600000023qu9?pv0={!Opportunity.Id}
&ESVisible=1
&ESAgreementName={!Opportunity.Name}
&ESSignatureType=2
&TemplateId={!IF ( Opportunity.RecordTypeId = "012600000005Eso", IF ( ISPICKVAL ( Opportunity.Payment_Methond__c , "Credit Card" ) , "a0G60000004z7sv" , "a0G60000004z7t0" ) , IF ( ISPICKVAL ( Opportunity.Payment_Methond__c , "Credit Card" ) , "a0G60000003Zej9" , "a0G60000003ZejE" ) )}
&ds4={!IF( $Profile.Name = "System Administrator", "0", "1")}
&ds7={!IF( $Profile.Name = "System Administrator", "0", "4")}

window.location.href="https://www.appextremes.com/apps/Conga/PointMerge.aspx?sessionId={!API.Session_ID}&serverUrl={!API.Partner_Server_URL_80}&id={!Opportunity.Id}&reportid=00O600000023k2f?pv0={!Opportunity.Id}&reportid=00O600000023k2k?pv0={!Contact.Id}&reportid=00O600000023k3O?pv0={!Opportunity.Id}&reportid=00O600000023k3T?pv0={!Opportunity.Id}&reportid=00O600000023qu9?pv0={!Opportunity.Id}&ESVisible=1&ESAgreementName={!Opportunity.Name}&ESSignatureType=2&TemplateId={!IF ( Opportunity.RecordTypeId = "012600000005Eso", IF ( ISPICKVAL ( Opportunity.Payment_Methond__c , "Credit Card" ) , "a0G60000004z7sv" , "a0G60000004z7t0" ) , IF ( ISPICKVAL ( Opportunity.Payment_Methond__c , "Credit Card" ) , "a0G60000003Zej9" , "a0G60000003ZejE" ) )}&ds4={!IF( $Profile.Name = "System Administrator", "0", "1")}&ds7={!IF( $Profile.Name = "System Administrator", "0", "4")}";

 

}

 

 

The error is:

 

 

A problem with the OnClick JavaScript for this button or link was encountered:

missing ) after condition.

 

 

It seems to me correct. i do not know what i am missing. can anyone help me here?

 

Thanks,

Sales4ce

 

.

Hey all,

 

I'm trying to work on a visualforce change that will rerender a pageblock with associated contacts whenever an account is modified in the lookup field. 

In other words, when an account is changed, the appropriate contacts should be displayed (to work with them later). 

 

I have the inputField displaying the Account lookup, but it's not changing on a change.  I tried using onchange... didn't work.  I just need to reference the account lookup within my standard controller and work with a rerendered.  Can anyone help out?

 

Code:

<Apex:inputField value="{!Call_Attendee__c.Attendee_Account__c}" onchange="Do Something"/>

 

 

I have a use case where, when a lead is converted, I need to convert all other leads from the same company.  I have a custom object (Lead Company) that the leads are linked to via Lookup.  The Lead Company has a flag Converted__c which is set when a lead is converted, from a lead <before update> trigger and the Lead Company record also then records the Account Id of the converted lead.  There is then a trigger on the Lead Company which detects that the flag has been set and then converts all other leads on that account to contacts.  Or at least, that is what is intended, but I get an error saying that it is recursive, as the conversion process then calls my lead trigger again.

 

So, I understand where the error is coming from, but what I can't work out is how to achieve this objective without the recursion.

 

Can anyone help me with a better solution?

 

Thanks

  • November 08, 2010
  • Like
  • 0

Hi All,

 

I have a visualforce page to search all accounts, now i simply wants to display all the searched records page wise i.e. having 20 records per page.

 

For ex. After searching all accounts, i have 500 records displayed. Now, i want to display only 20 records per page and enable the user to move to the next 20 records till last record.

 

Please let me know how can i do that.

 

Thanks

I'm trying to add a visualforce page to a detail layout. I've started off with a simple blank page with 'Hello World' and dragged it onto the detail page layout in it's own section. I've saved it all successfully.

 

The section appears and the page is set to it's appropriate width and height. But the page is blank. Why is this?

 

The page is set to it's standardController correctly.

We have three people at my firm who work leads.  One of them works all leads created between 7:00pm and 9:59am as well as everything from Saturday and Sunday.

 

Is there a way to assign leads to a queue or users based upon the time and day of week?

 

Additionally, is there a way to display created time in addition to created date in lead view?

 

Displaying the time in a lead view is something that has been requested and could create a workaround for assigning leads based on day of week and time.

 

We're on Professional Edition.

 

Thanks in advance for the help!

hello all

 

i have 5 pick list in the Acct that i need copy to the case but they need to update the same picklist in the case for example

 

property info (in account objecct) is a picklist with the value A, B ,C

 

and i have

 

Property info (in the case) is a picklist with value A, B, C

 

both fields have exactly the same values im pretty sure there is a better way to update the fields other than create a rule for each option i have in the picklist to update in the case 

 

any ideas

Hello All,

 

Can somebody help me pleaseeeeeeeeeee............???

 

Problem -

if someone enters Number__c then Company__c should become as required..... But the problem here is Company__c is a Picklist value.

 

Validation Rule -

ISCHANGED( Number__c ) && (isblank(Company__c))

 

 

Error: Field Company__c is a picklist field. Picklist fields are only supported in certain functions.

 

Thanks,

Dan 

Is it possible to make the sum of all the non-empty lookup fields (contact 1, 2 & 3) and automatically show this value in another field (# persons)

 

 

Thanks in advance!

 

 

  • September 27, 2010
  • Like
  • 0

Hi All,

 

I am trying to write a test method for controller extension Apex class.I want to test the "save" functionality of an Apex class.Follwing is the code.

public class jobcntroller {

 

    public Job_Details__c job{ get; set; }

     public String CompanyName;

     public void setCompanyName(String CompanyName)

    {

        this.CompanyName = CompanyName;

    }

    ApexPages.StandardController controller;   

    String s;

 

 

 

 

    public jobcontroller(ApexPages.StandardController stdController) {

        job = new Job_Details__c ();    

        controller = stdController;

 

    }   

 

   public PageReference mysave() {

     Schema.DescribeSObjectResult result = ob_Details__c.sObjectType.getDescribe();    

     controller.save();

 

 

    PageReference pageRef = New PageReference('/' + result.getKeyPrefix() + '/e');

 

     pageRef.setRedirect(true);

     return pageRef;

 

     }

      static testMethod void testMyController() {

      //Use the PageReference Apex class to instantiate a page

        PageReference pageRef = Page.jobpage;

        //In this case, the Visualforce page named 'jobpage' is the starting point of this test method.

        Test.setCurrentPage(pageRef);

        //Instantiate and construct the controller class. 

       ApexPages.StandardController thecontroller;       

        jobcontroller controller = new jobcontroller(thecontroller);

        controller.setCompanyName('abc');

        //The .getURL will return the page url the Save() method returns.

        String nextPage = controller.mysave().getUrl();

        //Check that the save() method returns the proper URL.

        System.assertEquals('/apex/failure?error=noParam', nextPage);

 

     }

 

     }

 

When I do the runtest, I am getting the following message:

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

 

stack trace:

Class.jobcntroller.mysave: line 25, column 25

Class.jobcntroller.testMyController: line 44, column 27 External entry point

 

I am not able to correct the nullpointerexception. Any help on how to resolve this is greatly appreciated.

 

  • September 26, 2010
  • Like
  • 0

I am lost here.  I have created the trigger in my sandbox and am trying to move it over to production.  The only problem I am having is in the testing.  I am hitting 58% and have no idea why.  The following is what I am getting. Any help would be very much appreciated.....(The only error message that I receive is that it failed)

 

LeadAssignmentTrigger (Code Covered: 58%)

 

 line  executions source
 1   trigger LeadAssignmentTrigger on Lead (before insert)
 2   {
 3 1   List<String> zips = new List<String>();

   
 5   
 6 1   for (Lead lead : Trigger.new)
 7    {
 8 6   if (lead.PostalCode != NULL && lead.Assign_Using_Assignment_Rules__c == true)
 9    {
 10 3   zips.add(lead.PostalCode);
 11    }
 12    }
 13   
 14   
 15 1   Map<String, Zip_Code__c> leadsToUpdate = new Map<String, Zip_Code__c>();
 16   
 17 1   for(Zip_Code__c zip_code:[select Name, Owner.Id from Zip_Code__c where Name in :zips])
 18    {
 19 0   if(zip_code.Name != null) leadsToUpdate.put(zip_code.Name, zip_code);
 20    }
 21   
 22   
 23   
 24 1   if (leadsToUpdate.size() > 0)
 25    {
 26   
 27 0   for (Lead lead : Trigger.new)
 28    {
 29   
 30 0   if (leadsToUpdate.containsKey(lead.PostalCode))
 31    {
 32   
 33 0   lead.OwnerId = leadsToUpdate.get(lead.PostalCode).OwnerId;
 34    }
 35    }
 36   
 37    }
 38 

  }

  • September 24, 2010
  • Like
  • 0
Im using a custom button in opportunity tab to get INvoice for a particular Opportunity,In that case the Invoice PAge should Invoke only wen the Opportunity Created date should be less than 21 days from now,so if difference between is greater 21 days it should not invoke Here is my COde in Custom button link display type is detail page button if({!Opportunity.CloseDate} - {!Opportunity.CreatedDate} > 21){ window.parent.location.href = "/apex/Invoice_1?id="+'{!Opportunity.Id}'; }else{ //do nothing } Thanks in Advance Sathish

Hi

 

I am getting an error.I know i have to use list for opportunity but the record is not getting saved.Please help me out

 

The related trigger is

 

 

trigger OpportunityCreditCheck on Credit_Check__c (before insert, before update) {

 

 

  for(Credit_Check__c CCheck : Trigger.new){
            
    if(CCheck.RecordtypeId == '012200000009PMEAA2'){
          Opportunity oppr = [Select Account.Business_Type__c,Account.Name,Account.Registered_Charity_Number__c,Product_Name__c, New_Supplier__c, AccountId From Opportunity where Id =:CCheck.Opportunity__c];
     
      if(Oppr.Account.Business_Type__c == 'Limited Company' || Oppr.Account.Business_Type__c == 'Plc' || Oppr.Account.Business_Type__c == 'Charity'){
     
         if(oppr.New_Supplier__c == 'Eon' && oppr.Product_Name__c != 'Bespoke Price'){ 
         
        
         
             if(CCheck.Limited_Company_Account__c == null ){
            CCheck.Limited_Company_Account__c.addError('Please Enter the Account Name');
            }
            if(CCheck.Registered_Address__c == null){
            CCheck.Registered_Address__c.addError('Please Enter the Full Registered Address');
            }
            
            if(CCheck.Date_of_Incorporation__c == null){
            CCheck.Date_of_Incorporation__c.addError('Please Enter the Date of Incorporation');
            }
            
             if(CCheck.Company_Registered_Number__c == null){
            CCheck.Company_Registered_Number__c.addError('Please Enter the Full Company Registered Number');
            }
             
            if(CCheck.Phone_Number__c == null){
            CCheck.Phone_Number__c.addError('Please Enter the Full Phone Number');
            }
            if(CCheck.Billing_Address__c == null){
            CCheck.Billing_Address__c.addError('Please Enter the Full Billing Address');
            }
            }
            
      }
       if(CCheck.Date_of_Incorporation__c < system.Today()-730){
       
           if(CCheck.Full_Company_Name__c == null){
           CCheck.Full_Company_Name__c.addError('Please Enter the Full company name');
           }
             
            if(CCheck.Registered_Address__c == null){
            CCheck.Registered_Address__c.addError('Please Enter the Full Registered Address');
            }
             if(CCheck.Company_Registered_Number__c == null){
            CCheck.Company_Registered_Number__c.addError('Please Enter the Company Registered Number');
            }
             
            if(CCheck.Phone_Number__c == null){
            CCheck.Phone_Number__c.addError('Please Enter the Full Phone Number');
            }
            if(CCheck.Billing_Address__c == null){
            CCheck.Billing_Address__c.addError('Please Enter the Full Billing Address');
            }
            if(CCheck.Director_First_Name__c == null){
            CCheck.Director_First_Name__c.addError('Please Enter the Director First Name');
            }
            if(CCheck.Director_Last_Name__c == null){
            CCheck.Director_Last_Name__c.addError('Please Enter Director Last Name');
            }
             if(CCheck.Directors_DOB__c == null){
            CCheck.Directors_DOB__c.addError('Please Enter Director Date of Birth');
            }
            
            if(CCheck.Building_Name__c == null && CCheck.Building_Number__c == null){
            CCheck.Building_Name__c.addError('Please Enter Building number or Building name');
             CCheck.Building_Number__c.addError('Please Enter Building number or Building name');
            
            }
           
            if(CCheck.Building_PostCode__c == null){
            CCheck.Building_PostCode__c.addError('Please Enter Building Post Code');
            }
            if(CCheck.CC_Consent__c == null){
            CCheck.CC_Consent__c.addError('Please Enter the Full CC Consent');
            }
            if(CCheck.Building_Town__c == null){
            CCheck.Building_Town__c.addError('Please Enter the Town'); 
            }
       }
       
       /*if date of incorporation is greater than 2 years, new supplier is equal to Eon and product name is not equal to bespoke,
        than contact firstname,contact last name,billing building number,billing building name ,billing address,billing town,
        billing post code and date field must be filled.*/
        
          if(CCheck.Date_of_Incorporation__c > system.Today() + 730 && oppr.New_Supplier__c == 'Eon' && oppr.Product_Name__c != 'Bespoke Price'){
           
           if(CCheck.Director_First_Name__c == null){
           CCheck.Director_First_Name__c.addError('Please enter contact First name');
           }
           if(CCheck.Director_Last_Name__c == null){
           CCheck.Director_Last_Name__c.addError('Please enter contact Last name');
           }
            if(CCheck.Building_Name__c == null && CCheck.Building_Number__c == null){
            CCheck.Building_Name__c.addError('Please Enter Building number or Building name');
             CCheck.Building_Number__c.addError('Please Enter Building number or Building name');
            
            }
           if(CCheck.Building_Street_Address__c== null){
           CCheck.Building_Street_Address__c.addError('Please enter Billing Street Address');
           }
           if(CCheck.Building_Town__c== null){
           CCheck.Building_Town__c.addError('Please enter Billing Town');
           }
           if(CCheck.Building_PostCode__c== null){
           CCheck.Building_PostCode__c.addError('Please enter Billing Post Code');
           }
           if(CCheck.Directors_DOB__c== null){
           CCheck.Directors_DOB__c.addError('Please enter Date of Birth');
           }
          }
        }
         if(CCheck.RecordtypeId == '012200000009PMJAA2'){
            
            Opportunity oppr = [Select Account.Business_Type__c,  AccountId From Opportunity where Id =:CCheck.Opportunity__c];
           
          if(Oppr.Account.Business_Type__c == 'Sole Trader' || Oppr.Account.Business_Type__c == 'Trusteeships' ||  Oppr.Account.Business_Type__c == 'Partnership' ){
            
            if(CCheck.Business_Name__c == null){
             CCheck.Business_Name__c.addError('Please enter business name');
            }
            if(CCheck.Bussiness_owner_name__c == null){
                CCheck.Bussiness_owner_name__c.addError('Please enter business owner name');
            }
           if(CCheck.Current_Address_Home_Address__c == null){
            CCheck.Current_Address_Home_Address__c.addError('Please enter current address');
           }
           if(CCheck.Date_of_Occupancy_of_Home__c == null){
            CCheck.Date_of_Occupancy_of_Home__c.addError('Please enter date of occupancy at Home');
           }
           if(CCheck.Previous_Address__c == null){
            CCheck.Previous_Address__c.addError('Please enter previous address if it less than 2 years Or mention SAME AS ABOVE');
           }
           if(CCheck.Bussiness_Owner_DOB__c == null){
           CCheck.Bussiness_Owner_DOB__c.addError('Please enter Bussiness owner date of birth');  
           }
           
          }
        }
    }   
    }

Thanks

 

Nasir

  • September 22, 2010
  • Like
  • 0
I have created a Custom Button in Opportunity tab called Invoice,and wen Click the custom Button It has to generate a Invoice for a particular Opportunity ID in a apex Page, Using Condition Only when Opportunity Name Equal to 'Testing' if not it has to be null.I have tried Several times using IF Control Statement,but im getting a error of URL NO LONGER EXIST, Here is my CUstom Button Code {!IF( Opportunity.Name = 'Testing' , '/apex/Invoice_1?id='&Opportunity.Id , null)} but its working fine wen the code is like below /apex/Invoice_1?id={!Opportunity.Id} Kindly Suggest me a Example for how to use IF statemnts in Calling URL Thanks in advance Sathish

Hey all,

 

So right now I am having an issue with a popup opened by javascript not closing itself. I am executing the self.close() javascript on the "save" button in the window, but the window simply refreshes itself rather than closing. Does anyone know if visualforce is stopping the close() action, and if so, is there a known workaround to close the popup?

 

Thanks,

Derrek