• BillPowell__c
  • NEWBIE
  • 10 Points
  • Member since 2016
  • Salesforce Administrator
  • McGrory Glass


  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 11
    Questions
  • 26
    Replies

I have a button on a related list that will allow users (via checkboxes) to update a field on the selected related records, launching an autolaunched/headless flow. However, when the flow completes and updates the field, it returns the user to the tab of the parent record. How can I modify either the flow or the VF page to return the user to the parent record that the related list was on instead of the tab? I'm not a developer whatsoever and had a ton of help with this to begin with. Any help would be greatly appreciated. 

Here is the VF Page: 

<apex:page StandardController="Sample_Order_Line_Items__c" tabstyle="Sample_Order_Line_Items__c" recordSetVar="SOLI" >
    <!-- Add below each field you reference in your Flow -->   
    <apex:repeat value="{!SOLI}" var="row" rendered="false">
        {!row.id}
        {!row.Status__c}
    </apex:repeat>
    <!-- Runs your Flow -->   
    <flow:interview name="SOLIComplete"
          finishLocation="{!URLFOR($Action.Sample_Order__c.Tab, $ObjectType.Sample_Order__c)}">
        <apex:param name="Selected" value="{!Selected}"/>
    </flow:interview>
</apex:page>

Have a custom button on a related list that calls a VF page that passes the ID into a flow to update a field on selected records in the related list. I don't know the first thing about code but have been able to piece some things together with some help. 

Unfortunately, when the user uses the button, it returns them to the custom object tab, not the record they were working on (parent record). I know there is a way to do itt, but can't get anything I found on the dev forums to work correctly. 

Suggestions? Here's my code for the VF page:

<apex:page StandardController="Sample_Order_Line_Items__c" tabstyle="Sample_Order_Line_Items__c" recordSetVar="SOLI" >
    <!-- Add below each field you reference in your Flow -->   
    <apex:repeat value="{!SOLI}" var="row" rendered="false">
        {!row.id}
        {!row.Status__c}
    </apex:repeat>
    <!-- Runs your Flow -->   
    <flow:interview name="SOLIComplete"
          finishLocation="{!URLFOR($Action.Sample_Order__c.Tab, $ObjectType.Sample_Order__c)}">
        <apex:param name="Selected" value="{!Selected}"/>
    </flow:interview>
</apex:page>
Hey all, im trying to learn code and can't seem to find the issue with this. It is giving me the following error: 

Error: New_Sample_Order_Alert line 17, column 44: The element type "font" must be terminated by the matching end-tag "</font>"
Error: The element type "font" must be terminated by the matching end-tag "</font>".

Clearly, in the code sample below, the font tag is closed. I can't seem to find the issue. Suggestions? 

Here is the code: 
 
<messaging:emailTemplate subject="New Sample Order Notification" recipientType="User" relatedToType="Sample_Order__c">

<messaging:htmlEmailBody >
<html>
    <body>
    <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">
        <p>A new sample order has been requested by {!relatedTo.CreatedBy.Name} with the following details:</p><br>
        <br/>
       
        {!relatedTo.Project_Name__c}</br>
        {!relatedTo.McGrory_Sales_Rep__c}</br>
        {!relatedTo.Company__c}</br>
        {!relatedTo.Contact__c}</br>
        {!relatedTo.Ship_To__c}</br>
        <br/>
        <table border="0">
            <tr>
                <th>Quantity</th>
                <th>Description</th>
            </tr>
         <apex:repeat var="li" value="{!relatedTo.Sample_Order_Line_Items__r}">
            <tr>
                <td>{!li.Quantity__c}</td>
                <td>{!li.Description__c}</td>
                <td>{!li.Width__c}</td>
                <td>{!li.Height__c}</td>
                <td>{!li.Product_Code__c}</td>
            </tr>
          </apex:repeat>
        </table>      
    </font>
   </body>
  </html>
 </messaging:htmlEmailBody>

 <messaging:plainTextEmailBody >
        A new sample order has been requested by {!relatedTo.Name} with the following details:
        
        {!relatedTo.Project_Name__c}
        {!relatedTo.McGrory_Sales_Rep__c}
        {!relatedTo.Company__c}
        {!relatedTo.Contact__c}
        {!relatedTo.Ship_To__c}
        
        [ Quantity ] - [ Description ] - [ Width ] - [ Height ] - [ Product Code ]
        
        <apex:repeat var="li" value="{!relatedTo.Sample_Order_Line_Items__r}">
            [ {!li.Quantity__c} ] - [ {!li.Description__c} ] - [ {!li.Width__c} ] - [ {!li.Height__c} ] - [ {!li.Product_Code__c} ]
        </apex:repeat>
        
    </messaging:plainTextEmailBody>
    
</messaging:EmailTemplate>

 

Not a coder and have got some great help from the dev community providing a wireframe for me to fill in the blanks (thanks). However, with a custom controller I can't use standard list handling and severely complicates things. 

Can anyone point me in the right direction? I need standard functionality for buttons & show list views at the top of the page, but the only "custom" controlling I need is a section with rows at the bottom with an "add row" function (as well as edit/delete rows) to create child records. I was told this is an "extension" class. But I dont knwo the first thing about creating it. Take a look at the VF Page, Current Custom Controller, and the Test class. 

Let me know how you'd adjust it, and if you're able (i'd really appreciate), some code examples. Thank you! 
 

Heres the code I have NOW:

VISUALFORCE PAGE

<apex:page controller="SampleController" showHeader="True" tabstyle="Sample_Order__c">
                                                                         
    <apex:form >
        <apex:sectionHeader title="Sample Order"></apex:sectionHeader>
        <apex:pageBlock title="Sample Order Edit" mode="edit">

<!--SAMPLE ORDER RECORD SECTION & FIELDS-->  
            
			<apex:pageBlockSection title="Sample Order Information" collapsible="false" columns="2">              
                	<apex:inputField label="Project Name" value="{!sampleOrder.Project_Name__c}" required="true"/>
                	<apex:inputfield label="Order Status" value="{!sampleOrder.Status__c}" required="false"/>
                	<apex:inputField label="Sales Rep" value="{!sampleOrder.McGrory_Sales_Rep__c}" required="true" />
                	<apex:outputfield label="Order Date" value="{!sampleOrder.Request_Date__c}"/>
                	<apex:inputField label="Ship To" value="{!sampleOrder.Ship_To__c}" required="true"/>
                	<apex:inputfield label="Ship Date" value="{!sampleOrder.Ship_Date__c}" required="false"/>
                	<apex:inputField label="Notes" value="{!sampleOrder.Notes__c}" required="false"/> 
            </apex:pageBlockSection>
                        
            <apex:pageBlockSection title="Customer Information" collapsible="false" columns="2">
                	<apex:inputfield label="Company" value="{!sampleOrder.Company__c}" required="True"/>
                	<apex:outputfield label="Address" value="{!sampleOrder.Address__c}"/>
                	<apex:inputfield label="Contact" value="{!sampleOrder.Contact__c}" required="True"/>
               		<apex:inputfield label="Contact Phone" value="{!sampleOrder.Contact_Phone__c}"/>
                	<apex:inputField label="Contact Email" value="{!sampleOrder.Contact_Email__c}"/>
            </apex:pageBlockSection>
            
            <apex:pageBlockSection title="Alternate Contact Information - If Not Shipping To Sales Rep Or Customer" collapsible="True" columns="2">
                	<apex:inputfield label="Alternate Company" value="{!sampleOrder.Alternate_Company__c}" required="False"/>
                	<apex:inputfield label="Street Address" value="{!sampleOrder.Street_address__c}" required="False"/>
                	<apex:inputfield label="Alternate Contact" value="{!sampleOrder.Alternate_Contact__c}" required="False"/>
                	<apex:inputfield label="City" value="{!sampleOrder.City__c}" required="False"/>
                	<apex:inputfield label="Alternate Phone" value="{!sampleOrder.Alternate_Phone__c}" required="False"/>
                	<apex:inputfield label="State" value="{!sampleOrder.State__c}" required="False"/>
                	<apex:inputfield label="Alternate Email" value="{!sampleOrder.Alternate_Email__c}" required="False"/>
                	<apex:inputfield label="Zip/Postal Code" value="{!sampleOrder.Zip_Postal_Code__c}" required="False"/>               	              
            </apex:pageBlockSection>
            
<!--SAMPLE ORDER LINE ITEMS TABLE-->
            <apex:pageBlockSection title="Sample Order Line Items">
                <apex:pageBlockTable id="tblLineItems" value="{!sampleOrderLineItems}" var="soli">
                    <apex:column >
                        <apex:inputField value="{!soli.Quantity__c}"></apex:inputField>
                        <apex:facet name="header">
                            Quantity
                        </apex:facet>
                    </apex:column>
                    <apex:column >
                        <apex:inputField value="{!soli.Description__c}"></apex:inputField>
                        <apex:facet name="header">
                            Description
                        </apex:facet>
                    </apex:column>
                    <apex:column >
                        <apex:inputField value="{!soli.Width__c}"></apex:inputField>
                        <apex:facet name="header">
                            Width
                        </apex:facet>
                    </apex:column>
                    <apex:column >
                        <apex:inputField value="{!soli.Height__c}"></apex:inputField>
                        <apex:facet name="header">
                            Height
                        </apex:facet>
                    </apex:column>
                    <apex:column >
                        <apex:inputField value="{!soli.Product_Code__c}"></apex:inputField>
                        <apex:facet name="header">
                            Product Code
                        </apex:facet>
                    </apex:column>
                    <apex:facet name="footer">
                        <apex:commandButton value="Add Line" immediate="true" action="{!addLineItem}" rerender="tblLineItems"></apex:commandButton>
                    </apex:facet>
                </apex:pageBlockTable>
            </apex:pageBlockSection>
            <apex:pageBlockButtons >
                <apex:commandButton value="Save" action="{!save}"/>
                <apex:commandButton value="Cancel" action="{!cancel}" immediate="true" html-formnovalidate="formnovalidate"/>
                <apex:commandbutton value="Edit" action="{!edit}" immediate="true" html-formnonvalidate="formnonvalidate"/>
                               
            </apex:pageBlockButtons>
            
        </apex:pageBlock>
    </apex:form>
     <apex:listViews type="Sample_Order__c" rendered="True"/> 
</apex:page>


Controller (Current, custom)​

public class SampleController {
    public Sample_Order__c sampleOrder  { get; set; }
    public List<Sample_Order_Line_Items__c> sampleOrderLineItems     { get; set; }
    
    public SampleController() {
        sampleOrder             = new Sample_Order__c();
        sampleOrderLineItems    = new List<Sample_Order_Line_Items__c>{ new Sample_Order_Line_Items__c() };
    }
    
    public void addLineItem() {
        sampleOrderLineItems.add( new Sample_Order_Line_Items__c() );
    }
    
    public PageReference save() {
        INSERT sampleOrder;
        
        for( Sample_Order_Line_Items__c soli : sampleOrderLineItems ) {
            soli.Sample_Order__c = sampleOrder.Id;
        }
        
        INSERT sampleOrderLineItems;
        
        return new PageReference( '/' + sampleOrder.Id );
    }
    
    public PageReference cancel() {
        return new PageReference( '/home/home.jsp' );
    }
    
    public boolean editSection {get;set;}
    {
        
    }
    public PageReference edit(){
        editSection = true;
        return null;
    }
    
}


Test Class​

@isTest 
public class SampleController_UT 
{
 static testMethod void testMethod1() 
 {
 Account oAccount = new Account();
 oAccount.name = 'Test';
 oAccount.Type = 'Architect';
 oAccount.Phone = '(856)739-2546';
 oAccount.BillingStreet = '1400 Grandview Avenue';
 oAccount.BillingCity = 'Paulsboro';
 oAccount.BillingStateCode = 'NJ';
 oAccount.BillingPostalCode = '08066';
 oAccount.BillingCountry = 'United States';
     insert oAccount;
     
 Project__c oProject = new Project__c();
 oProject.Account__c = oAccount.Id;
 oProject.Name = 'TestProject';
 oProject.Estimated_Project_Value__c = 1;
 oProject.Estimated_Completion_Date__c= date.today();
 oProject.Project_Manager__c = oAccount.CreatedById;
 oProject.Product_Type__c = 'Acid Etch';
     insert oProject;
 
 
 Sample_Order__c  oSampleOrder = new Sample_Order__c ();
 oSampleOrder.Project_Name__c = oProject.id;
 oSampleOrder.McGrory_Sales_rep__c = oProject.CreatedById;
 oSampleOrder.Ship_To__c = 'Customer';
     
 list<Sample_Order_Line_Items__c> lstSampleOrderLineItems = new list<Sample_Order_Line_Items__c>();
 Sample_Order_Line_Items__c oSampleOrderLineItems = new Sample_Order_Line_Items__c();
 oSampleOrderLineItems.Quantity__c = 1;
 oSampleOrderLineItems.Description__c = 'Test';
 //Add your required field
 lstSampleOrderLineItems.add(oSampleOrderLineItems);
 
 
 Test.StartTest(); 

  PageReference pageRef = Page.SampleOrder; // Add your VF page Name here
  Test.setCurrentPage(pageRef);

  SampleController  oSampleController  = new SampleController ();
  oSampleController.sampleOrder  = oSampleOrder;
  oSampleController.sampleOrderLineItems = lstSampleOrderLineItems; 
  oSampleController.save();
  oSampleController.cancel();
  oSampleController.addLineItem();  
 Test.StopTest();
 }
}

I can't write code for the life of me but can usually plug in values and follow a pattern to have it do what I need it to. Had some help with a VF page, controller, and test class, but cant seem to get the test class to save. Can someone take a look at let me know what to change to make it pass? Thanks

VF Page

<apex:page controller="SampleController">
    <apex:form >
        <apex:sectionHeader title="Mass Create Sample Order Line Items"></apex:sectionHeader>
        <apex:pageBlock title="Sample Order Edit" mode="edit">

<!--SAMPLE ORDER RECORD SECTION & FIELDS-->  
            
			<apex:pageBlockSection title="Sample Order Information" collapsible="false" columns="2">              
                	<apex:inputField label="Project Name" value="{!sampleOrder.Project_Name__c}" required="true"/>
                	<apex:inputfield label="Order Status" value="{!sampleOrder.Status__c}" required="false"/>
                	<apex:inputField label="Sales Rep" value="{!sampleOrder.McGrory_Sales_Rep__c}" required="true" />
                	<apex:outputfield label="Order Date" value="{!sampleOrder.Request_Date__c}"/>
                	<apex:inputField label="Ship To" value="{!sampleOrder.Ship_To__c}" required="true"/>
                	<apex:inputfield label="Ship Date" value="{!sampleOrder.Ship_Date__c}" required="false"/>
                	<apex:inputField label="Notes" value="{!sampleOrder.Notes__c}" required="false"/> 
            </apex:pageBlockSection>
                        
            <apex:pageBlockSection title="Customer Information" collapsible="false" columns="2">
                	<apex:inputfield label="Company" value="{!sampleOrder.Company__c}" required="True"/>
                	<apex:outputfield label="Address" value="{!sampleOrder.Address__c}"/>
                	<apex:inputfield label="Contact" value="{!sampleOrder.Contact__c}" required="True"/>
               		<apex:inputfield label="Contact Phone" value="{!sampleOrder.Contact_Phone__c}"/>
                	<apex:inputField label="Contact Email" value="{!sampleOrder.Contact_Email__c}"/>
            </apex:pageBlockSection>
            
            <apex:pageBlockSection title="Alternate Contact Information - If Not Shipping To Sales Rep Or Customer" collapsible="false" columns="2">
                	<apex:inputfield label="Alternate Company" value="{!sampleOrder.Alternate_Company__c}" required="False"/>
                	<apex:inputfield label="Street Address" value="{!sampleOrder.Street_address__c}" required="False"/>
                	<apex:inputfield label="Alternate Contact" value="{!sampleOrder.Alternate_Contact__c}" required="False"/>
                	<apex:inputfield label="City" value="{!sampleOrder.City__c}" required="False"/>
                	<apex:inputfield label="Alternate Phone" value="{!sampleOrder.Alternate_Phone__c}" required="False"/>
                	<apex:inputfield label="State" value="{!sampleOrder.State__c}" required="False"/>
                	<apex:inputfield label="Alternate Email" value="{!sampleOrder.Alternate_Email__c}" required="False"/>
                	<apex:inputfield label="Zip/Postal Code" value="{!sampleOrder.Zip_Postal_Code__c}" required="False"/>               	              
            </apex:pageBlockSection>
            
<!--SAMPLE ORDER LINE ITEMS TABLE-->
            <apex:pageBlockSection title="Sample Order Line Items">
                <apex:pageBlockTable id="tblLineItems" value="{!sampleOrderLineItems}" var="soli">
                    <apex:column >
                        <apex:inputField value="{!soli.Quantity__c}"></apex:inputField>
                        <apex:facet name="header">
                            Quantity
                        </apex:facet>
                    </apex:column>
                    <apex:column >
                        <apex:inputField value="{!soli.Description__c}"></apex:inputField>
                        <apex:facet name="header">
                            Description
                        </apex:facet>
                    </apex:column>
                    <apex:column >
                        <apex:inputField value="{!soli.Width__c}"></apex:inputField>
                        <apex:facet name="header">
                            Width
                        </apex:facet>
                    </apex:column>
                    <apex:column >
                        <apex:inputField value="{!soli.Height__c}"></apex:inputField>
                        <apex:facet name="header">
                            Height
                        </apex:facet>
                    </apex:column>
                    <apex:column >
                        <apex:inputField value="{!soli.Product_Code__c}"></apex:inputField>
                        <apex:facet name="header">
                            Product Code
                        </apex:facet>
                    </apex:column>
                    <apex:facet name="footer">
                        <apex:commandButton value="Add Line" immediate="true" action="{!addLineItem}" rerender="tblLineItems"></apex:commandButton>
                    </apex:facet>
                </apex:pageBlockTable>
            </apex:pageBlockSection>
            <apex:pageBlockButtons >
                <apex:commandButton value="Save" action="{!save}"></apex:commandButton>
                <apex:commandButton value="Cancel" action="{!cancel}"></apex:commandButton>
            </apex:pageBlockButtons>
        </apex:pageBlock>
    </apex:form>
</apex:page>

Custom Controller
public class SampleController {
    public Sample_Order__c sampleOrder  { get; set; }
    public List<Sample_Order_Line_Items__c> sampleOrderLineItems     { get; set; }
    
    public SampleController() {
        sampleOrder             = new Sample_Order__c();
        sampleOrderLineItems    = new List<Sample_Order_Line_Items__c>{ new Sample_Order_Line_Items__c() };
    }
    
    public void addLineItem() {
        sampleOrderLineItems.add( new Sample_Order_Line_Items__c() );
    }
    
    public PageReference save() {
        INSERT sampleOrder;
        
        for( Sample_Order_Line_Items__c soli : sampleOrderLineItems ) {
            soli.Sample_Order__c = sampleOrder.Id;
        }
        
        INSERT sampleOrderLineItems;
        
        return new PageReference( '/' + sampleOrder.Id );
    }
    
    public PageReference cancel() {
        return new PageReference( '/home/home.jsp' );
    }
}

Test Class (not working, can't figure out what to add/remove/edit) 
@isTest
private class SampleController_UT
{
	private static testmethod void testMethod1()
	{
		
		SampleController  soObj = new SampleController();
		soObj.addLineItem();
		soObj.cancel();
		soObj.Sample_Order__c = 'Test';
        soObj.Quantity__c = 1;
        soObj.Project_name__c = 'Quote Testing Project';
        soObj.McGrory_Sales_Rep__c = 'Bill Powell';
        soObj.Ship_To__c = 'Customer';

		
		try
		{
			soObj.save();
		}
		catch(Exception ee)
		{}
		
	}
	
}

 
Hey all, i'm slowly trying to learn apex and VF by adding my tweaks to code found elsewhere and understanding what it means (getting there!). However, i'm at a loss trying to figure out test classes, especially for a VF custom controller. 

Take a look let me know how i'd write a test class for this. Would I tell it to create a "Sample Order" record and populate the fields from the "Sample Order Line Items" object? My biggest problem is that I can understand the code (mostly), but can't write/regurgitate it :-( 
 
public class SampleController {
    public Sample_Order__c sampleOrder  { get; set; }
    public List<Sample_Order_Line_Items__c> sampleOrderLineItems     { get; set; }
    
    public SampleController() {
        sampleOrder             = new Sample_Order__c();
        sampleOrderLineItems    = new List<Sample_Order_Line_Items__c>{ new Sample_Order_Line_Items__c() };
    }
    
    public void addLineItem() {
        sampleOrderLineItems.add( new Sample_Order_Line_Items__c() );
    }
    
    public PageReference save() {
        INSERT sampleOrder;
        
        for( Sample_Order_Line_Items__c soli : sampleOrderLineItems ) {
            soli.Sample_Order__c = sampleOrder.Id;
        }
        
        INSERT sampleOrderLineItems;
        
        return new PageReference( '/' + sampleOrder.Id );
    }
    
    public PageReference cancel() {
        return new PageReference( '/home/home.jsp' );
    }
}

 
I have a lookup field on my Opportunity object that looks up to a custom object "Projects" (so we can see all of the opportunities associated with a project from different contractors). The # of opportunities are won/lost dynamically (not always 1 won, etc).  

Therefore, I want to create a list button on the Opportunity related list on projects so my users can just check off which ones have "won" and click a "Won" button to set the stage. The button works without error, but doesnt change the stage. Here is the code I have, why is this not working? Because of the relationship? 
 
{!REQUIRESCRIPT("/soap/ajax/40.0/connection.js")}
var o = new sforce.SObject("Opportunity");
o.id = "{!Opportunity.Id}";
o.StageName = "McGrory Won";
result = sforce.connection.update([o]);
window.location.reload();

 
Hoping the dev group can help me out. 

I want to create a visualforce page for a custom object "Sample Order". Sample order simply takes a few fields of input and adds the order to a queue for my sample team to fulfill an order, and keep track of orders placed, in process, and shipped. 

On the "Sample Order" page, the complicated part I can' figure out is how to write the visualforce page to include adding multiple child records for the custom object "Sample Order Line Items" in one shot, and have them display in the related list. 

I'd like to get something like this screenshot (very rough, done in excel)

User-added image

I can create the basic parts of the vf page since its just basic inputs and lookups, but need some help on creating the custom controller and the code to handle this list. I found a bunch of articles online but none seem to do the trick. 

Any help would be appreciated, thank you! 

I have a custom object "Projects__c" and standard "Opportunities" as a related list to projects via a lookup relationship. 

When a user creates a new Opportunity from the Projects__c object, I would like some values from the Project record to prepopulate in the opportunity when it is created. Is there a way to do this with a lookup relationship and Trigger? I know workflow and PB can only do this on save of the new record which would defeat the purpose, and am trying to avoid a URL hack. 

I don't know code other than the first two lines of the trigger, beyond that I get lost. Any suggestions? 

I know almost nothing about Apex and looking for help. I know for this use case I will need a Trigger, however. 

Here's the use case: 

My company has 8 oven slots(manufacturing), and 2 cycle AM and PM for a total of 16 total usable slots(8 each cycle). I need to measure the success rate of each slot during the AM and PM based on the # of orders gone into the specific slot. 


Here is how i've set it up thus far: 
I have a child related list (Audits__c) to a master (Order_Summary__c). Each "audit" record has a field "AM Oven Slot__c" and "PM Oven Slot__c" both are ranged 1-8 in a picklist, and finally there is a "Outcome_Result__c" picklist field with "Good" and "Fail" 

I have already used 16/25 rollup summaries to count the # of line items that go into each tray in the AM and PM, respectively. 

Now, I need a Trigger to COUNT the number of "Good" Outcome_Result__c for each respective tray # and update the respective number field. 
For example, it will SUM the # of "good" outcome results for Tray 1, and then insert that number into "Total Successful outcomes AM Tray 1" 

I think I need to do a BEFORE trigger since I don't need to utilize the record ID, and a list?? 

Help? 

I'd like to find a way to dynamically assign a "Line Number" to a quote line based on certain criteria. 

For instance, If I have 100 lines on my quote, and only want to show 20 of them and assign a line # 1-20 to those 20 items, how can I accomplish this? The "hidden" quote line items will not show up on the quote template since they are for internal configuration use only, but are throwing off the line #'s since they are hidden, its causing the line #'s for shown items to jump around. 

I'm assuming this may be an "After" trigger on the quote object? I don't know code well but I should be able how to write the trigger if need be with some guidance. 

Am I on the right path of having an "After" trigger and having it cycle through "quote lines" and if "Core Product" is checked and "Line Number" is blank, assign it 1, then go through the loop again and have X++ so the next quote line if it meets criteria, is 2, and so on and so on? 

Thoughts? Thanks for your help 

 
Hey all, im trying to learn code and can't seem to find the issue with this. It is giving me the following error: 

Error: New_Sample_Order_Alert line 17, column 44: The element type "font" must be terminated by the matching end-tag "</font>"
Error: The element type "font" must be terminated by the matching end-tag "</font>".

Clearly, in the code sample below, the font tag is closed. I can't seem to find the issue. Suggestions? 

Here is the code: 
 
<messaging:emailTemplate subject="New Sample Order Notification" recipientType="User" relatedToType="Sample_Order__c">

<messaging:htmlEmailBody >
<html>
    <body>
    <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">
        <p>A new sample order has been requested by {!relatedTo.CreatedBy.Name} with the following details:</p><br>
        <br/>
       
        {!relatedTo.Project_Name__c}</br>
        {!relatedTo.McGrory_Sales_Rep__c}</br>
        {!relatedTo.Company__c}</br>
        {!relatedTo.Contact__c}</br>
        {!relatedTo.Ship_To__c}</br>
        <br/>
        <table border="0">
            <tr>
                <th>Quantity</th>
                <th>Description</th>
            </tr>
         <apex:repeat var="li" value="{!relatedTo.Sample_Order_Line_Items__r}">
            <tr>
                <td>{!li.Quantity__c}</td>
                <td>{!li.Description__c}</td>
                <td>{!li.Width__c}</td>
                <td>{!li.Height__c}</td>
                <td>{!li.Product_Code__c}</td>
            </tr>
          </apex:repeat>
        </table>      
    </font>
   </body>
  </html>
 </messaging:htmlEmailBody>

 <messaging:plainTextEmailBody >
        A new sample order has been requested by {!relatedTo.Name} with the following details:
        
        {!relatedTo.Project_Name__c}
        {!relatedTo.McGrory_Sales_Rep__c}
        {!relatedTo.Company__c}
        {!relatedTo.Contact__c}
        {!relatedTo.Ship_To__c}
        
        [ Quantity ] - [ Description ] - [ Width ] - [ Height ] - [ Product Code ]
        
        <apex:repeat var="li" value="{!relatedTo.Sample_Order_Line_Items__r}">
            [ {!li.Quantity__c} ] - [ {!li.Description__c} ] - [ {!li.Width__c} ] - [ {!li.Height__c} ] - [ {!li.Product_Code__c} ]
        </apex:repeat>
        
    </messaging:plainTextEmailBody>
    
</messaging:EmailTemplate>

 

I can't write code for the life of me but can usually plug in values and follow a pattern to have it do what I need it to. Had some help with a VF page, controller, and test class, but cant seem to get the test class to save. Can someone take a look at let me know what to change to make it pass? Thanks

VF Page

<apex:page controller="SampleController">
    <apex:form >
        <apex:sectionHeader title="Mass Create Sample Order Line Items"></apex:sectionHeader>
        <apex:pageBlock title="Sample Order Edit" mode="edit">

<!--SAMPLE ORDER RECORD SECTION & FIELDS-->  
            
			<apex:pageBlockSection title="Sample Order Information" collapsible="false" columns="2">              
                	<apex:inputField label="Project Name" value="{!sampleOrder.Project_Name__c}" required="true"/>
                	<apex:inputfield label="Order Status" value="{!sampleOrder.Status__c}" required="false"/>
                	<apex:inputField label="Sales Rep" value="{!sampleOrder.McGrory_Sales_Rep__c}" required="true" />
                	<apex:outputfield label="Order Date" value="{!sampleOrder.Request_Date__c}"/>
                	<apex:inputField label="Ship To" value="{!sampleOrder.Ship_To__c}" required="true"/>
                	<apex:inputfield label="Ship Date" value="{!sampleOrder.Ship_Date__c}" required="false"/>
                	<apex:inputField label="Notes" value="{!sampleOrder.Notes__c}" required="false"/> 
            </apex:pageBlockSection>
                        
            <apex:pageBlockSection title="Customer Information" collapsible="false" columns="2">
                	<apex:inputfield label="Company" value="{!sampleOrder.Company__c}" required="True"/>
                	<apex:outputfield label="Address" value="{!sampleOrder.Address__c}"/>
                	<apex:inputfield label="Contact" value="{!sampleOrder.Contact__c}" required="True"/>
               		<apex:inputfield label="Contact Phone" value="{!sampleOrder.Contact_Phone__c}"/>
                	<apex:inputField label="Contact Email" value="{!sampleOrder.Contact_Email__c}"/>
            </apex:pageBlockSection>
            
            <apex:pageBlockSection title="Alternate Contact Information - If Not Shipping To Sales Rep Or Customer" collapsible="false" columns="2">
                	<apex:inputfield label="Alternate Company" value="{!sampleOrder.Alternate_Company__c}" required="False"/>
                	<apex:inputfield label="Street Address" value="{!sampleOrder.Street_address__c}" required="False"/>
                	<apex:inputfield label="Alternate Contact" value="{!sampleOrder.Alternate_Contact__c}" required="False"/>
                	<apex:inputfield label="City" value="{!sampleOrder.City__c}" required="False"/>
                	<apex:inputfield label="Alternate Phone" value="{!sampleOrder.Alternate_Phone__c}" required="False"/>
                	<apex:inputfield label="State" value="{!sampleOrder.State__c}" required="False"/>
                	<apex:inputfield label="Alternate Email" value="{!sampleOrder.Alternate_Email__c}" required="False"/>
                	<apex:inputfield label="Zip/Postal Code" value="{!sampleOrder.Zip_Postal_Code__c}" required="False"/>               	              
            </apex:pageBlockSection>
            
<!--SAMPLE ORDER LINE ITEMS TABLE-->
            <apex:pageBlockSection title="Sample Order Line Items">
                <apex:pageBlockTable id="tblLineItems" value="{!sampleOrderLineItems}" var="soli">
                    <apex:column >
                        <apex:inputField value="{!soli.Quantity__c}"></apex:inputField>
                        <apex:facet name="header">
                            Quantity
                        </apex:facet>
                    </apex:column>
                    <apex:column >
                        <apex:inputField value="{!soli.Description__c}"></apex:inputField>
                        <apex:facet name="header">
                            Description
                        </apex:facet>
                    </apex:column>
                    <apex:column >
                        <apex:inputField value="{!soli.Width__c}"></apex:inputField>
                        <apex:facet name="header">
                            Width
                        </apex:facet>
                    </apex:column>
                    <apex:column >
                        <apex:inputField value="{!soli.Height__c}"></apex:inputField>
                        <apex:facet name="header">
                            Height
                        </apex:facet>
                    </apex:column>
                    <apex:column >
                        <apex:inputField value="{!soli.Product_Code__c}"></apex:inputField>
                        <apex:facet name="header">
                            Product Code
                        </apex:facet>
                    </apex:column>
                    <apex:facet name="footer">
                        <apex:commandButton value="Add Line" immediate="true" action="{!addLineItem}" rerender="tblLineItems"></apex:commandButton>
                    </apex:facet>
                </apex:pageBlockTable>
            </apex:pageBlockSection>
            <apex:pageBlockButtons >
                <apex:commandButton value="Save" action="{!save}"></apex:commandButton>
                <apex:commandButton value="Cancel" action="{!cancel}"></apex:commandButton>
            </apex:pageBlockButtons>
        </apex:pageBlock>
    </apex:form>
</apex:page>

Custom Controller
public class SampleController {
    public Sample_Order__c sampleOrder  { get; set; }
    public List<Sample_Order_Line_Items__c> sampleOrderLineItems     { get; set; }
    
    public SampleController() {
        sampleOrder             = new Sample_Order__c();
        sampleOrderLineItems    = new List<Sample_Order_Line_Items__c>{ new Sample_Order_Line_Items__c() };
    }
    
    public void addLineItem() {
        sampleOrderLineItems.add( new Sample_Order_Line_Items__c() );
    }
    
    public PageReference save() {
        INSERT sampleOrder;
        
        for( Sample_Order_Line_Items__c soli : sampleOrderLineItems ) {
            soli.Sample_Order__c = sampleOrder.Id;
        }
        
        INSERT sampleOrderLineItems;
        
        return new PageReference( '/' + sampleOrder.Id );
    }
    
    public PageReference cancel() {
        return new PageReference( '/home/home.jsp' );
    }
}

Test Class (not working, can't figure out what to add/remove/edit) 
@isTest
private class SampleController_UT
{
	private static testmethod void testMethod1()
	{
		
		SampleController  soObj = new SampleController();
		soObj.addLineItem();
		soObj.cancel();
		soObj.Sample_Order__c = 'Test';
        soObj.Quantity__c = 1;
        soObj.Project_name__c = 'Quote Testing Project';
        soObj.McGrory_Sales_Rep__c = 'Bill Powell';
        soObj.Ship_To__c = 'Customer';

		
		try
		{
			soObj.save();
		}
		catch(Exception ee)
		{}
		
	}
	
}

 
Hey all, i'm slowly trying to learn apex and VF by adding my tweaks to code found elsewhere and understanding what it means (getting there!). However, i'm at a loss trying to figure out test classes, especially for a VF custom controller. 

Take a look let me know how i'd write a test class for this. Would I tell it to create a "Sample Order" record and populate the fields from the "Sample Order Line Items" object? My biggest problem is that I can understand the code (mostly), but can't write/regurgitate it :-( 
 
public class SampleController {
    public Sample_Order__c sampleOrder  { get; set; }
    public List<Sample_Order_Line_Items__c> sampleOrderLineItems     { get; set; }
    
    public SampleController() {
        sampleOrder             = new Sample_Order__c();
        sampleOrderLineItems    = new List<Sample_Order_Line_Items__c>{ new Sample_Order_Line_Items__c() };
    }
    
    public void addLineItem() {
        sampleOrderLineItems.add( new Sample_Order_Line_Items__c() );
    }
    
    public PageReference save() {
        INSERT sampleOrder;
        
        for( Sample_Order_Line_Items__c soli : sampleOrderLineItems ) {
            soli.Sample_Order__c = sampleOrder.Id;
        }
        
        INSERT sampleOrderLineItems;
        
        return new PageReference( '/' + sampleOrder.Id );
    }
    
    public PageReference cancel() {
        return new PageReference( '/home/home.jsp' );
    }
}

 
Hey there,

I'm new at Visualforce and like to create my first page.

Imagine the following setup: 

You have a custom object called Event. An Event may be a congress or a trade fair. Within the object you have the text field "City__c". 

Now you're working on a Lead from Dallas. Means: The standard field "City" equals "Dallas". Wouldn't it be great now to see all events taking in place in Dallas? I'd like to built a Visualforce Page list, that shows all Event records where the Lead field "City" is matching the Event field "City__c". I'm happy with 3 - 4 columns in the list.

Any idea how to build this? Feel free to provide me with sample code that is applicable for my project.

Kind regards,
David
  • June 27, 2017
  • Like
  • 0
I have a lookup field on my Opportunity object that looks up to a custom object "Projects" (so we can see all of the opportunities associated with a project from different contractors). The # of opportunities are won/lost dynamically (not always 1 won, etc).  

Therefore, I want to create a list button on the Opportunity related list on projects so my users can just check off which ones have "won" and click a "Won" button to set the stage. The button works without error, but doesnt change the stage. Here is the code I have, why is this not working? Because of the relationship? 
 
{!REQUIRESCRIPT("/soap/ajax/40.0/connection.js")}
var o = new sforce.SObject("Opportunity");
o.id = "{!Opportunity.Id}";
o.StageName = "McGrory Won";
result = sforce.connection.update([o]);
window.location.reload();

 
Hoping the dev group can help me out. 

I want to create a visualforce page for a custom object "Sample Order". Sample order simply takes a few fields of input and adds the order to a queue for my sample team to fulfill an order, and keep track of orders placed, in process, and shipped. 

On the "Sample Order" page, the complicated part I can' figure out is how to write the visualforce page to include adding multiple child records for the custom object "Sample Order Line Items" in one shot, and have them display in the related list. 

I'd like to get something like this screenshot (very rough, done in excel)

User-added image

I can create the basic parts of the vf page since its just basic inputs and lookups, but need some help on creating the custom controller and the code to handle this list. I found a bunch of articles online but none seem to do the trick. 

Any help would be appreciated, thank you! 
Hi,

I am stuck at the Create and Train the Dataset step on the Build a Cat Rescue App That Recognizes Cat Breeds Trailhead module.

I have successfully created the lightning component, uploaded the zip file and clicked on the train button but when I try to Verifiy I get the following error message:
"Challenge Not yet complete... here's what's wrong: 
Could not find a successful cat dataset training. The training may take a couple of minutes after the model is created."

Could you please advise ?

Thanks for your help.