• Justin L
  • NEWBIE
  • 30 Points
  • Member since 2014
  • GTM Technology Lead
  • ConAgra Foods

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 6
    Questions
  • 1
    Replies
Hello,

Yet another admin getting over their head in a foray into Apex.  I wrote a visualforce page (Cutting_ItemsShown) that required a custom controller (CuttingItemsShownController).  The VF page displays a list of associated records to the Task based on the Cutting_ID__c field on the Products_Cutting__c object.  These two parts work well, the trouble comes when trying to write a test class for the controller.
 
@isTest 
public class CuttingItemsShownControllerTest 
{
    static testMethod void testMethod1() 
    {   Account testAccount = new Account();
        testAccount.Name = 'Test Account';
        insert testAccount;
        
        Task testTask = new Task();
        testTask.RecordTypeId='0120y000000IBKkAAO' ;
        testTask.Subject='Cutting';
        testTask.Who_did_we_cut_against__c='Competitor';
        testTask.Did_We_Win__c='Yes';
        testTask.Whatid = 'testAccount.id';
        insert testTask;
        
        Products_Cutting__c item = new Products_Cutting__c ();
        item.Cutting_ID__c = testTask.id;
        item.Product_Code__c = '01tC0000004OvjpIAC';
        item.Name = 'SKUCode';
        item.Flavor__c = 'Company';
        item.Yield__c = 'Company';
        item.External_Texture__c = 'Company';
        item.Internal_Texture__c = 'Company';
        item.Cooked_Color__c = 'Company';
        item.Hold_Time__c = 'Company';
        item.Length__c = 'Company';
        item.Defects_Appearance__c = 'Company';
        item.Competitor_Item__c = '1234567901234';
        item.account_name__c = testAccount.Name;
        insert item;
        
        contract contr = new contract();
        // add all required field
        
        Test.StartTest(); 

            //ApexPages.currentPage().getParameters().put('id', String.valueOf(testTask.id));
            //CuttingItemsShownController  test = new CuttingItemsShownController(ApexPages.StandardController(testTask));
            //ApexPages.StandardController sc = new ApexPages.StandardController(item);
            //CuttingItemsShownController  testCutting = new CuttingItemsShownController(ApexPages.CuttingItemsShownController(testTask));
            PageReference pageRef = Page.Cutting_ItemsShown;
            pageRef.getParameters().put('Cutting_Id__c', testTask.id );
            pageRef.getParameters().put('Product_Code__c', '01tC0000004OvjpIAC');
            Test.setCurrentPage(pageRef);

            CuttingItemsShownController testTask1 = new CuttingItemsShownController(new ApexPages.StandardController(testTask));
            testTask.redirPage();    
        Test.StopTest();
     


            testCutting.cancel(); 
            testCutting.add ();

        Test.StopTest();
    }
}

The error received is as in the title:
Error: Compile Error: Constructor not defined: [CuttingItemsShownController].<Constructor>() at line 47 column 53

I'm thinking this has to do with the fact I'm displaying a list, but I'm not sure how to resolve it.  Is there any direction or resources you can provide to help me better understand the problem and the solution?  Thank you.
I'm trying to build a lightning component based on the Trailhead Contacts Nearby project, except using Accounts instead.  I'm getting the following error screen when I try to drag it to a Lightning Page:

User-added image


Controller: 
public with sharing class AcctController {

    @AuraEnabled
    public static List<Account> findNearby(Double latitude, Double longitude, Double maxDistance) {
        return Database.query('SELECT Id, Name, BillingStreet, BillingCity, BillingState, Next_Contract_Expiration__c, Current_Contract_Volume__c, Phone FROM Account' +
                       ' WHERE DISTANCE(Location__c, GEOLOCATION(' + latitude + ',' + longitude + '), \'mi\') < '+ maxDistance +
                       ' ORDER BY DISTANCE(Location__c, GEOLOCATION(' + latitude + ',' + longitude + '), \'mi\')');
        
    }

}

Component:
<aura:component controller="AcctController" implements="flexipage:availableForAllPageTypes">

    <aura:attribute name="maxDistance" type="integer"/>
    <aura:attribute name="latitude" type="Decimal"/>
    <aura:attribute name="longitude" type="Decimal"/>
    <aura:attribute name="Account" type="Account[]"/>
    
    <aura:handler name="init" value="{!this}" action="{!c.doInit}" />

    <div>
        <h2>Accounts Nearby</h2>
        <ul>
            <aura:iteration items="{!v.Account}" var="Account">
                <li>
                    <h3><a href="{! '#/sObject/' + Account.Id + '/view'}">{!Account.Name}</a></h3>
                    <aura:if isTrue="{! Account.BillingCity}">
                        <p><a href="{! 'http://maps.apple.com?q=' + Account.BillingStreet + ', ' + Account.BillingCity}">
                            {!Account.BillingStreet}<br/>
                            {!Account.BillingCity}, {!Account.BillingState}<br/>
                            {!Account.Current_Contract_Volume__c} + '  ' + {!Account.Next_Contract_Expiration__c}</a></p>
                    </aura:if>
                    <p><a href="{! 'tel:' + Account.phone}">{!Account.Phone}</a></p>
                </li>
            </aura:iteration>
        </ul>
    </div>

</aura:component>

The code is basically the same as the ContactsNearby, which appropriate changes made to desired fields and object, and it does not give off any code errors when saving, so syntax must be somewhat acceptable.  Any thoughts?
I'm trying to create a sidebar item in Visualforce that will display the most recent items posted to a specific Chatter group.  I have the feed working, but the page is showing the filter/sort bar and action items for the Chatter feed.  Is there a way I can just get the feed item itself without the extras?  

Example:
User-added image

Code:
<apex:page showHeader="false" sidebar="false" standardStylesheets="false">
  <html>
          <head>
                 <style>
                    body{
                      background-color: #FFB600;   
                      font-family: Arial, Helvetica, sans-serif;
                      font-size: 12px;
                      margin-left: 5px;
                      margin-right: 5px;
                   }
                    .alignleft {
                        text-align: left;
                   }
                 </style>  
        </head>
           <h3>Chatter Feed</h3>   
   <body>    
      <chatter:feed entityId="ChatterGroupID" rendered="true" showPublisher="false"/>
  </body>
  </html>
</apex:page>
Thank you, I searched on here and via Google and didn't see anything that addressed this situation.
 
Hello Everyone,

    I've been working in Apex for about 2 days now, and our IT department has set a requirement for 100% test coverage.  I created a class/controller that allows us to clone an object with it's custom children.  I have several similar controllers for cloning other objects, but that was before the test requirement.  

   Anyways, I've been working on a test class for the controller, and have been running into tons of little errors.  So far I have been able to clear them up on my own, but now I'm hitting one that is throwing me off.  

Now I'm getting the attempt to de-reference error on a line that gets the URL from the cloned object.  
 
//switch to test
                Test.startTest();
        
        //call the method
                PageReference ref = ext.cloneWithItems();
        
        //create the matching page reference
                PageReference redir = new PageReference('/'+ext.newRecordId+'/e?retURL=%2F'+ext.newRecordId);
        
        //sending to specific url
                System.assertEquals(ref.getURL(),redir.getURL());
        
        //check that GBU Activity was created 
                GBU_Activities__c newGBU = [select id from GBU_Activities__c where id = :ext.newRecordId];
                                               System.assertNotEquals(newGBU, null);
        
        //stop test
                Test.stopTest();

Any thoughts on how I can rewrite the assert statement to validate the clone?

Thank you.
I am very new to Visualforce (last job had its own VF programmer, now I'm having to pick it up), and created a page that creates a list of items, and a button to access the page from the parent, in this case, contracts.  The related list is Contract Items (contract_item__c) and I would like to limit the contract items to only the ones related to the specific contract I launch the page from.  I'm sure this is answered somewhere, but I apparently do not know what I am looking for, as 2 days of searching has brought me close but not quite there.
 
<apex:page standardController="Contract_Item__c"
           recordSetVar="CI"
           tabStyle="Contract_Item__c" sidebar="false">
  <apex:form >
    <apex:pageBlock >
      <apex:pageMessages />
      <apex:pageBlockButtons >
        <apex:commandButton value="Save"
                            action="{!save}"/>
        <apex:commandButton value="Cancel"
                            action="{!cancel}"/>
      </apex:pageBlockButtons>
      <apex:pageBlockTable value="{!CI}"
                           var="c">
        <apex:column value="{!c.name}"/>
        <apex:column headerValue="Item">
          <apex:outputField value="{!c.Item__c}"/>
        </apex:column>
        <apex:column headerValue="Price">
          <apex:inputField value="{!c.FS_Price__c}"/>
        </apex:column>
        <apex:column headerValue="Rebate">
            <apex:inputField value="{!c.Rebate__c}"/>
        </apex:column>
        <apex:column headerValue="Volume">
          <apex:inputField value="{!c.FS_Volume__c}"/>
        </apex:column>
      </apex:pageBlockTable>     
    </apex:pageBlock>
  </apex:form>
</apex:page>


 
This is probably an easy one for you, I'm just having a very hard time getting my search terms right while looking for an answer.  I'm a click admin, and I'm working on creating a checkbox that will mark itself true if a specific field value shows in a related list.   We have a list of items, and each item has a family (for example, part# 330455 would be included in Widgets, and part# 330456 would be in Sprockets.)  On our contracts, we have a related list that has each item, it's volume, and it's price that fills into a table on the final contract.  What I would like to do is have a checkbox mark itself if "Sprockets" shows at any point in that related list.  The family field is a picklist, which gives me some restrictions on formula.  My most recent attempt is IF(ISPICKVAL(Item_r.Family_c,"Sprockets"),TRUE,FALSE), but since not all items on the deal may be sprockets, it has been coming back false.  Any ideas?
Hi All, 

I'm an admin trying to work with our technical team on developing a custom app to use within our SF instance (Enterprise). We are wondering if lighning can make this process easier for them, and if we build a custom app can it integrate with Salesforce 1 as well? They are not familiar with Salesforce development. Thanks in advance for any advice.