• SFDC-PDX
  • NEWBIE
  • 10 Points
  • Member since 2010

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 4
    Replies
I am an experienced Administrator but not a developer. I tried my hand at creating a very simple ApexClass with a Visual Force Page. The page is meant to be embeded on an Asset Page Layout, and return Custom Object Records where the Name matches the Asset's Serial Number. This part works fine, the problem is the test class. I have spent more time than I care to admit (days) trying to figure this out, looking at documentation and code examples. I am at a loss and hoping someone can lend a hand.

Here is my ApexClass:
public class DongleRecords
{
    public List<Dongle_Record__c> DongleRecords { get; set; }
   
    Public DongleRecords ( ApexPages.StandardController std )
    {
        if( std.getRecord().Id != null )
        {
            Asset con = [ Select Id, SerialNumber from Asset where Id =: std.getRecord().Id ];
           
            DongleRecords = [ Select Name, Application_Name__c, Number_of_Licenses__c, Release_Date__c, Expiry_Date__c, Last_Upgrade_Date__c from Dongle_Record__c where Name =: con.SerialNumber ];
        }
        else
        {
            DongleRecords = new List<Dongle_Record__c>();
        }
    }        
}
Here is my VF Page
<apex:page StandardController="Asset" extensions="DongleRecords">
    <apex:form >
        <apex:pageBlock title="Dongle Licenses">
            <apex:pageBlockTable value="{!DongleRecords}" var="dg">
                <apex:column value="{!dg.Name}"/>
                <apex:column value="{!dg.Application_Name__c}"/>
                <apex:column value="{!dg.Number_of_Licenses__c}"/>
                <apex:column value="{!dg.Release_Date__c}"/>
                <apex:column value="{!dg.Expiry_Date__c}"/>
                <apex:column value="{!dg.Last_Upgrade_Date__c}"/>
            </apex:pageBlockTable>   
        </apex:pageBlock>
    </apex:form>
</apex:page>
Here is my Test Class so far:
Attempting to Create an Account, an Asset, and a Dongle_Record__c, and then somehow test the Calss and VF Page.
@isTest
public class DongleRecordsTest
{
    static testMethod void testMethod1()
    {
        Account testAccount = new Account();
        testAccount.Name='Test Account' ;
        insert testAccount;
       
        Asset ast = new Asset();
        ast.Name ='Test Asset';
        ast.SerialNumber ='TEST0000';
        ast.accountid = testAccount.id;
        insert ast;
       
        Dongle_Record__c dng = new Dongle_Record__c ();
        dng.Name = 'TEST0000';
        insert dng;
       
        Test.StartTest();

         ApexPages.currentPage().getParameters().put('id', String.valueOf(ast.Id));

        Test.StopTest();
    }
}
Any help would be tremendously appreciated...


 
I am an experienced Administrator but not a developer. I tried my hand at creating a very simple ApexClass with a Visual Force Page. The page is meant to be embeded on an Asset Page Layout, and return Custom Object Records where the Name matches the Asset's Serial Number. This part works fine, the problem is the test class. I have spent more time than I care to admit (days) trying to figure this out, looking at documentation and code examples. I am at a loss and hoping someone can lend a hand.

Here is my ApexClass:
public class DongleRecords
{
    public List<Dongle_Record__c> DongleRecords { get; set; }
   
    Public DongleRecords ( ApexPages.StandardController std )
    {
        if( std.getRecord().Id != null )
        {
            Asset con = [ Select Id, SerialNumber from Asset where Id =: std.getRecord().Id ];
           
            DongleRecords = [ Select Name, Application_Name__c, Number_of_Licenses__c, Release_Date__c, Expiry_Date__c, Last_Upgrade_Date__c from Dongle_Record__c where Name =: con.SerialNumber ];
        }
        else
        {
            DongleRecords = new List<Dongle_Record__c>();
        }
    }        
}
Here is my VF Page
<apex:page StandardController="Asset" extensions="DongleRecords">
    <apex:form >
        <apex:pageBlock title="Dongle Licenses">
            <apex:pageBlockTable value="{!DongleRecords}" var="dg">
                <apex:column value="{!dg.Name}"/>
                <apex:column value="{!dg.Application_Name__c}"/>
                <apex:column value="{!dg.Number_of_Licenses__c}"/>
                <apex:column value="{!dg.Release_Date__c}"/>
                <apex:column value="{!dg.Expiry_Date__c}"/>
                <apex:column value="{!dg.Last_Upgrade_Date__c}"/>
            </apex:pageBlockTable>   
        </apex:pageBlock>
    </apex:form>
</apex:page>
Here is my Test Class so far:
Attempting to Create an Account, an Asset, and a Dongle_Record__c, and then somehow test the Calss and VF Page.
@isTest
public class DongleRecordsTest
{
    static testMethod void testMethod1()
    {
        Account testAccount = new Account();
        testAccount.Name='Test Account' ;
        insert testAccount;
       
        Asset ast = new Asset();
        ast.Name ='Test Asset';
        ast.SerialNumber ='TEST0000';
        ast.accountid = testAccount.id;
        insert ast;
       
        Dongle_Record__c dng = new Dongle_Record__c ();
        dng.Name = 'TEST0000';
        insert dng;
       
        Test.StartTest();

         ApexPages.currentPage().getParameters().put('id', String.valueOf(ast.Id));

        Test.StopTest();
    }
}
Any help would be tremendously appreciated...


 

Hi there,

Great app, but have geo-coded about 1/3 of our orgs accounts and I think I have found a bug. Am getting an error message when ever going to the geocode tab.

Invalid double:

An unexpected error has occurred. Your solution provider has been notified. (FN)


This is preventing any further accounts to be located, would be great to know what is causing this and how to resolve it to get the rest of the accounts located.

 

Could the creator (or someone) of this app let us know if this is happening due to a bug in the code, or if this is an issue with the format of the address values.

If it is a bug I hope that this can be resolved soon.

If it is a problem with format of the data, could we please know what we need to look for in the data to fix? Is it an issue that there could be a bad character in the address data somewhere? How can I tell what the next account record is that the Geocode tab looks at (what order does it run though the records)? So I can check the data an fix it, if this is the problem.

This is a great app and really need all account records mapped for it to be useful, we only have a partial set of records that are mapped due to this problem

 

I have tried this on different browsers and it seems it is happening to other orgs possibly as well (as this has been commented in the comments section of the app) - just found this discussion forum

  • August 19, 2010
  • Like
  • 0