• bbosche
  • NEWBIE
  • 0 Points
  • Member since 2006

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 2
    Replies

This may seem so basic, but I must be missing the way to accomplish it. I need to set up one or more tables, with multiple fields, that can be referenced by all of my objects in Salesforce. How can I accomplish this? As it is right now, I've had to create multiple copies of the same table with a relationship to the places I need it, but that is a maintenance nightmare.

 

Thanks in advance.

 

Bob

I am using a Visualforce form page to gether information needed to quote our various types of products. Considering all of our various products, I only need to gather about 20 fields of information to define the required attributes to accurately quote any of them (limited example below). My challenge is that on a handful of attributes (fields) apply to any one product, and I do not want to be asking the user questions that do not apply to the product they want quoted.

 

How can I educate my one form to show or not show form fields based on a product code that is passed to the Visualforce form when it is generated?

 

I have looked at many Visualforce and apex samples, gone through the Componenet Reference, and attempted a number of approaches, but feel that I'm running in circles.

 

Record Type is not an appropriate choice, and dependint picklists would involve too many variables. I am hoping for some type of 'IF' or 'CASE' logic that is based on a table of include/exclude values for each product, but I am not sure how to make the IF or CASE piece work.

 

Thanks for your assistance.

 

<apex:page setup="false" showHeader="true" sidebar="true" standardController="Opportunity">
  <!-- Begin Default Content REMOVE THIS -->
    <apex:sectionHeader title="Request for Quote Questionnaire" subtitle="Complete **the following for a prompt and accurate quote for {!opportunity.Product_Code_List__c}"/>
    <!-- <apex:detail subject="{!opportunity.ownerId}" relatedList="false" title="false"/> -->
        <apex:form id="quoteRequestInfoForm">
            <apex:pageBlock title="quoteRequestInfo" mode="edit">
                <apex:pageBlockButtons >
                    <apex:commandButton action="{!save}" value="Save"/>
                    <apex:commandButton action="{!delete}" value="Delete"/>
                    <apex:commandButton action="{!cancel}" value="Cancel"/>
                    <apex:commandButton action="{!save}" value="Save and Request PM Assistance"/>
                    <apex:commandButton action="{!save}" value="Save and Submit Quote Request"/>
                </apex:pageBlockButtons>
                <apex:pageBlockSection columns="1">
                    <apex:inputField value="{!opportunity.Product_Code_List__c}"/>
                    <apex:inputField value="{!opportunity.Quote_Sub_Products__c}" />
                    <apex:inputField value="{!opportunity.QSmallest_Panel_Size__c}"/>
                    <apex:inputField value="{!opportunity.QHighest_Hole_Count__c}"/>
                    <apex:inputField value="{!opportunity.Q_Construction__c}" />
                    <apex:inputField value="{!opportunity.QCoppers__c}" />
                    <apex:inputField value="{!opportunity.QRequested_MCM__c}" />
                    <p>Additional Quote Instructions:</p>
                    <apex:inputTextarea cols="120" value="{!opportunity.Quote_Instructions__c}"/>
                </apex:pageBlockSection>
            </apex:pageBlock>
        </apex:form>
  <!-- End Default Content REMOVE THIS -->
</apex:page>

I am using a Visualforce form page to gether information needed to quote our various types of products. Considering all of our various products, I only need to gather about 20 fields of information to define the required attributes to accurately quote any of them (limited example below). My challenge is that on a handful of attributes (fields) apply to any one product, and I do not want to be asking the user questions that do not apply to the product they want quoted.

 

How can I educate my one form to show or not show form fields based on a product code that is passed to the Visualforce form when it is generated?

 

I have looked at many Visualforce and apex samples, gone through the Componenet Reference, and attempted a number of approaches, but feel that I'm running in circles.

 

Record Type is not an appropriate choice, and dependint picklists would involve too many variables. I am hoping for some type of 'IF' or 'CASE' logic that is based on a table of include/exclude values for each product, but I am not sure how to make the IF or CASE piece work.

 

Thanks for your assistance.

 

<apex:page setup="false" showHeader="true" sidebar="true" standardController="Opportunity">
  <!-- Begin Default Content REMOVE THIS -->
    <apex:sectionHeader title="Request for Quote Questionnaire" subtitle="Complete **the following for a prompt and accurate quote for {!opportunity.Product_Code_List__c}"/>
    <!-- <apex:detail subject="{!opportunity.ownerId}" relatedList="false" title="false"/> -->
        <apex:form id="quoteRequestInfoForm">
            <apex:pageBlock title="quoteRequestInfo" mode="edit">
                <apex:pageBlockButtons >
                    <apex:commandButton action="{!save}" value="Save"/>
                    <apex:commandButton action="{!delete}" value="Delete"/>
                    <apex:commandButton action="{!cancel}" value="Cancel"/>
                    <apex:commandButton action="{!save}" value="Save and Request PM Assistance"/>
                    <apex:commandButton action="{!save}" value="Save and Submit Quote Request"/>
                </apex:pageBlockButtons>
                <apex:pageBlockSection columns="1">
                    <apex:inputField value="{!opportunity.Product_Code_List__c}"/>
                    <apex:inputField value="{!opportunity.Quote_Sub_Products__c}" />
                    <apex:inputField value="{!opportunity.QSmallest_Panel_Size__c}"/>
                    <apex:inputField value="{!opportunity.QHighest_Hole_Count__c}"/>
                    <apex:inputField value="{!opportunity.Q_Construction__c}" />
                    <apex:inputField value="{!opportunity.QCoppers__c}" />
                    <apex:inputField value="{!opportunity.QRequested_MCM__c}" />
                    <p>Additional Quote Instructions:</p>
                    <apex:inputTextarea cols="120" value="{!opportunity.Quote_Instructions__c}"/>
                </apex:pageBlockSection>
            </apex:pageBlock>
        </apex:form>
  <!-- End Default Content REMOVE THIS -->
</apex:page>

I am attempting to implement a trigger that prevents duplicate contacts from being added.

 

Being a non developer (mere admin) I have download the app from the AppEx and although this gets me 90% of the way, I need to enhance the logic to include "Account Name". I have used a bit of trial and error (blantent guess work) but to no avail.

 

Below is the the apex trigger, but how do I include "Account"??

 

 

trigger ContactDuplicateTrigger on Contact (before insert) {
   for (Contact c : Trigger.new){
      
      Contact[] contacts= [select id from Contact where FirstName = :c.FirstName and LastName = :c.LastName and Email = :c.Email];
      
      if (contacts.size() > 0) {
          c.LastName.addError('Contact cannot be created - Contact already exists');
      }    
   }
}

 

Additionally I know that you need to test the trigger using an Apex Class, which of course I have, but wouldn't know how to tie in the changes above with below....if that makes sense.?!"

  

public class DuplicateContactTestClass {
   
   public static testMethod void testContactDuplicateTrigger() {
    Contact existingContact = new Contact(FirstName = 'John', LastName = 'Smith', Email = 'js@gmail.com');
    insert existingContact;
    
    Contact duplicateContact = new Contact(FirstName = 'John', LastName = 'Smith', Email = 'js@gmail.com');
    try {
       insert duplicateContact;
    }
    catch (Exception e) {
       System.debug('We want to see this.  This means the trigger is working.');
    } 
   }
}

 

 Help!!!

  • July 13, 2010
  • Like
  • 0