• trsmith
  • NEWBIE
  • 75 Points
  • Member since 2008
  • CTO
  • ClosedWon


  • Chatter
    Feed
  • 2
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 23
    Replies
Hey guys, I am attempting to test my extension. It is getting 90% coverage and yet it is still failing funnily enough (I thought anything over 75% was a pass). I know why it is failing, I am just not sure how to rectify it.

Basically, I have a VF page which is for a survey object that I am creating. The goal is to automatically send out a URL after a client has completed certain milestones. The URL will be part of an email template that will send a link to the site.com hosted version of the VF page with the clients account ID in the URL.. The client will complete the survey and upon clicking save, the survey will be inserted into the clients object by the extension which will draw the account ID from the URL....It all works fine in sandbox, testing just fails as I do not know how to test for AccountID when it gets it from the URL. These are my three codes:

VF page:

<apex:page standardController="Destiny_Survey__c" extensions="extDestinySurvey" >

<apex:includeScript value="{!URLFOR($Resource.jQuery, '/js/jquery-1.9.1.js')}"/>
<apex:includeScript value="{!URLFOR($Resource.jQuery, '/js/jquery-ui-1.10.3.custom.min.js')}"/>
<apex:stylesheet value="{!URLFOR($Resource.jQuery, '/css/ui-lightness/jquery-ui-1.10.3.custom.css')}"/>

<apex:form id="theForm">
<apex:pageBlock id="theBlock">
<apex:pageBlockSection id="theSection1" title="Thank you for completing our Destiny Survey {!Destiny_Survey__c.Account__c}" />
<apex:pageBlockSection id="theSection" columns="1" >
<apex:inputField value="{!Destiny_Survey__c.Which_Product_or_Service__c}" label="Which Destiny Product or Service have you just completed?" id="value3"/>
    <div id="slider" style="length:50"/>
    <apex:inputField value="{!Destiny_Survey__c.How_likely_are_you_to_refer_Destiny__c}" label="How likely is it that you would recommend us to a friend or colleague?" id="value"/>
     <apex:inputField value="{!Destiny_Survey__c.Explain_why_you_gave_your_rating__c}" label="Explain why you gave your rating." id="value2"/>
   
   
</apex:pageBlockSection>
</apex:pageBlock>

<apex:commandButton value="Save" action="{!saveDestinySurvey}"/>
</apex:form>


<script>
    function getCleanName(theName)
    {
        return '#' + theName.replace(/:/gi,"\\:");
    }
    var valueField = getCleanName( '{!$Component.theForm.theBlock.theSection.value}' );

    $j = jQuery.noConflict();
    $j( "#slider" ).slider( {enable: true, min: 0, max: 10, orientation: "horizontal", value: 0} );
    $j( "#slider" ).on( "slidechange",
        function( event, ui )
        {
            var value = $j( "#slider" ).slider( "option", "value" );
            $j( valueField ).val( value );
        }
    );
</script>

</apex:page>




This is my Extension:

public class extDestinySurvey
{
    public Destiny_Survey__c Dess {get;set;}

    private Id AccountId
    {
        get
        {
            if ( AccountId == null )
            {
                String acctParam = ApexPages.currentPage().getParameters().get( 'acct' );
                try
                {
                    if ( !String.isBlank( acctParam ) ) AccountId = Id.valueOf( acctParam );
                }
                catch ( Exception e ) {}
            }
            return AccountId;
        }
        private set;
    }

    public extDestinySurvey(ApexPages.StandardController controller)
    {
        Dess = (Destiny_Survey__c)controller.getRecord();
    }

    public PageReference saveDestinySurvey()
    {
        Dess.Account__c = AccountId;
        upsert Dess;

        // Send the user to the detail page for the new account.
        return new PageReference('/apex/DestinyAccount?id=' + AccountId + '&Sfdc.override=1');
    }
}



This is my Test that fails at 90%:

@isTest
private class TestExtDestinySurvey {

static testMethod void TestExtDestinySurvey(){
        //Testing Survey extension

// create a test account that will be use to reference the Destiny Survey Record




Account acc = new Account(Name = 'Test Account');
insert acc;

//Now lets create Fact Finder record that will be reference for the Standard Account
        Destiny_Survey__c DessTest = new Destiny_Survey__c(Account__c = acc.id, Explain_why_you_gave_your_rating__c = 'Because', How_likely_are_you_to_refer_Destiny__c = 8);
      
  
      
        //call the apepages stad controller
        Apexpages.Standardcontroller stdDess = new Apexpages.Standardcontroller(DessTest);

//now call the class and reference the standardcontroller in the class.
        extDestinySurvey ext = new extDestinySurvey(stdDess);
      
     
//call the pageReference in the class.
        ext.saveDestinySurvey();
    }
  
    }

I have a visualforce email template that we use to send out quotes. It attaches a PDF of the quote to the email template in the format "Quote-[quotenumber].pdf" where quotenumer is an auto-generated number in a custom field. In the visualforce template, the filename looks like this:

 

<messaging:attachment renderas="pdf" filename="Quote-{!relatedTo.Opp_Quote_Num__c}"> 

 

Prior to the upgrade to '09, this worked just fine. The pdf would attach with a name like "Quote-09775.pdf". But now the file gets attached as just "Quote-.pdf" without any changes having been made to the template and I can't seem to figure out a fix. Is this a bug? Has anyone else seen this?

 

Thanks in advance for any help! 

Message Edited by trsmith on 02-22-2009 07:42 AM
Message Edited by trsmith on 02-22-2009 07:44 AM
Message Edited by trsmith on 02-22-2009 08:06 AM
Message Edited by trsmith on 02-22-2009 08:07 AM
I have created a Visualforce email template that automatically attaches a PDF rendering of a quote from the opportunity object. It works fine when manually selecting the template from the email author page.

However, if I create a custom button on the opportunity page to take me to the email author page with the whoid, whatid, and template id defined in the URL, the email subject and body show up just fine but there is no attachment. Anyone else run into this? Any ideas on a fix?

Message Edited by trsmith on 11-17-2008 01:08 PM

Message Edited by trsmith on 11-17-2008 01:10 PM
I have a page which on load calls an action and also runs the javascript perfectly fine. There are two div's, one with google maps and other with apex table.

The same action is called with command button but if I use reRender, the javascript dosent fire and the div with map is not updated but with apex table gets updated.

Then I realized my Javascript is not fired which creates the map. Any help ???
While executing the APEX REST sample code available from the following link http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_rest_code_sample_basic.htm I got struck with the 3rd point "Create a file called account.txt to contain the data for the account you will create in the next step." The question is that where should this "account.txt" file be located and how is it supposed to be passed in the curl command line curl -H "Authorization: Bearer sessionId" -H "Content-Type: application/json" -d @account.txt "https://instance.salesforce.com/services/apexrest/Account/"
kumaresan.m
I want to pass some parameters in url to another page with hidden way. so i tried using getheaders() instead of getparameters(). but this was not works. Please help me understand, how to do? i am pasting my code below:

controller of Page 1:
public PageReference wish() {
    pagereference s=new pagereference('/apex/Aboutus');
    s.getHeaders().put('id','1234');
    return s;
}


Construtor of Page 2:

Public aboutus(){
string ss=ApexPages.currentPage().getheaders().get('id');
system.debug('mylog'+ss);
}

in debug log i am getting null during this action..
I'd like to create a trigger that automatically assign a value to a lookup field.
I've tried to emulate what I've read on these 3 posts (but without success)

https://developer.salesforce.com/forums?id=906F000000094NcIAI; How to Give Default value to a LookUp field in salesforce; Trigger based on Record Type + Default Value + Lookupfield;

Here is the situation. I have a Product_Sale__c object. Sale_Account_c is a lookup field in that object. That field is looking up for the Name (the Id?) of an account on Account_c. One of the account on Account__c is 'Sales_Revenue'. I'd like that account to be the default one on Sale_Account__c.

Here is what I wrote:

trigger ProductSale_Default_SaleAccount on Product_Sale__c (before insert, before update) {
             Account__c defaultSaleAcc = [SELECT Name FROM Product_Sale__c WHERE Name='Sales Revenue'];
            for (Product_Sale__c productsale : trigger.new) {
                        productsale.Sale_Account__c = defaultSaleAcc.Name;
            }
}

And I get this error: Compile Error: Illegal assignment from LIST to SOBJECT:Account__c at line 3 column 9

Any advices?
Please help me finding the Solution.

On Case update I need to send an email to Internal and Partner User both. Email content is same for both type of user.
Only difference is between an url present in that mail content. 

Is it possible to accomplish with a single workflow and single email template?


Hey guys, I am attempting to test my extension. It is getting 90% coverage and yet it is still failing funnily enough (I thought anything over 75% was a pass). I know why it is failing, I am just not sure how to rectify it.

Basically, I have a VF page which is for a survey object that I am creating. The goal is to automatically send out a URL after a client has completed certain milestones. The URL will be part of an email template that will send a link to the site.com hosted version of the VF page with the clients account ID in the URL.. The client will complete the survey and upon clicking save, the survey will be inserted into the clients object by the extension which will draw the account ID from the URL....It all works fine in sandbox, testing just fails as I do not know how to test for AccountID when it gets it from the URL. These are my three codes:

VF page:

<apex:page standardController="Destiny_Survey__c" extensions="extDestinySurvey" >

<apex:includeScript value="{!URLFOR($Resource.jQuery, '/js/jquery-1.9.1.js')}"/>
<apex:includeScript value="{!URLFOR($Resource.jQuery, '/js/jquery-ui-1.10.3.custom.min.js')}"/>
<apex:stylesheet value="{!URLFOR($Resource.jQuery, '/css/ui-lightness/jquery-ui-1.10.3.custom.css')}"/>

<apex:form id="theForm">
<apex:pageBlock id="theBlock">
<apex:pageBlockSection id="theSection1" title="Thank you for completing our Destiny Survey {!Destiny_Survey__c.Account__c}" />
<apex:pageBlockSection id="theSection" columns="1" >
<apex:inputField value="{!Destiny_Survey__c.Which_Product_or_Service__c}" label="Which Destiny Product or Service have you just completed?" id="value3"/>
    <div id="slider" style="length:50"/>
    <apex:inputField value="{!Destiny_Survey__c.How_likely_are_you_to_refer_Destiny__c}" label="How likely is it that you would recommend us to a friend or colleague?" id="value"/>
     <apex:inputField value="{!Destiny_Survey__c.Explain_why_you_gave_your_rating__c}" label="Explain why you gave your rating." id="value2"/>
   
   
</apex:pageBlockSection>
</apex:pageBlock>

<apex:commandButton value="Save" action="{!saveDestinySurvey}"/>
</apex:form>


<script>
    function getCleanName(theName)
    {
        return '#' + theName.replace(/:/gi,"\\:");
    }
    var valueField = getCleanName( '{!$Component.theForm.theBlock.theSection.value}' );

    $j = jQuery.noConflict();
    $j( "#slider" ).slider( {enable: true, min: 0, max: 10, orientation: "horizontal", value: 0} );
    $j( "#slider" ).on( "slidechange",
        function( event, ui )
        {
            var value = $j( "#slider" ).slider( "option", "value" );
            $j( valueField ).val( value );
        }
    );
</script>

</apex:page>




This is my Extension:

public class extDestinySurvey
{
    public Destiny_Survey__c Dess {get;set;}

    private Id AccountId
    {
        get
        {
            if ( AccountId == null )
            {
                String acctParam = ApexPages.currentPage().getParameters().get( 'acct' );
                try
                {
                    if ( !String.isBlank( acctParam ) ) AccountId = Id.valueOf( acctParam );
                }
                catch ( Exception e ) {}
            }
            return AccountId;
        }
        private set;
    }

    public extDestinySurvey(ApexPages.StandardController controller)
    {
        Dess = (Destiny_Survey__c)controller.getRecord();
    }

    public PageReference saveDestinySurvey()
    {
        Dess.Account__c = AccountId;
        upsert Dess;

        // Send the user to the detail page for the new account.
        return new PageReference('/apex/DestinyAccount?id=' + AccountId + '&Sfdc.override=1');
    }
}



This is my Test that fails at 90%:

@isTest
private class TestExtDestinySurvey {

static testMethod void TestExtDestinySurvey(){
        //Testing Survey extension

// create a test account that will be use to reference the Destiny Survey Record




Account acc = new Account(Name = 'Test Account');
insert acc;

//Now lets create Fact Finder record that will be reference for the Standard Account
        Destiny_Survey__c DessTest = new Destiny_Survey__c(Account__c = acc.id, Explain_why_you_gave_your_rating__c = 'Because', How_likely_are_you_to_refer_Destiny__c = 8);
      
  
      
        //call the apepages stad controller
        Apexpages.Standardcontroller stdDess = new Apexpages.Standardcontroller(DessTest);

//now call the class and reference the standardcontroller in the class.
        extDestinySurvey ext = new extDestinySurvey(stdDess);
      
     
//call the pageReference in the class.
        ext.saveDestinySurvey();
    }
  
    }
I have created a custom link that sits on the home page.  It's a java script link that kicks off a batch processing job.  What I'd like to do is put in a confirmation dialog to the give the user a chance to back out of running the process.  I can't seem to get the confirm call to work . Here is the code:

{!REQUIRESCRIPT("/soap/ajax/14.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/14.0/apex.js")}
{!REQUIRESCRIPT('//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js')}
{!REQUIRESCRIPT('//ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js')}
if(Confirm('You are about to update the Opportunities via the batch process. You should make sure no one is modifying Opportunities or Opportunity Splits while this process is running. You can monitor the process under setup/monitoring/apexJobs. Do you want to continue?')sforce.apex.execute("clsOpportunitySplitManageBchbl","processAllManual",{}));


  • December 26, 2013
  • Like
  • 0
I have a Controller with a remote action.

I would like to move that remote action to a nested apex class.

Controller1.controller2.remoteAction

Currently, I have the remote action in Controller1:
MemberProfileController.saveMPUPhoto('{!memberProfileUpdateController.account.Id}', function(result, event)

but I want to move it to the nested controller:
MemberProfileController.nestedContrller.saveMPUPhoto('{!memberProfileUpdateController.account.Id}', function(result, event)



How can I access the method, as a remote action, inside the nested class?
This does not work:
MemberProfileController.nestedController.saveMPUPhoto('{!memberProfileUpdateController.account.Id}', function(result, event)

nor does trying to get an instance of it in javascript.

Can multiple profiles be used on a Customer Portal, or can it only run under one profile?

 

I have a a portal setup with "Profile A" setup as the Default New User Profile;  I then have "Profile A" and "Profile B" in the Assigned Profile Lists, but if I change User Z's profile from Profile A to Profile B, I get insufficient priviliges in the portal.

 

 

Hi,

 

I am getting the following error and am struggling to find a fix.

 

"This page has changed since you started your edit. Refresh your page and try again."

 

The code has been running fine on developer accounts on na6 and na7 but is now failing on cs2!  Turning on logging doesnt pick up anything.  I don't understand why it works fine on one instance but not the other... dont think there is anything in the config that is much different.  Refreshing does not help.

 

I think the error may happen during a redirect but I will have to go through the code  - just wondering if anyone has seen this one before?

 

Any thoughts?

 

Thanks

Graham

Hello,

 

I'm getting an error today when trying to save APEX changes in Eclipse:  

 

"Save error: Unable to perform save on all files: PermGen space".

 

Is this a problem in my workspace, or in the SF Org I am developing in?

 

Thank you

I have a non-sobject field called "InvoiceDates" in my controller extension. On the VF page there is both an InputTextarea and an outputtext for the same field. The idea is the inputtextarea is pre-populated, but editable by the user. When the user updates that field and clicks a refresh button, they can see a "preview" of the document that will be created.

 

So far things work great for the inputtext area. I placed \n in the string which provides my line breaks. However when I go to output the value it shows up on a single line.

 

Part of method defining string

string vDate = string.valueof(StartDate.Month() +'/'+ StartDate.Day()+'/'+ StartDate.Year()); String Term = 'Term ' + string.valueof(i+2) + ': '; InvoiceDates = InvoiceDates + Term + Vdate + '\n';

VF Page area

 

(this works)

<apex:inputtextarea value="{!InvoiceDates}" id="InvoiceDates" style="width:300px;height:150px"/>

(Output not displaying with line breaks) <apex:outputtext value="{!InvoiceDates}" /> (Also tried) {!InvoiceDates}

 

the component references says outputtext "escape the rendered text if it contains sensitive HTML and XML characters" I'm assuming that using outputtext would "strip" my \n, so I tried just placing the string without an outputtext - but get the same data string line.

 

The only way I have been able to work around this is to create a list<string> instead of a concatenated String. This works on the display, but doesn't work for the user Inputtextarea well. Any suggestions on how I can get my output to include the \n ?

I have a visualforce email template that we use to send out quotes. It attaches a PDF of the quote to the email template in the format "Quote-[quotenumber].pdf" where quotenumer is an auto-generated number in a custom field. In the visualforce template, the filename looks like this:

 

<messaging:attachment renderas="pdf" filename="Quote-{!relatedTo.Opp_Quote_Num__c}"> 

 

Prior to the upgrade to '09, this worked just fine. The pdf would attach with a name like "Quote-09775.pdf". But now the file gets attached as just "Quote-.pdf" without any changes having been made to the template and I can't seem to figure out a fix. Is this a bug? Has anyone else seen this?

 

Thanks in advance for any help! 

Message Edited by trsmith on 02-22-2009 07:42 AM
Message Edited by trsmith on 02-22-2009 07:44 AM
Message Edited by trsmith on 02-22-2009 08:06 AM
Message Edited by trsmith on 02-22-2009 08:07 AM