• foodrunner
  • NEWBIE
  • 0 Points
  • Member since 2010

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 16
    Questions
  • 18
    Replies

I am working with an unmanaged package from the appexchange and force.com labs called Campaign Call Down, and have been troubleshooting this requirement for customization for several hours.

 

I am needing to query across all active campaigns to formulate a list of campaign members by owner dropdown list. I have tried to create a nested soql statement but am coming up with an error

Error: Compile Error: Initial term of field expression must be a concrete SObject: LIST<Lead> at line 416 column 44

 

Here is my Code:

    public List<SelectOption> getowneritems(){
        List<SelectOption> options = new List<SelectOption>();
        options.add(new SelectOption( '1', 'SELECT' ));
        for( Campaign c:getactiveCampaigns()){
            options.add( new SelectOption( lead.ownerid, c.leadowner.name));
        }
        return options;


    public List<Campaign> getactiveCampaigns(){
        if( activeCampaigns == null ){
            activeCampaigns = [select id, (select lead.Ownerid, Contact.ownerid from CampaignMembers),
            Name, Ownerid, Owner.id, owner.name
            From Campaign where isActive = true and
            Include_in_Campaign_Call_Down__c = true order by name LIMIT 100];
        }
        return activeCampaigns;
    }

 

 

How can I fix this?

Thank you

In this workflow I have created a new record from the creation of an opportunity product record in a separate trigger. After the creation of the second record, I am needing to update the opportunity product record with the lookup value. With opportunity product records I can unable to use the object in a UI lookup field. I am receiving the following error:

 

Compile Error: Expression cannot be assigned at line -1 column -1  

 

Here is the trigger:

trigger LinkonOLI on Manufacturing_Design_Sheet__c (after insert) {

   Set<Id> mids = new set<Id>();
   for(Manufacturing_Design_Sheet__c m : trigger.new){
   mIds.add(m.OpportunityLineItemID__c);
   
   }
    System.debug('****1 : m Id size '+ mIds.size());

    List<Manufacturing_Design_Sheet__c> mds = [SELECT Id, name, OpportunityLineItemID__c
     FROM Manufacturing_Design_Sheet__c  
        WHERE createddate =: system.now() and createdbyId = :UserInfo.getUserId() limit 1]; 
       
  
    If(OpportunityLineItem.id = Manufacturing_Design_Sheet__c.OpportunityLineItemID__c){
     OpportunityLineItem.spec_sheet__c = Manufacturing_Design_Sheet__c.OpportunityLineItemID__c;
   }
}      

 

How do I solve the error?

 

Thank you,

I am working on a trigger that will create a custom object record when a product is add to the Opportunity, where the product name will be copied to the custom record. I qwould like the product name be the name of the custom record, but the system is returning the record id in the name field. Here is my code:

 

trigger newSpecSheet on OpportunityLineItem (after Insert) {
    List<Manufacturing_Design_Sheet__c> mds = new List<Manufacturing_Design_Sheet__c>();
    for (OpportunityLineItem oli: Trigger.new) {
        if(Pricebookentry.id != null) {
        mds.add(new Manufacturing_Design_Sheet__c (
            Name = oli.Pricebookentry.Product2.name,
            Opportunity_Name__c = oli.Opportunityid,
            RecordTypeId = '012500000001COp',
            Quotation_Item_Number__c = 1));
        
        }
    }
    insert mds;
} 

How do I put the name of the product in the name field on the custom record?

Thank you

I am trying to integrate the standard quote object with Content to send package quotes with appropriate marketing documentation in Content to package and use the Content Delivery. I am trying to find apex information for Content and am not finding anything. Where can I find this information? can someone give me a link?

 

Thank you

I am needing to concatenate two custom fields into the address field through a before insert trigger. Will the before insert trigger fire before lead assignment rules?

I am trying to learn the wrapper class technique and am not understanding the cContact concept from the following example link:
http://wiki.developerforce.com/index.php/Wrapper_Class

The first instance of the cContact is on line 4 of the class with:

public List<cContact> getContacts() {

I have tried a number of times to convert this to the custom object that I am using with this code

public class casewrapperClassController {

public List <cCustomer_Product__c> CustomerList {get; set;}

}
and I recieve the following error:

Compile Error: Invalid type: cCustomer_Product__c at line 3 column 18

The questions I need answered is:

1. What is cContact in the example?
2. How is it defined in the example for the example to work?
3. What do I need to do to use cContact for a custom object or another standard object?

I have studied the example and am not understnding the cContact term.

 

Thank you

I have been working on a custom pdf page with CSS for quite a while and have not been able to standardize spacing between text lines within a mult-line field (billing address). What do I need to change to add the uniform spacing? I have not moved my css into an external style sheet, though I plan to.

 

 

My challenge is with this portion of the page:

 

                <apex:outputField value="{!quote.BillingAddress__c}" styleClass=" header3" />
                <apex:outputField value="{!quote.Created_Date__c}" />
                <span style="margin-left:-176px; margin-top: 500px;">
                <apex:outputLabel value="">
                <apex:outputField value="{!quote.BillingAddress2__c}"/>
                </apex:outputLabel>
                                </span>
                <span style="float:left; margin-left:0px; margin-top:-15px;">
                <apex:outputField value="{!quote.ExpirationDate}"/>
                                </span>
                <span style="float:left; margin-left:-176px; margin-top:-15px; z-index:-8;">
                <apex:outputLabel value="">
                <apex:outputfield value="{!quote.BillingCountry}"/>
                </apex:outputLabel>
                </span>   

 

 

 

 

Here is the entire visualforce page. I am not including the apex controllers as they are not applicable for this question.

 

<apex:page standardController="Quote" extensions="dataTableCons" standardstylesheets="false" renderAs="pdf" showHeader="false">
<head>
<style>
body { font-family: Arial Unicode MS; font-size: 10 px; } 

h3 {
    display:block; width:637px; padding:0; background:#ADD8E6;
    font-size:12px; line-height:23px; text-align:left; font-weight:normal;
}
h4 {
    display:block; width:637px; padding:0; 
    font-size:10px; line-height:12px; text-align:left; font-weight:normal;
}
h5 {
    display:block; width:637px; padding:0; 
    font-size:8px; line-height:12px; text-align:right; font-weight:normal;
}

.header
{
 width: 367x;
 height: 5px;
 background-color: gray;
 color: White;
 font-size:8pt;
 text-align: left;
 padding-left: 5px;
}
.header1
{
 width: 15px;
 height: 5px;
 background-color: gray;
 color: White;
 font-size:8pt;
 text-align: right;
 padding-left: 10px;
}
.header2
{
 width: 65px;
 background-color: gray;
 height: 5px;
 color: White;
 font-size:8pt;
 text-align: right;
 padding: 5px;
}

.tabletop {
    display:block; width:630px; height:5px; 
    background:transparent url(images/top.gif) no-repeat scroll 0 0;
    margin:0 0 0 4px;
}
.tablebk {
    width:615px;
    background:transparent url(images/middle.gif) repeat-y scroll 0 0;
    margin:0 0 0 4px; padding:0 0 0 15px;
}
.tablebottom {
    display:block; width:630px; height:16px; 
    background:transparent url(images/bottom.gif) no-repeat scroll 0 0;
    margin:0 0 0 4px;
}

table {table-layout:fixed; border-collapse:collapse; border-spacing:0; }

th {
    color:#fff; 
    font-size:14px; line-height:10px;
    padding:5px 6px 8px;
    vertical-align:top;
}
td {
    
    font-size:10px; line-height:10px;
    padding:3px;
    vertical-align:top;
}
th.col1,
td.col1 {text-align:left;}
.odd td {background-color:#f2f7fa;}

td input {
    width:85px; height:22px;
    font-size:14px; line-height:16px; font-weight:bold; text-align:left;
    padding-top:3px;
    border:null;
}

tr:hover td {background-color:#599bbd;} /* hover state does not work in ie6 */

/* table1 */
.table1 th.col1 {width:176px; }
.table1 th.col2 {width:181px;}
.table1 th.col3 {width:173px;}
.table1 td {padding-bottom:5px;}
.table1 td.col3 {padding-top:6px; padding-left:19px;}

/* table2 */
.table2 th.col1 {width:176px;}
.table2 th.col2 {width:181px;}
.table2 th.col3 {width:173px;}

/* table3 */
.table3 th.col1 {width:128px;}
.table3 th.col2 {width:153px;}
.table3 th.col3 {width:130px;}
.table3 th.col4 {width:95px;}
.table3 td {padding-bottom:5px;}
.table3 td.col4 {padding-top:6px; padding-left:19px;}
/* END Table CSS */


</style>
</head>

    <apex:form id="theForm">  
       <apex:pageBlock tabStyle="account">
            <apex:pageMessages />
         <apex:image url="/resource/1272645408000/Key_Logo" width="20%" height="20%"/>
           <Table class="table">
           <apex:pageBlockSection title="Essential Information" columns="2"  showHeader="false">
                <apex:outputField value="{!quote.Opportunity.AccountId}" styleClass="line-height='133px'" />
                <apex:outputField value="{!quote.quotenumber}" />
                <apex:outputField value="{!quote.BillingAddress__c}" styleClass=" header3" />
                <apex:outputField value="{!quote.Created_Date__c}" />
                <span style="margin-left:-176px; margin-top: 500px;">
                <apex:outputLabel value="">
                <apex:outputField value="{!quote.BillingAddress2__c}"/>
                </apex:outputLabel>
                                </span>
                <span style="float:left; margin-left:0px; margin-top:-15px;">
                <apex:outputField value="{!quote.ExpirationDate}"/>
                                </span>
                <span style="float:left; margin-left:-176px; margin-top:-15px; z-index:-8;">
                <apex:outputLabel value="">
                <apex:outputfield value="{!quote.BillingCountry}"/>
                </apex:outputLabel>
                </span>                
             </apex:pageBlockSection>

            <apex:pageBlockSection title="Contact Info" showHeader="true" >
                <apex:outputField value="{!quote.contactid}"/>
                <apex:outputField value="{!quote.Phone}"/>
                <apex:outputField value="{!quote.email}"/>
                <apex:outputField value="{!quote.fax}"/>
             </apex:pageBlockSection>

            </Table>

       </apex:pageBlock>
       
       </apex:form>

    <apex:pageBlock >
    <apex:pageBlockSection columns="2">
      <apex:dataTable value="{!Quote.QuoteLineItems}" rowClasses="even,odd," var="line"  width="630">
        <apex:column style="text-align:right;" headerClass="header1" headerValue="Item">
        <apex:facet name="Item">Item</apex:facet>
        <apex:outputText value="{!line.Quote_Item_Number__c}"/>
        </apex:column>  

        <apex:column style="text-align:left;
            border-left-style:solid; border-left-color:black;
            border-left-width:.25px;"
          headerClass="header" headerValue="Product">
        <apex:facet name="header">Product</apex:facet>
        <apex:outputText value="{!line.PriceBookentry.name}"/>
        </apex:column>        
        <apex:column style="text-align:right;
            border-left-style:solid; border-left-color:black;
            border-left-width:.25px;" headerClass="header2" headerValue="Quantity">
        <apex:facet name="header">Quantity</apex:facet>
        <apex:outputText value="{!line.Quantity}"/>
        </apex:column>
    <apex:column style="text-align:right;
            border-left-style:solid; border-left-color:black;
            border-left-width:.25px;" headerClass="header2" headerValue="Price Each">
        <apex:facet name="header">Price Each</apex:facet>
        <apex:outputText value="{!line.ListPrice}"/>
        </apex:column>
    <apex:column style="text-align:right;
            border-left-style:solid; border-left-color:black;
            border-left-width:.25px;" headerClass="header2" headerValue="Price Each">
        <apex:facet name="header">SubTotal</apex:facet>
        <apex:outputText value="{!line.Subtotal}"/>
        </apex:column>        
      </apex:dataTable>
      </apex:pageBlockSection>
   </apex:pageBlock>
  
        <apex:form >      
       <apex:pageBlock >
       <apex:pageBlockSection columns="2">
       <apex:inputhidden />
       <apex:inputhidden />
       <apex:inputhidden />
       <apex:outputField value="{!quote.Grand_Total__c}" style="h5" />
       </apex:pageBlockSection>

       </apex:pageBlock>
       <apex:pageBlock >
       <h4>
       This quotation is provided for budgetary planning purposes only. 
       This is not an official offer of sale, orders cannot be placed against this budget quotation. 
       Once project details have been fully defined, a final detailed quotation will be submitted.
       </h4>
       </apex:pageBlock> 
      </apex:form>

</apex:page>

 

In the test class that I am writing I am recieving the following error:

 

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

Class.testForecastOverride.TestOverrideTrigger: line 12, column 9 External entry point 

 

Below is my test class:

 

@isTest
private class testForecastOverride {

     testmethod private static void TestOverrideTrigger() {

    Opportunity o;

    id id1 = userinfo.getProfileId();
    Map <Id, Opportunity> opp = new map <id, Opportunity>();
    If (id1 == '00e30000000gAk7') {
    
        o.ForecastCategoryName = o.Forecast_Category_Override__c;
       }
       else if (id1 == '00eQ0000000HivN') {

        o.ForecastCategoryName = o.Forecast_Category_Override__c;
       } else if (id1 == '00e30000000gl0u') {
        o.ForecastCategoryName = o.Forecast_Category_Override__c;
       }
    }

}

 

Below is my trigger

trigger ForecastOverride on Opportunity (Before Update) {

    Set<Id> bIds = new Set<Id>();
    
    for(Opportunity op : trigger.new){
    System.debug('**** 0 op id : '+op.ForecastCategoryName);
    bids.add(op.id);
   }     
    list<Opportunity> forecastcategoryList = new List<Opportunity>();
    
    if(StaticClass.doNotExecute ==true)
{
    system.debug('Inserting'+StaticClass.doNotExecute);
    for(Opportunity o:trigger.new)
    {
     bIds.add(o.id);
     
    id id1 = userinfo.getProfileId();
    If (id1 == '00e30000000gAk7') {
    if (trigger.new[0].Forecast_Category_Override__c != trigger.old[0].Forecast_Category_Override__c)
     {
        o.ForecastCategoryName = o.Forecast_Category_Override__c;
        
        }
       }
       else if (id1 == '00eQ0000000HivN') {
    if (trigger.new[0].Forecast_Category_Override__c != trigger.old[0].Forecast_Category_Override__c)
     {
        o.ForecastCategoryName = o.Forecast_Category_Override__c;
        
        }
       } else if (id1 == '00e30000000gl0u') {
    if (trigger.new[0].Forecast_Category_Override__c != trigger.old[0].Forecast_Category_Override__c)
     {
        o.ForecastCategoryName = o.Forecast_Category_Override__c;
        
        }
       }
    }
}
}

 

 

I believe I am needing to write a map/list of the opportunity in the test class, but how do I do this?

 

Thank you again for your help

I am working on a visualforce page that provides a search field and returns the results on the same page. I have two problems with the search field.

 

1. The search box can only be used once for each time the page loads. How do I change this to allow the user keep using the same page without manually refreshing the entire page? I have not found any discussions on this, so I don't have code to post that is not working.

 

2.  The second question I have does have some code that I have started. I am trying to program the search field allow the user hit enter on the keyboard to search rather than having to click the search button. Here is my Javascript&colon;

 

button:

                <apex:commandButton value="Search" action="{!Search}" rerender="table"/>

 

javascript&colon;

<script> 
    function noenter(ev)  {
        if (window.event && window.event.keyCode == 13 || ev.which == 13) {
            Search();
            return false;
         } else {
              return true;
         }
     }

</script>

 

 

What do I need to change for this to work?

 

Thanks

I am working on a project where I have a visualforce page opening from the opportunity to pick records from the customer product custom object and copying the record into object B and referencing the opportunity page. I am trying to pull the opportunity id onto the Visualforce page. I have been scouring the discussion boards and the new. All I could file is the Janascript code to go to the previous page for IE and have been playing with some sample code.

 

 public PageReference GoBack() {
  String previousPage = System.currentPageReference().getParameters().get(​history.go(-1));
    PageReference newPage = new PageReference(previousPage);
    newPage.setRedirect(true);
    return newPage;
  }

 

I know the above code is a shot in the dark. Can anyone help and point me in the right direction?

I m trying to create a vf page where the  user will search for records and add them to the opportunity. This functionality is similar to tstandard automation of adding products to the opportunity. When I attempt to add the cutom controller I recieve the following error: "Unknown Property" "String.Selected."

 

Here is my Visualforce  page

<apex:page controller="customerwrapperClassController" > 
<!-- Javascript function to check all rows in the table --> 
<script> 
function checkAll(cb) 
{ 
var inputElem = document.getElementsByTagName("input"); 
for(var i=0;i<inputElem.length;i++) 
{ 
if(inputElem[i].id.indexOf("selectLine1")!=-1) 
inputElem[i].checked = cb.checked; 
} 
} 
</script> 
<!-- End of Javascript function --> 
<apex:form > 
<apex:sectionHeader title="Step 1" subtitle="Select Contacts to send Email"/> 
<apex:pageblock > 
<apex:pageBlockSection title="Search Contacts" columns="1"></apex:pageBlockSection> 

<!-- Div to give a colored box effect --> 

<div style="border-width:2px;border-style:solid;border-color:orange;"> 

<!-- Panel grid to display boxes o accept user input values --> 
<apex:panelGrid columns="2"> 
<apex:outputLabel style="font-weight:bold;" value="Contact E-mail" ></apex:outputLabel> 
<apex:inputText value="{!userinput}"/> 
<apex:outputLabel style="font-weight:bold;" value="Contact Name" ></apex:outputLabel> 
<apex:inputText value="{!userinp}"/> 
</apex:panelGrid> 
<!-- End of panelgrid --> 
<!-- Div to position the commandbutton appropriately --> 
<div style="position:relative;left:75px;"> 
<apex:commandButton value="Search" action="{!contactsearch}" /> 
</div> 
<!-- End of div --> 
<br/> 
</div> 

<!-- End of colored box div --> 
<br/> 
<!-- Display error message --> 
<apex:pagemessage strength="2" title="Error!!" severity="error" detail="Please select a contact or enter email address to proceed" rendered="{!errormsg}"/> 
<!-- End of error message --> 

<!-- Display search results --> 
<apex:pageblocksection columns="1" title="Search results" rendered="{!NOT(ISNULL(results))}" > 
<apex:outputpanel id="Contactlist"> 

<apex:pageBlockTable value="{!results}" var="contacts"> 
<apex:column > 
<apex:facet name="header"> 
<apex:inputCheckbox onclick="checkAll(this)"/> 
</apex:facet> 
<apex:inputCheckbox value="{!contacts.selected}" id="selectLine1"/> 
</apex:column> 
<apex:column headervalue="Contact Name"> 
<apex:outputtext value="{!contacts.con.Name}"/> 
</apex:column> 
<apex:column headervalue="Account Name"> 
<apex:outputtext value="{!contacts.con.Account.Name}"/> 
</apex:column> 
<apex:column headervalue="Title"> 
<apex:outputtext value="{!contacts.con.Title}"/> 
</apex:column> 
</apex:pageBlockTable> <br/><br/> 

</apex:outputpanel> 
</apex:pageblocksection> 
<!-- End of search results --> 

<!-- Commandbutton to proceed to next screen --> 
<div style="position:relative;left:75px;"> 
<apex:commandButton value="Next" action="{!processSelected}"/> 
<apex:commandbutton value="Cancel" action="{!Cancel}"/> 
</div> 
<!-- End of Commandbutton --> 
</apex:pageblock> 
</apex:form> 
</apex:page> 

 

Here is my controller:

public class customerwrapperClassController {
    public String results { get; set; }

    public String errormsg { get; set; }

    public PageReference contactsearch() {
        return null;
    }


    public String userinp { get; set; }

    public String userinput { get; set; }

    public customerwrapperClassController() {

    }


    public customerwrapperClassController(ApexPages.StandardController controller) {

    }



    //Our collection of the class/wrapper objects Customer_Product_List_Item__c 
    public List<Customer_Product__c> productList {get; set;}
    
    //This method uses a simple SOQL query to return a List of Contacts
    public List<Customer_Product__c> getproduct(){
        if(productList== null){
            productList= new List<Customer_Product__c>();
        
            for(Customer_Product__c c : [select Id, Name from Customer_Product__c]){
                /* As each contact is processed we create a new Customer_Product_List_Item__c object and
                add it to the productList*/
                productList.add(c);
            }
        }
        return productList;
    }
    public PageReference processSelected(){
        /*We create a new list of Contacts that we be populated only with Contacts
        if they are selected*/
        List<Customer_Product__c> selectedProducts = new List<Customer_Product__c>();
        
        /*We will cycle through our list of cContacts and will check to see if the 
        selected property is set to true, if it is we add the Contact to the 
        selectedContacts list. */
        for(Customer_Product__c cCon: getproduct()){
            if(cCon.selected__c == true){
            //    selectedCustomer_Product__c.add(cCon.id);
            }
            }
         
        /* Now we have our list of selected contacts and can perform any type of 
        logic we want, sending emails, updating a field on the Contact, etc */
        System.debug('These are the selected Contacts...');
        for(Customer_Product__c con: selectedProducts){
            system.debug(con);
        }
        return null;
    }
 
    /* This is our wrapper/container class. A container class is a class, a data 
    structure, or an abstract data type whose instances are collections of other 
    objects. In this example a wrapper class contains both the standard salesforce 
    object Contact and a Boolean value */
    public class cCustomer {
        public Customer_Product__c con {get; set;}
        public Boolean selected {get; set;}
        
        /*This is the contructor method. When we create a new cContact object we pass a 
        Contact that is set to the con property. We also set the selected value to false*/
        public cCustomer(Customer_Product__c c){
            con = c;;
        }

 

Note: comments have not been updated to the custom object specifics, but is patterned after the wrapper class example. http://wiki.developerforce.com/index.php/Wrapper_Class

 

How do I solve this error? Thanks

 

I am working on a visualforce page customizing the quote page layout with the quote line items. I am adapting the script from the Creating Compount Views turtorial on the wiki.

 

I am recieving the following error message:

Error: Compile Error: Return value must be of type: LIST<Quote> at line 9 column 9  

 

Below is my controller code:

 

public class MyConsoleController {
    public MyConsoleController() {

   }
 
    public Quote selectedQuote { get; set; }  
     
    public Quote[] getQuote() {
        return [SELECT id, Name, QuoteNumber, Created_Date__c, quote.Opportunity.AccountId, Quote_Line_Item__c,
                    Grand_Total__c,BillingAddress__c, BillingAddress2__c FROM Quote where id = :ApexPages.currentPage().getParameters().get('id')];
    
    }


    public QuoteLineItem[] getQuoteLineItems() {
        return [SELECT Id, PriceBookEntry.name, Quote__r.Grand_Total__c, QuoteID, Quantity, Quote_Item_Number__c, TotalPrice, ListPrice FROM QuoteLineItem
        WHERE QuoteId = :ApexPages.currentPage().getParameters().get('Id') order by Quote_Item_Number__c Asc];}

}

My questions:

 

1. What am I doing wrong in this controller?

2. What needs to be changed?

 

Thank you

I have the following class to order the quotelineitem related list(datatable).

 

public class orderedLineItems { 
       public Id quoteID {get; set;}
               List<QuoteLineItem> lineItems;
                public List<QuoteLineItem> getlineItems(){
            if(lineItems == null){
                /*Using dyanamic apex and SOQL you could set this up to query all*/
                lineItems = [select Id, PricebookEntry.Name, Quantity, UnitPrice, TotalPrice from QuoteLineItem where QuoteID =:QuoteID];
                lineItems = sortLines(lineItems);
            }
            return lineItems;
        }
        
        private static List<QuoteLineItem> sortLines(List<QuoteLineItem> olis) {
            List<QuoteLineItem> resultList = new List<QuoteLineItem>();
        
            /* Create a map of amount to Opportunity collection */
            Map<String, List<QuoteLineItem>> oliMap = new Map<String, List<QuoteLineItem>>();
            
            for(QuoteLineItem oli : olis) {
                if(oliMap.get(oli.PricebookEntry.Name) == null){ 
                    oliMap.put(oli.PricebookEntry.Name, new List<QuoteLineItem >()); 
                }
                oliMap.get(oli.PricebookEntry.Name).add(oli);
            }
            
            List<String> keys = new List<String>(oliMap.keySet());
            
            /* Leverage the standard, primitive collection sort method */
            keys.sort();
            
            for(String key:keys){ 
                resultList.addAll(oliMap.get(key)); 
            }
            
            return resultList;
        }
}

 

 

Here is my visualforce page:

 

<apex:page standardController="Quote" standardstylesheets="false" renderAs="pdf" showHeader="false">
<head>
<style>
body { font-family: Arial Unicode MS; font-size: 10 px; } 

h3 {
    display:block; width:637px; padding:0; background:#ADD8E6;
    font-size:12px; line-height:23px; text-align:left; font-weight:normal;
}
h4 {
    display:block; width:637px; padding:0; 
    font-size:10px; line-height:12px; text-align:left; font-weight:normal;
}
h5 {
    display:block; width:637px; padding:0; 
    font-size:8px; line-height:12px; text-align:right; font-weight:normal;
}

.header
{
 width: 367x;
 height: 5px;
 background-color: gray;
 color: White;
 font-size:8pt;
 text-align: left;
 padding-left: 5px;
}
.header1
{
 width: 15px;
 height: 5px;
 background-color: gray;
 color: White;
 font-size:8pt;
 text-align: right;
 padding-left: 10px;
}
.header2
{
 width: 65px;
 background-color: gray;
 height: 5px;
 color: White;
 font-size:8pt;
 text-align: right;
 padding: 5px;
}

.tabletop {
    display:block; width:630px; height:5px; 
    background:transparent url(images/top.gif) no-repeat scroll 0 0;
    margin:0 0 0 4px;
}
.tablebk {
    width:615px;
    background:transparent url(images/middle.gif) repeat-y scroll 0 0;
    margin:0 0 0 4px; padding:0 0 0 15px;
}
.tablebottom {
    display:block; width:630px; height:16px; 
    background:transparent url(images/bottom.gif) no-repeat scroll 0 0;
    margin:0 0 0 4px;
}

table {table-layout:fixed; border-collapse:collapse; border-spacing:0; }

th {
    color:#fff; 
    font-size:14px; line-height:10px;
    padding:5px 6px 8px;
    vertical-align:top;
}
td {
    
    font-size:10px; line-height:10px;
    padding:3px;
    vertical-align:top;
}
th.col1,
td.col1 {text-align:left;}
.odd td {background-color:#f2f7fa;}

td input {
    width:85px; height:22px;
    font-size:14px; line-height:16px; font-weight:bold; text-align:left;
    padding-top:3px;
    border:null;
}

tr:hover td {background-color:#599bbd;} /* hover state does not work in ie6 */

/* table1 */
.table1 th.col1 {width:176px; }
.table1 th.col2 {width:181px;}
.table1 th.col3 {width:173px;}
.table1 td {padding-bottom:5px;}
.table1 td.col3 {padding-top:6px; padding-left:19px;}

/* table2 */
.table2 th.col1 {width:176px;}
.table2 th.col2 {width:181px;}
.table2 th.col3 {width:173px;}

/* table3 */
.table3 th.col1 {width:128px;}
.table3 th.col2 {width:153px;}
.table3 th.col3 {width:130px;}
.table3 th.col4 {width:95px;}
.table3 td {padding-bottom:5px;}
.table3 td.col4 {padding-top:6px; padding-left:19px;}
/* END Table CSS */


</style>
</head>

    <apex:form id="theForm">  
       <apex:pageBlock tabStyle="account">
            <apex:pageMessages />
         <apex:image url="/resource/1272645408000/Key_Logo" width="20%" height="20%"/>
           <Table class="table">
           <apex:pageBlockSection title="Essential Information" columns="2"  showHeader="false">
                <apex:outputField value="{!quote.Opportunity.AccountId}" />
                <apex:outputField value="{!quote.quotenumber}" />
                <apex:outputField value="{!quote.BillingAddress__c}" />

                <apex:outputField value="{!quote.Created_Date__c}" />
                <span style="margin-left:-176px; margin-top:-500px; z-index:-1;">
                <apex:outputLabel value="">
                <apex:outputField value="{!quote.BillingAddress2__c}"/>
                </apex:outputLabel>
                                </span>
                <span style="float:left; margin-left:0px; margin-top:-16px;">
                <apex:outputField value="{!quote.ExpirationDate}"/>
                                </span>
                <span style="float:left; margin-left:-176px; margin-top:-6px; z-index:-8;">
                <apex:outputLabel value="">
                <apex:outputfield value="{!quote.BillingCountry}"/>
                </apex:outputLabel>
                </span>                
             </apex:pageBlockSection>

            <apex:pageBlockSection title="Contact Info" showHeader="true" >
                <apex:outputField value="{!quote.contactid}"/>
                <apex:outputField value="{!quote.Phone}"/>
                <apex:outputField value="{!quote.email}"/>
                <apex:outputField value="{!quote.fax}"/>
             </apex:pageBlockSection>

            </Table>
       </apex:pageBlock>
       
       </apex:form>

    <apex:pageBlock >
    <apex:pageBlockSection columns="2">
      <apex:dataTable value="{!Quote.QuoteLineItems}" rowClasses="even,odd," var="line" width="630">
        <apex:column style="text-align:right;" headerClass="header1" headerValue="Item">
        <apex:facet name="header1">Item</apex:facet>
        <apex:outputText value="{!line.Quote_Item_Number__c}" />
        </apex:column>
        <apex:column style="text-align:left;
            border-left-style:solid; border-left-color:black;
            border-left-width:.25px;"  headerClass="header" headerValue="Product">
        <apex:facet name="header">Product</apex:facet>
        <apex:outputText value="{!line.PriceBookentry.name}" />
        </apex:column>        
        <apex:column style="text-align:right;
            border-left-style:solid; border-left-color:black;
            border-left-width:.25px;" headerClass="header2" headerValue="Quantity">
        <apex:facet name="header">Quantity</apex:facet>
        <apex:outputText value="{!line.Quantity}"/>
        </apex:column>
    <apex:column style="text-align:right;
            border-left-style:solid; border-left-color:black;
            border-left-width:.25px;" headerClass="header2" headerValue="Price Each">
        <apex:facet name="header">Price Each</apex:facet>
        <apex:outputText value="{!line.ListPrice}"/>
        </apex:column>
    <apex:column style="text-align:right;
            border-left-style:solid; border-left-color:black;
            border-left-width:.25px;" headerClass="header2" headerValue="Price Each">
        <apex:facet name="header">SubTotal</apex:facet>
        <apex:outputText value="{!line.Subtotal}"/>
        </apex:column>        
      </apex:dataTable>
      </apex:pageBlockSection>
   </apex:pageBlock>
  
        <apex:form >      
       <apex:pageBlock >
       <apex:pageBlockSection columns="2">
       <apex:inputhidden />
       <apex:inputhidden />
       <apex:inputhidden />
       <apex:outputField value="{!quote.Grand_Total__c}" style="h5" />
       </apex:pageBlockSection>

       </apex:pageBlock>
       <apex:pageBlock >
       <h4>
       This quotation is provided for budgetary planning purposes only. 
       This is not an official offer of sale, orders cannot be placed against this Budget quotation. 
       Once project details have been fully defined, a final detailed quotation will be submitted.
       </h4>
       </apex:pageBlock> 
      </apex:form>

</apex:page>

 

Does my class order the quotelineitems by? ItemNumber? What am I missing? How do I attach this onto the visualforce page?

 

Thank you,

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 am working on a conversion tool that will change the lookup values depending on a drop down list of the different measurement systems.

 

The step I am on is writing a trigger to populate a lookup field connecting the two records with cooresponding value. The workflow is when a record is created, a trigger will calculate the cnverted measure and enter a new record with the converted value and a link to the original record. I am trying to insert the value in the lookup field on the original record.

 

 

I am recieving the following error message:

Error: Compile Error: Method does not exist or incorrect signature: updatedCustomer_Bulk_Density__c.add(SOBJECT:Customer_Bulk_Density__c) at line 9 column 10

 

 

Below is my code:

trigger BulkDensityLink on Customer_Bulk_Density__c (after insert, after update) {
    Map<Id, Customer_Bulk_Density__c> LookupPop = new Map<Id, Customer_Bulk_Density__c>();

   List <Customer_Bulk_Density__c> updatedbulkdensity =  new List<Customer_Bulk_Density__c>();

    for(Customer_Bulk_Density__c b : [select id, Converted_Record_ID__c from Customer_Bulk_Density__c
         where Converted_Record_ID__c in :LookupPop.keyset() Limit 1]) {
         b.Converted_Record_Id__c = b.id;
         updatedCustomer_Bulk_Density__c.add(b);
         }
    //update updatedCustomer_Bulk_Density__c;
}

 

How do I insert the desired value from one record to another record on the same object?

 

Thanks,

 

Chris

I am trying to set create a new clone button only cloning certain fields on the opportunity:

I am recieving a de-reference a null object error.

 

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



Class.OpportunityCloneWithItemsController: line 32, column 81 External entry point 

 

Here is the apex class.

 

public with sharing class OpportunityCloneWithItemsController {
    public OpportunityCloneWithItemsController(ApexPages.StandardController controller) {

    }



        // load the current record
      //  Opportunity o = (Opportunity)controller.getRecord();
 
    
 
    // method called from the VF's action attribute to clone the Opportunity
    public PageReference clone;{
 
         // setup the save point for rollback
         Savepoint sp = Database.setSavepoint();
         Opportunity o;
         Opportunity newO;
 

              //copy the Opportunity - ONLY INCLUDE THE FIELDS YOU WANT TO CLONE
             o = [select  id, Name, Estimated_Cost__c, Margin__c, Competitor_Primary__c, 
             Competitor_Secondary__c, Account_Shipping_Location__c, Amount, INCO_Terms__c,
             Related_Location__c, Language_to_prepare_docs_in__c, Campaignid, Equipment__c,
             Parent__c, Equip_Services_Options_to_be_quoted__c, Lead_Time_Ex_Works__c, Op_Market_Position__c,
             Product_1__c, Product1_condition__c, Product1_Line_Capacity__c, Product1_Bulk_density__c,
             Product1_defect_description__c, Product_2__c, Product_2_Condition__c, Product_2_Line_Capacity__c,
             Product_2_Bulk_Density__c, Product_2_Defect_Description__c, Description, PS__c, Upgrade__c, Farmco__c,
             Service_Contract__c, Potato__c, Processed_Fruit_Veg__c, AIS__c, Project_System_Eng__c, Freshline__c,
             Spare_Parts__c, 
             Pharma__c, Misc_Other__c, AccountId from Opportunity o Where id = :o.id ];
             newO = o.clone(false);
             insert newO;
 

 
             // copy over the line items - ONLY INCLUDE THE FIELDS YOU WANT TO CLONReturn must be called from a method or trigger bodyE
             List<OpportunityLineItem> items = new List<OpportunityLineItem>();
             for (OpportunityLineItem oli : [Select Id, ListPrice, Cost_Each__c, Quantity From OpportunityLineItem ol where OpportunityLineItem.id = :o.id]) {
                  OpportunityLineItem newoli = oli.clone(false);
                //  newO.id = newO.id;
                  items.add(newOli);
             }
             insert items;


   //     return new PageReference('/'+newO.id+'/e?retURL=%2F'+newO.id);

    }

}

 

How do I solve this problem?

Thank you

I am working with an unmanaged package from the appexchange and force.com labs called Campaign Call Down, and have been troubleshooting this requirement for customization for several hours.

 

I am needing to query across all active campaigns to formulate a list of campaign members by owner dropdown list. I have tried to create a nested soql statement but am coming up with an error

Error: Compile Error: Initial term of field expression must be a concrete SObject: LIST<Lead> at line 416 column 44

 

Here is my Code:

    public List<SelectOption> getowneritems(){
        List<SelectOption> options = new List<SelectOption>();
        options.add(new SelectOption( '1', 'SELECT' ));
        for( Campaign c:getactiveCampaigns()){
            options.add( new SelectOption( lead.ownerid, c.leadowner.name));
        }
        return options;


    public List<Campaign> getactiveCampaigns(){
        if( activeCampaigns == null ){
            activeCampaigns = [select id, (select lead.Ownerid, Contact.ownerid from CampaignMembers),
            Name, Ownerid, Owner.id, owner.name
            From Campaign where isActive = true and
            Include_in_Campaign_Call_Down__c = true order by name LIMIT 100];
        }
        return activeCampaigns;
    }

 

 

How can I fix this?

Thank you

In this workflow I have created a new record from the creation of an opportunity product record in a separate trigger. After the creation of the second record, I am needing to update the opportunity product record with the lookup value. With opportunity product records I can unable to use the object in a UI lookup field. I am receiving the following error:

 

Compile Error: Expression cannot be assigned at line -1 column -1  

 

Here is the trigger:

trigger LinkonOLI on Manufacturing_Design_Sheet__c (after insert) {

   Set<Id> mids = new set<Id>();
   for(Manufacturing_Design_Sheet__c m : trigger.new){
   mIds.add(m.OpportunityLineItemID__c);
   
   }
    System.debug('****1 : m Id size '+ mIds.size());

    List<Manufacturing_Design_Sheet__c> mds = [SELECT Id, name, OpportunityLineItemID__c
     FROM Manufacturing_Design_Sheet__c  
        WHERE createddate =: system.now() and createdbyId = :UserInfo.getUserId() limit 1]; 
       
  
    If(OpportunityLineItem.id = Manufacturing_Design_Sheet__c.OpportunityLineItemID__c){
     OpportunityLineItem.spec_sheet__c = Manufacturing_Design_Sheet__c.OpportunityLineItemID__c;
   }
}      

 

How do I solve the error?

 

Thank you,

I am working on a trigger that will create a custom object record when a product is add to the Opportunity, where the product name will be copied to the custom record. I qwould like the product name be the name of the custom record, but the system is returning the record id in the name field. Here is my code:

 

trigger newSpecSheet on OpportunityLineItem (after Insert) {
    List<Manufacturing_Design_Sheet__c> mds = new List<Manufacturing_Design_Sheet__c>();
    for (OpportunityLineItem oli: Trigger.new) {
        if(Pricebookentry.id != null) {
        mds.add(new Manufacturing_Design_Sheet__c (
            Name = oli.Pricebookentry.Product2.name,
            Opportunity_Name__c = oli.Opportunityid,
            RecordTypeId = '012500000001COp',
            Quotation_Item_Number__c = 1));
        
        }
    }
    insert mds;
} 

How do I put the name of the product in the name field on the custom record?

Thank you

I am working in a Custom Opportunity Clone and am trying to clone the Sales Team when I recieve the following error when I click the clone button:

System.DmlException: Insert failed. First exception on row 0 with id 00q50000002eoQZAAY; first error: INVALID_FIELD_FOR_INSERT_UPDATE, cannot specify Id in an insert call: [Id]



Class.OpportunityCloneWithItemsController.MyClone: line 94, column 14 External entry point 

 

Here is the code in question to clone the sales team:

             // copy over the Opportunity Sales Team - ONLY INCLUDE THE FIELDS YOU WANT TO CLONE
             List<OpportunityTeamMember> team= new List<OpportunityTeamMember>();
             for (OpportunityTeamMember otm : [Select id, TeamMemberRole,OpportunityAccessLevel, 
                  Userid, opportunity.id From OpportunityTeamMember where Opportunity.id = :o.id]) {
                  OpportunityTeamMember newotm = otm.clone(true);
                  newotm.opportunity = otm.Opportunity;
                  team.add(newOtm);
             }
             insert team;
      

 

Here is the entire code:

 

public with sharing class OpportunityCloneWithItemsController {

    //added an instance varaible for the standard controller
    private ApexPages.StandardController controller {get; set;}
     // add the instance for the variables being passed by id on the url
    public Opportunity o {get;set;}
    // set the id of the record that is created -- ONLY USED BY THE TEST CLASS
    public ID newRecordId {get;set;}


    public OpportunityCloneWithItemsController(ApexPages.StandardController controller) {

        //this.controller = controller;

        // load the current record
        o = (opportunity) controller.getRecord();
        system.debug('********** ' + o);
    }
    
    // method called from the VF's action attribute to clone the Opportunity
    public PageReference MyClone() {
 
         // setup the save point for rollback
         Savepoint sp = Database.setSavepoint();
         Opportunity o;
         Opportunity newO;
 

              //copy the Opportunity - ONLY INCLUDE THE FIELDS YOU WANT TO CLONE
             o = [select 
                     Name, 
                     Estimated_Cost__c, 
                     Margin__c, 
                     Competitor_Primary__c,
                     Competitor_Secondary__c, 
                     Account_Shipping_Location__c, 
                     Amount, 
                     INCO_Terms__c,             
                     Related_Location__c, 
                     Language_to_prepare_docs_in__c, 
                     Campaignid, 
                     Equipment__c,             
                     Parent__c, 
                     Equip_Services_Options_to_be_quoted__c, 
                     Lead_Time_Ex_Works__c, 
                     Op_Market_Position__c,             
                     Product_1__c, 
                     Product1_condition__c, 
                     Product1_Line_Capacity__c, 
                     Product1_Bulk_density__c,
                     Product1_defect_description__c, 
                     Product_2__c, 
                     Product_2_Condition__c, 
                     Product_2_Line_Capacity__c,
                     Product_2_Bulk_Density__c, 
                     Product_2_Defect_Description__c, 
                     Description, 
                     PS__c, 
                     Farmco__c,
                     Service_Contract__c, 
                     Potato__c, 
                     Processed_Fruit_Veg__c, 
                     AIS__c, 
                     Project_System_Eng__c, 
                     Freshline__c,
                     Spare_Parts__c, 
                     Pharma__c, 
                     Misc_Other__c, 
                     CloseDate, 
                     StageName, 
                     AccountId,
                     OwnerID from Opportunity where ID = :this.o.ID];
             newO = o.clone(false);

    newO.Name = 'Cloned - ' + o.Name;
    newO.StageName = 'Prospecting';
    newO.CloseDate = o.CloseDate + 700;
    
             insert newO;
         System.debug('******* ID: ' + newO.ID);
    
    //Reset the Opp ID and resset fields to default values

    

             // copy over the Opportunity Sales Team - ONLY INCLUDE THE FIELDS YOU WANT TO CLONE
             List<OpportunityTeamMember> team= new List<OpportunityTeamMember>();
             for (OpportunityTeamMember otm : [Select id, TeamMemberRole,OpportunityAccessLevel, 
                  Userid, opportunity.id From OpportunityTeamMember where Opportunity.id = :o.id]) {
                  OpportunityTeamMember newotm = otm.clone(true);
                  newotm.opportunity = otm.Opportunity;
                  team.add(newOtm);
             }
             insert team;
      


     return new PageReference('/'+newO.id+'/e?retURL=%2F'+newO.id);
   return new PageReference('/'+  newO.Id);

    }

}

 

How do I solve this error?

 

Thank you

I have been working on a custom pdf page with CSS for quite a while and have not been able to standardize spacing between text lines within a mult-line field (billing address). What do I need to change to add the uniform spacing? I have not moved my css into an external style sheet, though I plan to.

 

 

My challenge is with this portion of the page:

 

                <apex:outputField value="{!quote.BillingAddress__c}" styleClass=" header3" />
                <apex:outputField value="{!quote.Created_Date__c}" />
                <span style="margin-left:-176px; margin-top: 500px;">
                <apex:outputLabel value="">
                <apex:outputField value="{!quote.BillingAddress2__c}"/>
                </apex:outputLabel>
                                </span>
                <span style="float:left; margin-left:0px; margin-top:-15px;">
                <apex:outputField value="{!quote.ExpirationDate}"/>
                                </span>
                <span style="float:left; margin-left:-176px; margin-top:-15px; z-index:-8;">
                <apex:outputLabel value="">
                <apex:outputfield value="{!quote.BillingCountry}"/>
                </apex:outputLabel>
                </span>   

 

 

 

 

Here is the entire visualforce page. I am not including the apex controllers as they are not applicable for this question.

 

<apex:page standardController="Quote" extensions="dataTableCons" standardstylesheets="false" renderAs="pdf" showHeader="false">
<head>
<style>
body { font-family: Arial Unicode MS; font-size: 10 px; } 

h3 {
    display:block; width:637px; padding:0; background:#ADD8E6;
    font-size:12px; line-height:23px; text-align:left; font-weight:normal;
}
h4 {
    display:block; width:637px; padding:0; 
    font-size:10px; line-height:12px; text-align:left; font-weight:normal;
}
h5 {
    display:block; width:637px; padding:0; 
    font-size:8px; line-height:12px; text-align:right; font-weight:normal;
}

.header
{
 width: 367x;
 height: 5px;
 background-color: gray;
 color: White;
 font-size:8pt;
 text-align: left;
 padding-left: 5px;
}
.header1
{
 width: 15px;
 height: 5px;
 background-color: gray;
 color: White;
 font-size:8pt;
 text-align: right;
 padding-left: 10px;
}
.header2
{
 width: 65px;
 background-color: gray;
 height: 5px;
 color: White;
 font-size:8pt;
 text-align: right;
 padding: 5px;
}

.tabletop {
    display:block; width:630px; height:5px; 
    background:transparent url(images/top.gif) no-repeat scroll 0 0;
    margin:0 0 0 4px;
}
.tablebk {
    width:615px;
    background:transparent url(images/middle.gif) repeat-y scroll 0 0;
    margin:0 0 0 4px; padding:0 0 0 15px;
}
.tablebottom {
    display:block; width:630px; height:16px; 
    background:transparent url(images/bottom.gif) no-repeat scroll 0 0;
    margin:0 0 0 4px;
}

table {table-layout:fixed; border-collapse:collapse; border-spacing:0; }

th {
    color:#fff; 
    font-size:14px; line-height:10px;
    padding:5px 6px 8px;
    vertical-align:top;
}
td {
    
    font-size:10px; line-height:10px;
    padding:3px;
    vertical-align:top;
}
th.col1,
td.col1 {text-align:left;}
.odd td {background-color:#f2f7fa;}

td input {
    width:85px; height:22px;
    font-size:14px; line-height:16px; font-weight:bold; text-align:left;
    padding-top:3px;
    border:null;
}

tr:hover td {background-color:#599bbd;} /* hover state does not work in ie6 */

/* table1 */
.table1 th.col1 {width:176px; }
.table1 th.col2 {width:181px;}
.table1 th.col3 {width:173px;}
.table1 td {padding-bottom:5px;}
.table1 td.col3 {padding-top:6px; padding-left:19px;}

/* table2 */
.table2 th.col1 {width:176px;}
.table2 th.col2 {width:181px;}
.table2 th.col3 {width:173px;}

/* table3 */
.table3 th.col1 {width:128px;}
.table3 th.col2 {width:153px;}
.table3 th.col3 {width:130px;}
.table3 th.col4 {width:95px;}
.table3 td {padding-bottom:5px;}
.table3 td.col4 {padding-top:6px; padding-left:19px;}
/* END Table CSS */


</style>
</head>

    <apex:form id="theForm">  
       <apex:pageBlock tabStyle="account">
            <apex:pageMessages />
         <apex:image url="/resource/1272645408000/Key_Logo" width="20%" height="20%"/>
           <Table class="table">
           <apex:pageBlockSection title="Essential Information" columns="2"  showHeader="false">
                <apex:outputField value="{!quote.Opportunity.AccountId}" styleClass="line-height='133px'" />
                <apex:outputField value="{!quote.quotenumber}" />
                <apex:outputField value="{!quote.BillingAddress__c}" styleClass=" header3" />
                <apex:outputField value="{!quote.Created_Date__c}" />
                <span style="margin-left:-176px; margin-top: 500px;">
                <apex:outputLabel value="">
                <apex:outputField value="{!quote.BillingAddress2__c}"/>
                </apex:outputLabel>
                                </span>
                <span style="float:left; margin-left:0px; margin-top:-15px;">
                <apex:outputField value="{!quote.ExpirationDate}"/>
                                </span>
                <span style="float:left; margin-left:-176px; margin-top:-15px; z-index:-8;">
                <apex:outputLabel value="">
                <apex:outputfield value="{!quote.BillingCountry}"/>
                </apex:outputLabel>
                </span>                
             </apex:pageBlockSection>

            <apex:pageBlockSection title="Contact Info" showHeader="true" >
                <apex:outputField value="{!quote.contactid}"/>
                <apex:outputField value="{!quote.Phone}"/>
                <apex:outputField value="{!quote.email}"/>
                <apex:outputField value="{!quote.fax}"/>
             </apex:pageBlockSection>

            </Table>

       </apex:pageBlock>
       
       </apex:form>

    <apex:pageBlock >
    <apex:pageBlockSection columns="2">
      <apex:dataTable value="{!Quote.QuoteLineItems}" rowClasses="even,odd," var="line"  width="630">
        <apex:column style="text-align:right;" headerClass="header1" headerValue="Item">
        <apex:facet name="Item">Item</apex:facet>
        <apex:outputText value="{!line.Quote_Item_Number__c}"/>
        </apex:column>  

        <apex:column style="text-align:left;
            border-left-style:solid; border-left-color:black;
            border-left-width:.25px;"
          headerClass="header" headerValue="Product">
        <apex:facet name="header">Product</apex:facet>
        <apex:outputText value="{!line.PriceBookentry.name}"/>
        </apex:column>        
        <apex:column style="text-align:right;
            border-left-style:solid; border-left-color:black;
            border-left-width:.25px;" headerClass="header2" headerValue="Quantity">
        <apex:facet name="header">Quantity</apex:facet>
        <apex:outputText value="{!line.Quantity}"/>
        </apex:column>
    <apex:column style="text-align:right;
            border-left-style:solid; border-left-color:black;
            border-left-width:.25px;" headerClass="header2" headerValue="Price Each">
        <apex:facet name="header">Price Each</apex:facet>
        <apex:outputText value="{!line.ListPrice}"/>
        </apex:column>
    <apex:column style="text-align:right;
            border-left-style:solid; border-left-color:black;
            border-left-width:.25px;" headerClass="header2" headerValue="Price Each">
        <apex:facet name="header">SubTotal</apex:facet>
        <apex:outputText value="{!line.Subtotal}"/>
        </apex:column>        
      </apex:dataTable>
      </apex:pageBlockSection>
   </apex:pageBlock>
  
        <apex:form >      
       <apex:pageBlock >
       <apex:pageBlockSection columns="2">
       <apex:inputhidden />
       <apex:inputhidden />
       <apex:inputhidden />
       <apex:outputField value="{!quote.Grand_Total__c}" style="h5" />
       </apex:pageBlockSection>

       </apex:pageBlock>
       <apex:pageBlock >
       <h4>
       This quotation is provided for budgetary planning purposes only. 
       This is not an official offer of sale, orders cannot be placed against this budget quotation. 
       Once project details have been fully defined, a final detailed quotation will be submitted.
       </h4>
       </apex:pageBlock> 
      </apex:form>

</apex:page>

 

In the test class that I am writing I am recieving the following error:

 

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

Class.testForecastOverride.TestOverrideTrigger: line 12, column 9 External entry point 

 

Below is my test class:

 

@isTest
private class testForecastOverride {

     testmethod private static void TestOverrideTrigger() {

    Opportunity o;

    id id1 = userinfo.getProfileId();
    Map <Id, Opportunity> opp = new map <id, Opportunity>();
    If (id1 == '00e30000000gAk7') {
    
        o.ForecastCategoryName = o.Forecast_Category_Override__c;
       }
       else if (id1 == '00eQ0000000HivN') {

        o.ForecastCategoryName = o.Forecast_Category_Override__c;
       } else if (id1 == '00e30000000gl0u') {
        o.ForecastCategoryName = o.Forecast_Category_Override__c;
       }
    }

}

 

Below is my trigger

trigger ForecastOverride on Opportunity (Before Update) {

    Set<Id> bIds = new Set<Id>();
    
    for(Opportunity op : trigger.new){
    System.debug('**** 0 op id : '+op.ForecastCategoryName);
    bids.add(op.id);
   }     
    list<Opportunity> forecastcategoryList = new List<Opportunity>();
    
    if(StaticClass.doNotExecute ==true)
{
    system.debug('Inserting'+StaticClass.doNotExecute);
    for(Opportunity o:trigger.new)
    {
     bIds.add(o.id);
     
    id id1 = userinfo.getProfileId();
    If (id1 == '00e30000000gAk7') {
    if (trigger.new[0].Forecast_Category_Override__c != trigger.old[0].Forecast_Category_Override__c)
     {
        o.ForecastCategoryName = o.Forecast_Category_Override__c;
        
        }
       }
       else if (id1 == '00eQ0000000HivN') {
    if (trigger.new[0].Forecast_Category_Override__c != trigger.old[0].Forecast_Category_Override__c)
     {
        o.ForecastCategoryName = o.Forecast_Category_Override__c;
        
        }
       } else if (id1 == '00e30000000gl0u') {
    if (trigger.new[0].Forecast_Category_Override__c != trigger.old[0].Forecast_Category_Override__c)
     {
        o.ForecastCategoryName = o.Forecast_Category_Override__c;
        
        }
       }
    }
}
}

 

 

I believe I am needing to write a map/list of the opportunity in the test class, but how do I do this?

 

Thank you again for your help

I am working on a visualforce page that provides a search field and returns the results on the same page. I have two problems with the search field.

 

1. The search box can only be used once for each time the page loads. How do I change this to allow the user keep using the same page without manually refreshing the entire page? I have not found any discussions on this, so I don't have code to post that is not working.

 

2.  The second question I have does have some code that I have started. I am trying to program the search field allow the user hit enter on the keyboard to search rather than having to click the search button. Here is my Javascript&colon;

 

button:

                <apex:commandButton value="Search" action="{!Search}" rerender="table"/>

 

javascript&colon;

<script> 
    function noenter(ev)  {
        if (window.event && window.event.keyCode == 13 || ev.which == 13) {
            Search();
            return false;
         } else {
              return true;
         }
     }

</script>

 

 

What do I need to change for this to work?

 

Thanks

I am working on a project where I have a visualforce page opening from the opportunity to pick records from the customer product custom object and copying the record into object B and referencing the opportunity page. I am trying to pull the opportunity id onto the Visualforce page. I have been scouring the discussion boards and the new. All I could file is the Janascript code to go to the previous page for IE and have been playing with some sample code.

 

 public PageReference GoBack() {
  String previousPage = System.currentPageReference().getParameters().get(​history.go(-1));
    PageReference newPage = new PageReference(previousPage);
    newPage.setRedirect(true);
    return newPage;
  }

 

I know the above code is a shot in the dark. Can anyone help and point me in the right direction?

I m trying to create a vf page where the  user will search for records and add them to the opportunity. This functionality is similar to tstandard automation of adding products to the opportunity. When I attempt to add the cutom controller I recieve the following error: "Unknown Property" "String.Selected."

 

Here is my Visualforce  page

<apex:page controller="customerwrapperClassController" > 
<!-- Javascript function to check all rows in the table --> 
<script> 
function checkAll(cb) 
{ 
var inputElem = document.getElementsByTagName("input"); 
for(var i=0;i<inputElem.length;i++) 
{ 
if(inputElem[i].id.indexOf("selectLine1")!=-1) 
inputElem[i].checked = cb.checked; 
} 
} 
</script> 
<!-- End of Javascript function --> 
<apex:form > 
<apex:sectionHeader title="Step 1" subtitle="Select Contacts to send Email"/> 
<apex:pageblock > 
<apex:pageBlockSection title="Search Contacts" columns="1"></apex:pageBlockSection> 

<!-- Div to give a colored box effect --> 

<div style="border-width:2px;border-style:solid;border-color:orange;"> 

<!-- Panel grid to display boxes o accept user input values --> 
<apex:panelGrid columns="2"> 
<apex:outputLabel style="font-weight:bold;" value="Contact E-mail" ></apex:outputLabel> 
<apex:inputText value="{!userinput}"/> 
<apex:outputLabel style="font-weight:bold;" value="Contact Name" ></apex:outputLabel> 
<apex:inputText value="{!userinp}"/> 
</apex:panelGrid> 
<!-- End of panelgrid --> 
<!-- Div to position the commandbutton appropriately --> 
<div style="position:relative;left:75px;"> 
<apex:commandButton value="Search" action="{!contactsearch}" /> 
</div> 
<!-- End of div --> 
<br/> 
</div> 

<!-- End of colored box div --> 
<br/> 
<!-- Display error message --> 
<apex:pagemessage strength="2" title="Error!!" severity="error" detail="Please select a contact or enter email address to proceed" rendered="{!errormsg}"/> 
<!-- End of error message --> 

<!-- Display search results --> 
<apex:pageblocksection columns="1" title="Search results" rendered="{!NOT(ISNULL(results))}" > 
<apex:outputpanel id="Contactlist"> 

<apex:pageBlockTable value="{!results}" var="contacts"> 
<apex:column > 
<apex:facet name="header"> 
<apex:inputCheckbox onclick="checkAll(this)"/> 
</apex:facet> 
<apex:inputCheckbox value="{!contacts.selected}" id="selectLine1"/> 
</apex:column> 
<apex:column headervalue="Contact Name"> 
<apex:outputtext value="{!contacts.con.Name}"/> 
</apex:column> 
<apex:column headervalue="Account Name"> 
<apex:outputtext value="{!contacts.con.Account.Name}"/> 
</apex:column> 
<apex:column headervalue="Title"> 
<apex:outputtext value="{!contacts.con.Title}"/> 
</apex:column> 
</apex:pageBlockTable> <br/><br/> 

</apex:outputpanel> 
</apex:pageblocksection> 
<!-- End of search results --> 

<!-- Commandbutton to proceed to next screen --> 
<div style="position:relative;left:75px;"> 
<apex:commandButton value="Next" action="{!processSelected}"/> 
<apex:commandbutton value="Cancel" action="{!Cancel}"/> 
</div> 
<!-- End of Commandbutton --> 
</apex:pageblock> 
</apex:form> 
</apex:page> 

 

Here is my controller:

public class customerwrapperClassController {
    public String results { get; set; }

    public String errormsg { get; set; }

    public PageReference contactsearch() {
        return null;
    }


    public String userinp { get; set; }

    public String userinput { get; set; }

    public customerwrapperClassController() {

    }


    public customerwrapperClassController(ApexPages.StandardController controller) {

    }



    //Our collection of the class/wrapper objects Customer_Product_List_Item__c 
    public List<Customer_Product__c> productList {get; set;}
    
    //This method uses a simple SOQL query to return a List of Contacts
    public List<Customer_Product__c> getproduct(){
        if(productList== null){
            productList= new List<Customer_Product__c>();
        
            for(Customer_Product__c c : [select Id, Name from Customer_Product__c]){
                /* As each contact is processed we create a new Customer_Product_List_Item__c object and
                add it to the productList*/
                productList.add(c);
            }
        }
        return productList;
    }
    public PageReference processSelected(){
        /*We create a new list of Contacts that we be populated only with Contacts
        if they are selected*/
        List<Customer_Product__c> selectedProducts = new List<Customer_Product__c>();
        
        /*We will cycle through our list of cContacts and will check to see if the 
        selected property is set to true, if it is we add the Contact to the 
        selectedContacts list. */
        for(Customer_Product__c cCon: getproduct()){
            if(cCon.selected__c == true){
            //    selectedCustomer_Product__c.add(cCon.id);
            }
            }
         
        /* Now we have our list of selected contacts and can perform any type of 
        logic we want, sending emails, updating a field on the Contact, etc */
        System.debug('These are the selected Contacts...');
        for(Customer_Product__c con: selectedProducts){
            system.debug(con);
        }
        return null;
    }
 
    /* This is our wrapper/container class. A container class is a class, a data 
    structure, or an abstract data type whose instances are collections of other 
    objects. In this example a wrapper class contains both the standard salesforce 
    object Contact and a Boolean value */
    public class cCustomer {
        public Customer_Product__c con {get; set;}
        public Boolean selected {get; set;}
        
        /*This is the contructor method. When we create a new cContact object we pass a 
        Contact that is set to the con property. We also set the selected value to false*/
        public cCustomer(Customer_Product__c c){
            con = c;;
        }

 

Note: comments have not been updated to the custom object specifics, but is patterned after the wrapper class example. http://wiki.developerforce.com/index.php/Wrapper_Class

 

How do I solve this error? Thanks

 

I am working on a visualforce page customizing the quote page layout with the quote line items. I am adapting the script from the Creating Compount Views turtorial on the wiki.

 

I am recieving the following error message:

Error: Compile Error: Return value must be of type: LIST<Quote> at line 9 column 9  

 

Below is my controller code:

 

public class MyConsoleController {
    public MyConsoleController() {

   }
 
    public Quote selectedQuote { get; set; }  
     
    public Quote[] getQuote() {
        return [SELECT id, Name, QuoteNumber, Created_Date__c, quote.Opportunity.AccountId, Quote_Line_Item__c,
                    Grand_Total__c,BillingAddress__c, BillingAddress2__c FROM Quote where id = :ApexPages.currentPage().getParameters().get('id')];
    
    }


    public QuoteLineItem[] getQuoteLineItems() {
        return [SELECT Id, PriceBookEntry.name, Quote__r.Grand_Total__c, QuoteID, Quantity, Quote_Item_Number__c, TotalPrice, ListPrice FROM QuoteLineItem
        WHERE QuoteId = :ApexPages.currentPage().getParameters().get('Id') order by Quote_Item_Number__c Asc];}

}

My questions:

 

1. What am I doing wrong in this controller?

2. What needs to be changed?

 

Thank you

I have the following class to order the quotelineitem related list(datatable).

 

public class orderedLineItems { 
       public Id quoteID {get; set;}
               List<QuoteLineItem> lineItems;
                public List<QuoteLineItem> getlineItems(){
            if(lineItems == null){
                /*Using dyanamic apex and SOQL you could set this up to query all*/
                lineItems = [select Id, PricebookEntry.Name, Quantity, UnitPrice, TotalPrice from QuoteLineItem where QuoteID =:QuoteID];
                lineItems = sortLines(lineItems);
            }
            return lineItems;
        }
        
        private static List<QuoteLineItem> sortLines(List<QuoteLineItem> olis) {
            List<QuoteLineItem> resultList = new List<QuoteLineItem>();
        
            /* Create a map of amount to Opportunity collection */
            Map<String, List<QuoteLineItem>> oliMap = new Map<String, List<QuoteLineItem>>();
            
            for(QuoteLineItem oli : olis) {
                if(oliMap.get(oli.PricebookEntry.Name) == null){ 
                    oliMap.put(oli.PricebookEntry.Name, new List<QuoteLineItem >()); 
                }
                oliMap.get(oli.PricebookEntry.Name).add(oli);
            }
            
            List<String> keys = new List<String>(oliMap.keySet());
            
            /* Leverage the standard, primitive collection sort method */
            keys.sort();
            
            for(String key:keys){ 
                resultList.addAll(oliMap.get(key)); 
            }
            
            return resultList;
        }
}

 

 

Here is my visualforce page:

 

<apex:page standardController="Quote" standardstylesheets="false" renderAs="pdf" showHeader="false">
<head>
<style>
body { font-family: Arial Unicode MS; font-size: 10 px; } 

h3 {
    display:block; width:637px; padding:0; background:#ADD8E6;
    font-size:12px; line-height:23px; text-align:left; font-weight:normal;
}
h4 {
    display:block; width:637px; padding:0; 
    font-size:10px; line-height:12px; text-align:left; font-weight:normal;
}
h5 {
    display:block; width:637px; padding:0; 
    font-size:8px; line-height:12px; text-align:right; font-weight:normal;
}

.header
{
 width: 367x;
 height: 5px;
 background-color: gray;
 color: White;
 font-size:8pt;
 text-align: left;
 padding-left: 5px;
}
.header1
{
 width: 15px;
 height: 5px;
 background-color: gray;
 color: White;
 font-size:8pt;
 text-align: right;
 padding-left: 10px;
}
.header2
{
 width: 65px;
 background-color: gray;
 height: 5px;
 color: White;
 font-size:8pt;
 text-align: right;
 padding: 5px;
}

.tabletop {
    display:block; width:630px; height:5px; 
    background:transparent url(images/top.gif) no-repeat scroll 0 0;
    margin:0 0 0 4px;
}
.tablebk {
    width:615px;
    background:transparent url(images/middle.gif) repeat-y scroll 0 0;
    margin:0 0 0 4px; padding:0 0 0 15px;
}
.tablebottom {
    display:block; width:630px; height:16px; 
    background:transparent url(images/bottom.gif) no-repeat scroll 0 0;
    margin:0 0 0 4px;
}

table {table-layout:fixed; border-collapse:collapse; border-spacing:0; }

th {
    color:#fff; 
    font-size:14px; line-height:10px;
    padding:5px 6px 8px;
    vertical-align:top;
}
td {
    
    font-size:10px; line-height:10px;
    padding:3px;
    vertical-align:top;
}
th.col1,
td.col1 {text-align:left;}
.odd td {background-color:#f2f7fa;}

td input {
    width:85px; height:22px;
    font-size:14px; line-height:16px; font-weight:bold; text-align:left;
    padding-top:3px;
    border:null;
}

tr:hover td {background-color:#599bbd;} /* hover state does not work in ie6 */

/* table1 */
.table1 th.col1 {width:176px; }
.table1 th.col2 {width:181px;}
.table1 th.col3 {width:173px;}
.table1 td {padding-bottom:5px;}
.table1 td.col3 {padding-top:6px; padding-left:19px;}

/* table2 */
.table2 th.col1 {width:176px;}
.table2 th.col2 {width:181px;}
.table2 th.col3 {width:173px;}

/* table3 */
.table3 th.col1 {width:128px;}
.table3 th.col2 {width:153px;}
.table3 th.col3 {width:130px;}
.table3 th.col4 {width:95px;}
.table3 td {padding-bottom:5px;}
.table3 td.col4 {padding-top:6px; padding-left:19px;}
/* END Table CSS */


</style>
</head>

    <apex:form id="theForm">  
       <apex:pageBlock tabStyle="account">
            <apex:pageMessages />
         <apex:image url="/resource/1272645408000/Key_Logo" width="20%" height="20%"/>
           <Table class="table">
           <apex:pageBlockSection title="Essential Information" columns="2"  showHeader="false">
                <apex:outputField value="{!quote.Opportunity.AccountId}" />
                <apex:outputField value="{!quote.quotenumber}" />
                <apex:outputField value="{!quote.BillingAddress__c}" />

                <apex:outputField value="{!quote.Created_Date__c}" />
                <span style="margin-left:-176px; margin-top:-500px; z-index:-1;">
                <apex:outputLabel value="">
                <apex:outputField value="{!quote.BillingAddress2__c}"/>
                </apex:outputLabel>
                                </span>
                <span style="float:left; margin-left:0px; margin-top:-16px;">
                <apex:outputField value="{!quote.ExpirationDate}"/>
                                </span>
                <span style="float:left; margin-left:-176px; margin-top:-6px; z-index:-8;">
                <apex:outputLabel value="">
                <apex:outputfield value="{!quote.BillingCountry}"/>
                </apex:outputLabel>
                </span>                
             </apex:pageBlockSection>

            <apex:pageBlockSection title="Contact Info" showHeader="true" >
                <apex:outputField value="{!quote.contactid}"/>
                <apex:outputField value="{!quote.Phone}"/>
                <apex:outputField value="{!quote.email}"/>
                <apex:outputField value="{!quote.fax}"/>
             </apex:pageBlockSection>

            </Table>
       </apex:pageBlock>
       
       </apex:form>

    <apex:pageBlock >
    <apex:pageBlockSection columns="2">
      <apex:dataTable value="{!Quote.QuoteLineItems}" rowClasses="even,odd," var="line" width="630">
        <apex:column style="text-align:right;" headerClass="header1" headerValue="Item">
        <apex:facet name="header1">Item</apex:facet>
        <apex:outputText value="{!line.Quote_Item_Number__c}" />
        </apex:column>
        <apex:column style="text-align:left;
            border-left-style:solid; border-left-color:black;
            border-left-width:.25px;"  headerClass="header" headerValue="Product">
        <apex:facet name="header">Product</apex:facet>
        <apex:outputText value="{!line.PriceBookentry.name}" />
        </apex:column>        
        <apex:column style="text-align:right;
            border-left-style:solid; border-left-color:black;
            border-left-width:.25px;" headerClass="header2" headerValue="Quantity">
        <apex:facet name="header">Quantity</apex:facet>
        <apex:outputText value="{!line.Quantity}"/>
        </apex:column>
    <apex:column style="text-align:right;
            border-left-style:solid; border-left-color:black;
            border-left-width:.25px;" headerClass="header2" headerValue="Price Each">
        <apex:facet name="header">Price Each</apex:facet>
        <apex:outputText value="{!line.ListPrice}"/>
        </apex:column>
    <apex:column style="text-align:right;
            border-left-style:solid; border-left-color:black;
            border-left-width:.25px;" headerClass="header2" headerValue="Price Each">
        <apex:facet name="header">SubTotal</apex:facet>
        <apex:outputText value="{!line.Subtotal}"/>
        </apex:column>        
      </apex:dataTable>
      </apex:pageBlockSection>
   </apex:pageBlock>
  
        <apex:form >      
       <apex:pageBlock >
       <apex:pageBlockSection columns="2">
       <apex:inputhidden />
       <apex:inputhidden />
       <apex:inputhidden />
       <apex:outputField value="{!quote.Grand_Total__c}" style="h5" />
       </apex:pageBlockSection>

       </apex:pageBlock>
       <apex:pageBlock >
       <h4>
       This quotation is provided for budgetary planning purposes only. 
       This is not an official offer of sale, orders cannot be placed against this Budget quotation. 
       Once project details have been fully defined, a final detailed quotation will be submitted.
       </h4>
       </apex:pageBlock> 
      </apex:form>

</apex:page>

 

Does my class order the quotelineitems by? ItemNumber? What am I missing? How do I attach this onto the visualforce page?

 

Thank you,

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 am working on a trigger to redirect a lookup based on a picklist value (field: Measurement system with values 'english' and 'metric'. The intended, finished workflow will be when the user has chosen one of the two values and clicks save, the system will repopulate the lookup with the appropriate record based on the original value.

 

Logially, the system will look up the value based on the product, metric family, and the new value converted from the original value multiplied by the conversion rate.

 

The specific field names are:

 

The obje4ctive is to change the Bulk Density according to the Customer Product and the Measurement System. The converted rate will be applied the original Bulk Density to determine the new bulk density. The bulk density field is a lookup.

 

Below is my code:

 

trigger BulkDensityChange on Opportunity(after insert, after update) {
    Set<id> cid = new Set<id>();
    for(Opportunity opp : Trigger.new) {
    System.debug('**** 0 cid id : '+opp.Customer_Product_1__c);
    
        cid.add(opp.Customer_Product_1__c);
    System.debug('**** 1 opp id : '+opp.id);
    }
    List<Customer_Bulk_Density__c> density = [select id, name, Customer_Product__c from Customer_Bulk_Density__c 
                                   Where Customer_Product__c in (
                                      select id from Customer_Product__c)];
                                      
    
 
}

 

Currently I have set up the list relationship between the customer product and  the customer bulk density. I am not sure I have done this correctly as I am trying to link the opportunity, customer product, and bulk density objects together.

 

I believe my next step is to calculate the converted amount from measurement 1 to measurement 2.

 

I would like to write the following:

 

If the new bulk density equals the old bulk density times the conversion rate and is related to the customer product, then populate.

 

The bulk densities will be prpopulated for both the metric and english measurements.

 

My questions are:

 

1. Have I started the trigger correctly, as I have described above?

2. How do I write the next part of the trigger to convert the bulk density values?

  • August 05, 2010
  • Like
  • 0