• impalacrazy69
  • NEWBIE
  • 0 Points
  • Member since 2013

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 16
    Questions
  • 24
    Replies
So i am looking to compare a picklist value to a name field where i take the value of the picklist and see if the name field contains that value. The formula works but however it only returns "match" when the name field is blank which is incorrect. Does anyone see what i am doing wrong.

IF(ISPICKVAL( Site__r.Support_Package__c , "Support") && CONTAINS("Support", Product__r.Name), "Match",
IF(ISPICKVAL( Site__r.Support_Package__c , "Enhanced") && CONTAINS("Enhanced", Product__r.Name), "Match",
IF(ISPICKVAL( Site__r.Support_Package__c , "Premium") && CONTAINS("Premium", Product__r.Name), "Match", "Different")))

Thanks.....
So below is the trigger created and then the test class. The error i am geting is: Method does not exist or incorrect signature:[createobjectcreator].CreateCase(SOBJECT:Account) and im not sure what this means. Does it not like me creating a case?

Trigger:

trigger Case_UpdateSiteInfo on Case (before update) {

Set<Id> siteIds = new Set<Id>();

// List<Site__c> results = new List<Site__c>();

    for (Case c : trigger.new) {
        siteIds.add(c.Site__c);
    }
   
//   
   
    if (siteIDs.size() > 0) {
       
        // Get all the cases and site fields we will need
       Map<Id, Site__c> siteFieldMap = new Map<Id, Site__c>(
        [SELECT Id, Status__c, Region_New__c, User__c
           FROM Site__c
             WHERE Id in :siteIds]
    );
       
        // Loop through cases and assign values                   
           for (Case c : trigger.new) {
        c.Site_Status__c    = siteFieldMap.get(c.Site__c).Status__c;
        c.Region__c         = siteFieldMap.get(c.Site__c).Region_New__c ;
        c.SE__c    = siteFieldMap.get(c.Site__c).User__c;
       
        // Run the update
//      if (siteIDs.size() > 0) update siteIds;
    }
   

       
    }
}

Test Class:

@isTest
private class Test_Case_UpdateSiteInfo {

    static testMethod void myUnitTest() {
    
      // TO DO: implement unit test
     
      // Create Account, contact, opportunity and Site using standard test objects
     createObjectCreator oc = new createObjectCreator();
    
     Account a = oc.CreateAccount();
     Case c = oc.CreateCase(a);
     Site__c s = oc.CreateSite(a);
   
    
     // Populate the Case Info
     c.ContactId = '003D000000stP8e';
     c.SE__c = '005c0000000pmUb';
     c.AccountId = a.Id;
     c.Site__c = s.Id;
     c.Version__c = 'Not Available';
     c.Severity__c = 'Low';
     c.Origin = 'Web';
     c.Subject = 'Testing 123';
        insert c;
    
    
     // Update the Site address
     c.Site__c = 'a012000000SWGT1';
     update c;
         
  
    
     // Run asserts to check that all fields updated
     Case assert = [SELECT Id, Status__c, Region_New__c, User__c FROM Site__c WHERE Id = :c.Id];
     System.assertEquals(c.Site_Status__c, assert.Status__c);
     System.assertEquals(c.Region__c, assert.Region_New__c);
     System.assertEquals(c.SE__c, assert.User__c);
         
    }
}
Can anyone help with a test class for the below trigger to sort and update cases by email. thx

trigger Case_NewEmailFromImperva on Case (before update) {

// Get a set of all FromAddress from trigger
Set<String> fromAddressSet = new Set<String>();
for (Case c : Trigger.new) {
  if (c.Imperva_Email_Added__c && c.Imperva_Email_Address__c != null) {
   fromAddressSet.add(c.Imperva_Email_Address__c);
  }
}

// Get a map of email to user/role
Map<String,User> emailUserMap = new Map<String,User>();
List<User> users = [SELECT Id, Username, UserRole.Name FROM User WHERE Username in :fromAddressSet];
for (User u : users) {
  emailUserMap.put(u.Username, u);
}

// Loop through and change status where needed
for (Case c : Trigger.new) {
  if (c.Imperva_Email_Added__c && c.Imperva_Email_Address__c != null) {
  
   // If they are not a solution manager, update the status to troubleshooting
   if (!emailUserMap.get(c.Imperva_Email_Address__c).UserRole.Name.contains('Solution Manager')) {
    c.Status = 'Troubleshooting';
   }
  
   // Either way, always unset the flag and address
   c.Imperva_Email_Added__c = false;
   c.Imperva_Email_Address__c = null;
  }
}
}
So here is my issue. I have a class that does a validation to check if things are oaky before user can convert the lead. What i am trying to do is check to see if the RSD ID listed on the territory object matches the Assigned to ID on the QSL object. Below is the code i have thus far but keep getting relationship error. can anyone help

// North America Territory assignment
     if (this.lead.Territory__c.Name == 'NA -*'){
    
      RSD = [Select ID,Regional_Sales_Director__c.Name from Territory__c where ID := Territory__c.Id];
      primeQ = [Select ID, Assigned_To__c.Name From QSL_Review_Request__c Where ID := QSL_Review_Request__c.ID];
    
      if (!isMatch(primeQ)){
       addError('Please update the lead owner to the correct queue. If this is a PRM lead or you need help, contact salesops@imperva.com');
       isValid = false;
     
      }
    
     }
Below is the code i have found and trying to use to update the products field on my case object. Id like to be able to change multiple cases while viewing a list to a certain product selection but im getting the error: ID not specified in an update call when i click the button. Can someone see what im missing for this simple update

{!REQUIRESCRIPT("/soap/ajax/13.0/connection.js")}

var caseObj = new sforce.SObject("Case");
caseObj.Id = '{!Case.Id}';
caseObj.Product__c = '{Product__c}';
var result = sforce.connection.update([caseObj]);

if (result[0].success=='false') {
alert(result[0].errors.message);
} else {
location.reload(true);
}
Afternoon,

I need soql help...
My requirements are as follows:

1. Check if it is in a North American Territory (including mid market)

2. If it is:   

a. Look at the Primary QSL.Assigned To field

b. Check that it matches the RSD/RSM on the Lead.Territory - Where im having the most trouble on how to do this

c. If there is a mismatch, display an error message "Please update the lead owner to the correct queue. If this is a PRM lead or you need help, contact salesops@imperva.com."

Below is the code i have but just looking i know its not working. I cant figure how to get my select statements correct. Can anyone help...

// North America Territory assignment
     if (this.lead.Territory__c.Name == 'NA -*'){
     
      RSD = [Select ID,Regional_Sales_Director__c.Name from Territory__c where ID := ];
      primeQ = [Select ID, Assigned_To__c.Name From QSL_Review_Request__c Where ID := ];
     
      if (RSD <> primeQ){
       addError('Please update the lead owner to the correct queue. If this is a PRM lead or you need help, contact salesops@imperva.com');
       isValid = false;
      
      }
     
     }

I have a trigger that was updated to handle bulk case closures and it works but when i deploy to production i get errors from other test classes what have nothing to do with my trigger. So i think i need to have a test created but am having trouble to create one. Here is the trigger i have created.

trigger pullSE on Case (before update, before insert) {
Set<id> userids=new Set<id>();
Map<id,string> siteMap=new Map<id,string>();
    for (case t: trigger.new) {

        try {
            if (t.SE__c == null) {
                userids.add(t.site__c);                
            }
        }
        catch (Exception e) {
        }
    }
	if(userids!=null){
		for(site__c s:[select id,user__c from site__c where id in:userids]){
			siteMap.put(s.id,s.user__c);
			}
		}
		for(case t:trigger.new){
			t.se__c=sitemap.get(t.site__c);
		}
	}

 

So i have the attached trigger on my case object. When trying to do a mahor upload we received the following errror:

 

System.LimitException: Too many SOQL queries: 101 Trigger.pullSE: line 5, column 1".

 

From reading other post it seems that i have to take the select statement out of the for loop. But my issue is that when i try its not pulling the information as it was. I tried <list> and <map> functions and nothing works so i have put it back to normal and now the code works again. Can anyone help me figure the best approach to get rid of the error.

 

Code:

trigger pullSE on Case (before update, before insert) {
    for (case t: trigger.new) {
        try {
            if (t.SE__c == null) {
                t.SE__c = [select User__c from Site__c where Id = :t.Site__c].User__c; //t.Site__r.User__c;
            }
        }
        catch (Exception e) {
        }
    }
}

 

Thanks....

Ive never really written a test class before so a little stuck trying to look at old ones to figure out what i need in order to test. Can anyone help. the class wont save saying the "Variable does not exist: tcontact.id"

 

@IsTest

public class Lead_Campaign_Mid_Market_Test{
static testMethod void testCampMember() {


// Create testing Camp, Lead, Contact and Campaign member data 
Campaign tCampaign = new Campaign(name='testcamp');
insert tCampaign;

Lead tlead = new Lead(FirstName='SaraTester',LastName='testing',Lead_Routing_Override__c = 'Mid Market', Trigger_Assignment_Rules__c = true);
insert tlead;

Contact tcontact = new Contact(FirstName='JimTester',LastName='testing');
insert tcontact;


CampaignMember tCampMemb = new CampaignMember(campaignId=tCampaign.id,leadId=tlead.id,contactId=tcontact.id,status='Responded');
insert tCampMemb;




}
}

 

So attached is my code in my controller that is looking to pull the account data using the lookup filed called Partner__c. For some reason nothing is being pulled over. Does anyone see what i am missing this seems so simple but is causing such a headache...

         public PageReference getresellerInfo (){ 
    	
  		Account a = [SELECT Id, Name, Phone, Account.BillingStreet, Account.BillingCity,   Account.BillingState, Account.BillingPostalCode, Account.BillingCountry
                     FROM Account
                     WHERE Id = :this.request.Partner__c];

   	 if(this.request.Partner__c != null){
            this.request.Company_Phone__c = a.Phone;
            this.request.Company_Address__c = a.BillingStreet;
            this.request.Company_City__c = a.BillingCity;
            this.request.Company_Postal__c = a.BillingPostalCode;
            this.request.Company_Country__c = a.BillingCountry;           
            this.request.Company_State__c = a.BillingState;
    	}
              
            system.debug('in the getresellerInfo method monkey balls 2');
    		  
            return null;
            
    		   	
    } 

 

So here is what i am trying to accomplish:

 

I need a trigger that basically does the following:

  1. Every time a CampaignMember object is created…
  2. Check if the GEO on the parent campaign is 'Mid Market'
  3. If it is, update the related lead:
    1. Set the Lead_Routing_Override__c field to be 'Mid Market'
    2. Set Trigger_Assignment_Rules__c to true

 

Here is what i have thus far but i feel i am missing someting becasuse my statement to see if the GEO code = Mid Market wont let me save the file.

 

trigger Lead_Campaign_Mid_Market on CampaignMember(after insert, after update) {

    List<Lead> ldlist;
    for(CampaignMember cmpmember: Trigger.new){
        if(
        cmpmember.LeadId !=null 
        //Campaign.GEO__c ='Mid Market'
        ){
              Lead ld = [SELECT id,  Lead_Routing_Override__c , Trigger_Assignment_Rules__c FROM Lead WHERE id =:cmpmember.LeadId] ; 
              ld.Lead_Routing_Override__c = 'Mid Market';
              ld.Trigger_Assignment_Rules__c= true;
               ldlist = new List<Lead>();
              ldlist.add(ld);
        }      
    }
    if(ldlist !=null && ldlist.size()>0){
        upsert ldlist;
    }
}

 can anyone help me figure out what im missing to get the end result.

 

thx

 

So im assuming that i am totally off in what i am trying to accomplish. So here we go:

 

I have a controller and within it a section that takes the fields from the VF page and pushes them into another set of fields on the same VF page (fired by a copy to command link on the VF page) all within the same object. So one of the fields i am pulling data from is Company_Country which is a picklist in my object and i want to pass the value of this(name) into another vield called Venue_Country (which is a lookup to a table called Country). Attached is the code i am working on but for some reason i get this errror in my debugger. Am i missing something since im passing a picklist value to a lookup

 

public PageReference getsameAddress (){ 
    	
 			this.request.Venue_Name__c = this.request.Company_Name__c;   	
        	this.request.Venue_Address__c = this.request.Company_Address__c;
       		this.request.Venue_City__c = this.request.Company_City__c;
       		this.request.Venue_Postal__c = this.request.Company_Postal__c;
       		
       		
       if (this.request.Company_Country__c != null){
       		this.request.Venue_Country2__c = [select Company_Country__c from Marketing_Request__c where Name=:this.request.Company_Country__c].Name;
       }
   			
       
       		this.request.Venue_State__c = this.request.Company_State__c;
   system.debug('in the getsameaddress method monkey balls');
   		return null;
    	
    } 

So i found a similar message here hat gave some insight into how to copy text from my venue address fields to my vendor address fields. The code shown was just JS and im using apex so getting i to work has my brain spinning. So atached is my controller code and the vf code. I have tried actionsupport functions, onlick, action region and rendered but notihng seems to pass any data. I took the rendered out becasue it gave me a save error about type not matching.


Can anyone see what im going wrong:

My Controller code:

public PageReference getsameAddress (){ 
       	if (this.request.Same_as_Venue__c == true)
       	{
       		this.request.Venue_Address__c = this.request.Company_Address__c;
       		this.request.Venue_City__c = this.request.Company_City__c;
       		this.request.Venue_Postal__c = this.request.Company_Postal__c;
       		this.request.Venue_Country__c = this.request.Company_Country__c;
       		this.request.Venue_State__c = this.request.Company_State__c;
       	}	
      return null;
    } 

 

My vf code:

 <!-- Vendor Info -->
    <!-- Only displayed for internal users -->
    <apex:pageBlockSection title="Vendor Details" rendered="{!isInternal}" columns="1" id="vendorinfo">
       <apex:pageBlockSectionItem >
         	<apex:actionregion >
            	<apex:outputLabel >Same as Venue Details</apex:outputLabel>
              <apex:inputField value="{!request.Same_as_Venue__c}">
            		<apex:actionSupport event="onclick" />
            	</apex:inputField>
            </apex:actionregion>
        </apex:pageBlockSectionItem>
        <apex:pageBlockSectionItem >
            <apex:outputLabel >Phone</apex:outputLabel>
            <apex:inputField value="{!request.Company_Phone__c}"/>
        </apex:pageBlockSectionItem>
        <apex:pageBlockSectionItem >
            <apex:outputLabel >Address</apex:outputLabel>
            <apex:inputField required="true" value="{!request.Company_Address__c}" styleClass="longinput"/>
        </apex:pageBlockSectionItem>
        <apex:pageBlockSectionItem >
            <apex:outputLabel >City</apex:outputLabel>
            <apex:inputField required="true" value="{!request.Company_City__c}"/>
        </apex:pageBlockSectionItem>
        <apex:pageBlockSectionItem >
            <apex:outputLabel >Postal Code</apex:outputLabel>
            <apex:inputField required="true" value="{!request.Company_Postal__c}"/>
        </apex:pageBlockSectionItem>
        
        <!-- 
        This is a little complex...
        The action region allows the page to only submit this specific field
        to the controller when calling AJAX functionality. Without the action region,
        required fields cause the rerender action to fail.
        -->
        <apex:pageBlockSectionItem >
            <apex:outputLabel >Country</apex:outputLabel>
            <apex:actionRegion >
            <apex:inputField required="true" value="{!request.Company_Country__c}">
                <apex:actionSupport event="onchange" reRender="vendorstate"/>
            </apex:inputField>
            </apex:actionRegion>
        </apex:pageBlockSectionItem>
    </apex:pageBlockSection>
    

 

Ok so i have tried every message on the board over the last 2 days and cant seem to get what im trying to acomplish to work. So here is what i am trying to do and my code snipet.

 

I have a VF page that has a picklist called activity_type. When certain choices are picked i would like for the pageblocksection to go away and if they are not selected to show (i.e. if activity_type != Null or Conference or TradeShow remove venue details section)

 

So below is my code. I have tried actionsupport / rendered / rerendered / onchange / onclick u name i have tried it. What i am seeing is

1. that when the page loads for one the venue detail section is gone all together even with null listed

2. When i move the rendered to a field it  will work but not bring it back when it is changed

 

Below is my code i hope someone can see what im totally missing:

 

Ivan

 

Code from controller:

public Boolean checkMe (){ 
       	if (this.request.Activity_Type__c != null ||
			this.request.Activity_Type__c != 'Conference' ||
			this.request.Activity_Type__c != 'TradeShow'){
       		return false;
       	}
       	return true;
    }   		


Code from VF Page:

<apex:pageBlockSection title="Event Details" id="eventdetails">
        <apex:inputField required="true" value="{!request.Event_Name__c}" styleClass="normalinput"/>
        <apex:inputField required="true" value="{!request.Event_Date__c}"/>
        <apex:inputField required="true" value="{!request.Activity_Type__c}" />
        <apex:actionSupport event="onchange" rerender="venuedetails"/>
        <apex:inputField required="true" value="{!request.Estimated_Leads__c}" styleClass="shortinput"/>
        <apex:pageBlockSectionItem >
            <apex:outputLabel >Description</apex:outputLabel>
            <apex:inputField required="true" value="{!request.Event_Description__c}" styleClass="textarea"/>
        </apex:pageBlockSectionItem>
        <apex:pageBlockSectionItem >
            <apex:outputPanel >
                <apex:outputLabel >Currency</apex:outputLabel> <br></br><br></br>
                <apex:outputLabel >Requested Funding Amount</apex:outputLabel>
            </apex:outputPanel>
            <apex:outputPanel >
                <apex:inputField required="true" value="{!request.Currency__c}"/>
                <apex:inputField required="true" value="{!request.Requested_Funding_Amount__c}" styleClass="shortinput"/>
            </apex:outputPanel>
        </apex:pageBlockSectionItem>

        
        <!-- Materials Section -->
        <apex:pageBlockSectionItem >
            <apex:outputLabel >Materials Needed: <br></br> (select any that apply)</apex:outputLabel>
            <apex:selectCheckboxes value="{!materials}" layout="pageDirection">
                <apex:selectOptions value="{!materialOptions}" />
            </apex:selectCheckboxes>
        </apex:pageBlockSectionItem>
        <!-- END Materials Section -->
        
        <!-- Product Focus -->
        <apex:inputField required="true" value="{!request.Product_Focus__c}"/>
        <!-- END Product Focus -->
        
    </apex:pageBlockSection>
    <!-- END Event Details -->
    
    <!-- Venue Info -->
    <apex:pageBlockSection title="Venue Details" columns="1" id="venuedetails" rendered="{!checkMe}">
        <apex:inputField required="true" value="{!request.Venue_Name__c}"  styleClass="normalinput"/>
        
        <apex:pageBlockSectionItem >
            <apex:outputLabel >Address</apex:outputLabel>
            <apex:inputField required="true" value="{!request.Venue_Address__c}" styleClass="longinput"/>
            
        </apex:pageBlockSectionItem>
        <apex:pageBlockSectionItem >
            <apex:outputLabel >City</apex:outputLabel>
            <apex:inputField required="true" value="{!request.Venue_City__c}"/>
        </apex:pageBlockSectionItem>
        <apex:pageBlockSectionItem >
            <apex:outputLabel >Postal Code</apex:outputLabel>
            <apex:inputField required="true" value="{!request.Venue_Postal__c}"/>
        </apex:pageBlockSectionItem>
        
        <!-- Same actionRegion pattern as above -->
        <apex:pageBlockSectionItem dataStyleClass="requiredInput" >
            <apex:outputLabel >Country</apex:outputLabel>
            <apex:actionRegion >
            <div class="requiredInput">
            <div class="requiredBlock"></div>
            <apex:selectList value="{!request.Venue_Country2__c}" size="1">
                <apex:actionSupport event="onchange" reRender="venuestate"/>
                <apex:selectOptions value="{!CountryOptions}"/>
            </apex:selectList>
            </div>
            </apex:actionRegion>
       </apex:pageBlockSectionItem>
    </apex:pageBlockSection> 
    
    <apex:pageBlockSection columns="1" id="venuestate">
        <apex:pageBlockSectionItem rendered="{!venueRequiresState}">
            <apex:outputLabel >State/Province</apex:outputLabel>
            <apex:inputField required="true" value="{!request.Venue_State__c}"/>
        </apex:pageBlockSectionItem>
    </apex:pageBlockSection>
    <!-- END Venue Info -->

 

 

ok so hopefully i explain this correctly. So i have a VF page i have created (code will be below) that captures data from the user. What i need to have happen is when the record is saved it should be associated with a parent campaign. So the campaign is the master detail reocrd i want to have all records from the VF page associated with. I have the VF page working and am trying to right a controller to connect the master detail record (campaign Id) to the child record.

 

So in short user goes to VF page fills in data and when they hit save system relates this record to a campaign. Is this even possible?

 

VF Code:

 

<apex:page standardController="Spiff_Request__c">
  <apex:form >
    <apex:pageBlock title="Spiff Request" mode="Create">
                  
              <apex:pageBlockButtons >
                <apex:commandButton action="{!edit}" id="editButton" value="Edit"/>
                <apex:commandButton action="{!save}" id="saveButton" value="Save"/>
                <apex:commandButton onclick="resetInlineEdit()" id="cancelButton" value="Cancel"/>
              </apex:pageBlockButtons>

     <apex:pageBlockSection title="Spiff Request" columns="2">
         <apex:inputField value="{!Spiff_Request__c.When_was_date_of_Meeting__c}"/> <br></br>
         <apex:inputField value="{!Spiff_Request__c.Product_Interest__c}"/> <br></br>
         <apex:inputField value="{!Spiff_Request__c.New_Customer__c}"/> <br></br>
         <apex:inputField value="{!Spiff_Request__c.Reseller_Company_Name__c}"/>
         <apex:inputField value="{!Spiff_Request__c.Customer_Name__c}"/>
         <apex:inputField value="{!Spiff_Request__c.Reseller_Phone__c}"/>
         <apex:inputField value="{!Spiff_Request__c.Customer_Phone__c}"/>
         <apex:inputField value="{!Spiff_Request__c.Address_to_send_Spiff_to__c}"/>
         <apex:inputField value="{!Spiff_Request__c.Customer_Address__c}"/>
         <apex:inputField value="{!Spiff_Request__c.Who_Attended_Partner_Imperva__c}"/>
         <apex:inputField value="{!Spiff_Request__c.Who_Attended_Customer__c}"/>
         <apex:inputField value="{!Spiff_Request__c.Additional_Details__c}"/>
     </apex:pageBlockSection>
 
    </apex:pageBlock>
  </apex:form>
</apex:page>
             

Controller class code: (this is where im trying to pass the ID to match child recod to parent (the error i get is :

Save error: Initial term of field expression must be a concrete SObject: String)

 

public

withsharingclass CampaignID {

publicCampaign campaignID       {get;set;}

public CampaignID(ApexPages.StandardController sc)

 

{

 

  campaignID = sc.getID()campaign_ID;

 

}

public PageReference saveAndReject() {

 

PageReference requestPage = Page.AccountRecord;

requestPage.getParameters().put(campaignID,

Spiff_Request__c.CampaignID__c);

requestPage.setRedirect(

true);

return

requestPage;

 

}

}

 

I havent added the controller into the VF code yet becasue i cant get it to save.

 

Thanks for all replys....

 

So this may or may not be possible. But what i am trying to accomplish is that in my workflow for those who should recieve the email alert i would like to pull in the opprotunity owners manager into the list. So instead of having to create for each i would like to see if i could create an email field on the opprotunity and have the manager of the opprotunity added in that way on the email alert selection list i can use the new email field to add to recepients list.

 

Hopefully thats not to confusing... any thoughts..

 

Ivan

Afternoon,

I need soql help...
My requirements are as follows:

1. Check if it is in a North American Territory (including mid market)

2. If it is:   

a. Look at the Primary QSL.Assigned To field

b. Check that it matches the RSD/RSM on the Lead.Territory - Where im having the most trouble on how to do this

c. If there is a mismatch, display an error message "Please update the lead owner to the correct queue. If this is a PRM lead or you need help, contact salesops@imperva.com."

Below is the code i have but just looking i know its not working. I cant figure how to get my select statements correct. Can anyone help...

// North America Territory assignment
     if (this.lead.Territory__c.Name == 'NA -*'){
     
      RSD = [Select ID,Regional_Sales_Director__c.Name from Territory__c where ID := ];
      primeQ = [Select ID, Assigned_To__c.Name From QSL_Review_Request__c Where ID := ];
     
      if (RSD <> primeQ){
       addError('Please update the lead owner to the correct queue. If this is a PRM lead or you need help, contact salesops@imperva.com');
       isValid = false;
      
      }
     
     }

I have a trigger that was updated to handle bulk case closures and it works but when i deploy to production i get errors from other test classes what have nothing to do with my trigger. So i think i need to have a test created but am having trouble to create one. Here is the trigger i have created.

trigger pullSE on Case (before update, before insert) {
Set<id> userids=new Set<id>();
Map<id,string> siteMap=new Map<id,string>();
    for (case t: trigger.new) {

        try {
            if (t.SE__c == null) {
                userids.add(t.site__c);                
            }
        }
        catch (Exception e) {
        }
    }
	if(userids!=null){
		for(site__c s:[select id,user__c from site__c where id in:userids]){
			siteMap.put(s.id,s.user__c);
			}
		}
		for(case t:trigger.new){
			t.se__c=sitemap.get(t.site__c);
		}
	}

 

So i have the attached trigger on my case object. When trying to do a mahor upload we received the following errror:

 

System.LimitException: Too many SOQL queries: 101 Trigger.pullSE: line 5, column 1".

 

From reading other post it seems that i have to take the select statement out of the for loop. But my issue is that when i try its not pulling the information as it was. I tried <list> and <map> functions and nothing works so i have put it back to normal and now the code works again. Can anyone help me figure the best approach to get rid of the error.

 

Code:

trigger pullSE on Case (before update, before insert) {
    for (case t: trigger.new) {
        try {
            if (t.SE__c == null) {
                t.SE__c = [select User__c from Site__c where Id = :t.Site__c].User__c; //t.Site__r.User__c;
            }
        }
        catch (Exception e) {
        }
    }
}

 

Thanks....

Ive never really written a test class before so a little stuck trying to look at old ones to figure out what i need in order to test. Can anyone help. the class wont save saying the "Variable does not exist: tcontact.id"

 

@IsTest

public class Lead_Campaign_Mid_Market_Test{
static testMethod void testCampMember() {


// Create testing Camp, Lead, Contact and Campaign member data 
Campaign tCampaign = new Campaign(name='testcamp');
insert tCampaign;

Lead tlead = new Lead(FirstName='SaraTester',LastName='testing',Lead_Routing_Override__c = 'Mid Market', Trigger_Assignment_Rules__c = true);
insert tlead;

Contact tcontact = new Contact(FirstName='JimTester',LastName='testing');
insert tcontact;


CampaignMember tCampMemb = new CampaignMember(campaignId=tCampaign.id,leadId=tlead.id,contactId=tcontact.id,status='Responded');
insert tCampMemb;




}
}

 

So attached is my code in my controller that is looking to pull the account data using the lookup filed called Partner__c. For some reason nothing is being pulled over. Does anyone see what i am missing this seems so simple but is causing such a headache...

         public PageReference getresellerInfo (){ 
    	
  		Account a = [SELECT Id, Name, Phone, Account.BillingStreet, Account.BillingCity,   Account.BillingState, Account.BillingPostalCode, Account.BillingCountry
                     FROM Account
                     WHERE Id = :this.request.Partner__c];

   	 if(this.request.Partner__c != null){
            this.request.Company_Phone__c = a.Phone;
            this.request.Company_Address__c = a.BillingStreet;
            this.request.Company_City__c = a.BillingCity;
            this.request.Company_Postal__c = a.BillingPostalCode;
            this.request.Company_Country__c = a.BillingCountry;           
            this.request.Company_State__c = a.BillingState;
    	}
              
            system.debug('in the getresellerInfo method monkey balls 2');
    		  
            return null;
            
    		   	
    } 

 

So here is what i am trying to accomplish:

 

I need a trigger that basically does the following:

  1. Every time a CampaignMember object is created…
  2. Check if the GEO on the parent campaign is 'Mid Market'
  3. If it is, update the related lead:
    1. Set the Lead_Routing_Override__c field to be 'Mid Market'
    2. Set Trigger_Assignment_Rules__c to true

 

Here is what i have thus far but i feel i am missing someting becasuse my statement to see if the GEO code = Mid Market wont let me save the file.

 

trigger Lead_Campaign_Mid_Market on CampaignMember(after insert, after update) {

    List<Lead> ldlist;
    for(CampaignMember cmpmember: Trigger.new){
        if(
        cmpmember.LeadId !=null 
        //Campaign.GEO__c ='Mid Market'
        ){
              Lead ld = [SELECT id,  Lead_Routing_Override__c , Trigger_Assignment_Rules__c FROM Lead WHERE id =:cmpmember.LeadId] ; 
              ld.Lead_Routing_Override__c = 'Mid Market';
              ld.Trigger_Assignment_Rules__c= true;
               ldlist = new List<Lead>();
              ldlist.add(ld);
        }      
    }
    if(ldlist !=null && ldlist.size()>0){
        upsert ldlist;
    }
}

 can anyone help me figure out what im missing to get the end result.

 

thx

So i found a similar message here hat gave some insight into how to copy text from my venue address fields to my vendor address fields. The code shown was just JS and im using apex so getting i to work has my brain spinning. So atached is my controller code and the vf code. I have tried actionsupport functions, onlick, action region and rendered but notihng seems to pass any data. I took the rendered out becasue it gave me a save error about type not matching.


Can anyone see what im going wrong:

My Controller code:

public PageReference getsameAddress (){ 
       	if (this.request.Same_as_Venue__c == true)
       	{
       		this.request.Venue_Address__c = this.request.Company_Address__c;
       		this.request.Venue_City__c = this.request.Company_City__c;
       		this.request.Venue_Postal__c = this.request.Company_Postal__c;
       		this.request.Venue_Country__c = this.request.Company_Country__c;
       		this.request.Venue_State__c = this.request.Company_State__c;
       	}	
      return null;
    } 

 

My vf code:

 <!-- Vendor Info -->
    <!-- Only displayed for internal users -->
    <apex:pageBlockSection title="Vendor Details" rendered="{!isInternal}" columns="1" id="vendorinfo">
       <apex:pageBlockSectionItem >
         	<apex:actionregion >
            	<apex:outputLabel >Same as Venue Details</apex:outputLabel>
              <apex:inputField value="{!request.Same_as_Venue__c}">
            		<apex:actionSupport event="onclick" />
            	</apex:inputField>
            </apex:actionregion>
        </apex:pageBlockSectionItem>
        <apex:pageBlockSectionItem >
            <apex:outputLabel >Phone</apex:outputLabel>
            <apex:inputField value="{!request.Company_Phone__c}"/>
        </apex:pageBlockSectionItem>
        <apex:pageBlockSectionItem >
            <apex:outputLabel >Address</apex:outputLabel>
            <apex:inputField required="true" value="{!request.Company_Address__c}" styleClass="longinput"/>
        </apex:pageBlockSectionItem>
        <apex:pageBlockSectionItem >
            <apex:outputLabel >City</apex:outputLabel>
            <apex:inputField required="true" value="{!request.Company_City__c}"/>
        </apex:pageBlockSectionItem>
        <apex:pageBlockSectionItem >
            <apex:outputLabel >Postal Code</apex:outputLabel>
            <apex:inputField required="true" value="{!request.Company_Postal__c}"/>
        </apex:pageBlockSectionItem>
        
        <!-- 
        This is a little complex...
        The action region allows the page to only submit this specific field
        to the controller when calling AJAX functionality. Without the action region,
        required fields cause the rerender action to fail.
        -->
        <apex:pageBlockSectionItem >
            <apex:outputLabel >Country</apex:outputLabel>
            <apex:actionRegion >
            <apex:inputField required="true" value="{!request.Company_Country__c}">
                <apex:actionSupport event="onchange" reRender="vendorstate"/>
            </apex:inputField>
            </apex:actionRegion>
        </apex:pageBlockSectionItem>
    </apex:pageBlockSection>
    

 

Ok so i have tried every message on the board over the last 2 days and cant seem to get what im trying to acomplish to work. So here is what i am trying to do and my code snipet.

 

I have a VF page that has a picklist called activity_type. When certain choices are picked i would like for the pageblocksection to go away and if they are not selected to show (i.e. if activity_type != Null or Conference or TradeShow remove venue details section)

 

So below is my code. I have tried actionsupport / rendered / rerendered / onchange / onclick u name i have tried it. What i am seeing is

1. that when the page loads for one the venue detail section is gone all together even with null listed

2. When i move the rendered to a field it  will work but not bring it back when it is changed

 

Below is my code i hope someone can see what im totally missing:

 

Ivan

 

Code from controller:

public Boolean checkMe (){ 
       	if (this.request.Activity_Type__c != null ||
			this.request.Activity_Type__c != 'Conference' ||
			this.request.Activity_Type__c != 'TradeShow'){
       		return false;
       	}
       	return true;
    }   		


Code from VF Page:

<apex:pageBlockSection title="Event Details" id="eventdetails">
        <apex:inputField required="true" value="{!request.Event_Name__c}" styleClass="normalinput"/>
        <apex:inputField required="true" value="{!request.Event_Date__c}"/>
        <apex:inputField required="true" value="{!request.Activity_Type__c}" />
        <apex:actionSupport event="onchange" rerender="venuedetails"/>
        <apex:inputField required="true" value="{!request.Estimated_Leads__c}" styleClass="shortinput"/>
        <apex:pageBlockSectionItem >
            <apex:outputLabel >Description</apex:outputLabel>
            <apex:inputField required="true" value="{!request.Event_Description__c}" styleClass="textarea"/>
        </apex:pageBlockSectionItem>
        <apex:pageBlockSectionItem >
            <apex:outputPanel >
                <apex:outputLabel >Currency</apex:outputLabel> <br></br><br></br>
                <apex:outputLabel >Requested Funding Amount</apex:outputLabel>
            </apex:outputPanel>
            <apex:outputPanel >
                <apex:inputField required="true" value="{!request.Currency__c}"/>
                <apex:inputField required="true" value="{!request.Requested_Funding_Amount__c}" styleClass="shortinput"/>
            </apex:outputPanel>
        </apex:pageBlockSectionItem>

        
        <!-- Materials Section -->
        <apex:pageBlockSectionItem >
            <apex:outputLabel >Materials Needed: <br></br> (select any that apply)</apex:outputLabel>
            <apex:selectCheckboxes value="{!materials}" layout="pageDirection">
                <apex:selectOptions value="{!materialOptions}" />
            </apex:selectCheckboxes>
        </apex:pageBlockSectionItem>
        <!-- END Materials Section -->
        
        <!-- Product Focus -->
        <apex:inputField required="true" value="{!request.Product_Focus__c}"/>
        <!-- END Product Focus -->
        
    </apex:pageBlockSection>
    <!-- END Event Details -->
    
    <!-- Venue Info -->
    <apex:pageBlockSection title="Venue Details" columns="1" id="venuedetails" rendered="{!checkMe}">
        <apex:inputField required="true" value="{!request.Venue_Name__c}"  styleClass="normalinput"/>
        
        <apex:pageBlockSectionItem >
            <apex:outputLabel >Address</apex:outputLabel>
            <apex:inputField required="true" value="{!request.Venue_Address__c}" styleClass="longinput"/>
            
        </apex:pageBlockSectionItem>
        <apex:pageBlockSectionItem >
            <apex:outputLabel >City</apex:outputLabel>
            <apex:inputField required="true" value="{!request.Venue_City__c}"/>
        </apex:pageBlockSectionItem>
        <apex:pageBlockSectionItem >
            <apex:outputLabel >Postal Code</apex:outputLabel>
            <apex:inputField required="true" value="{!request.Venue_Postal__c}"/>
        </apex:pageBlockSectionItem>
        
        <!-- Same actionRegion pattern as above -->
        <apex:pageBlockSectionItem dataStyleClass="requiredInput" >
            <apex:outputLabel >Country</apex:outputLabel>
            <apex:actionRegion >
            <div class="requiredInput">
            <div class="requiredBlock"></div>
            <apex:selectList value="{!request.Venue_Country2__c}" size="1">
                <apex:actionSupport event="onchange" reRender="venuestate"/>
                <apex:selectOptions value="{!CountryOptions}"/>
            </apex:selectList>
            </div>
            </apex:actionRegion>
       </apex:pageBlockSectionItem>
    </apex:pageBlockSection> 
    
    <apex:pageBlockSection columns="1" id="venuestate">
        <apex:pageBlockSectionItem rendered="{!venueRequiresState}">
            <apex:outputLabel >State/Province</apex:outputLabel>
            <apex:inputField required="true" value="{!request.Venue_State__c}"/>
        </apex:pageBlockSectionItem>
    </apex:pageBlockSection>
    <!-- END Venue Info -->