• Daniel.Reid
  • NEWBIE
  • 55 Points
  • Member since 2012

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

Hello, I'm very new to triggers and need some assistance with some code. When I try to save the following trigger, I receive the error "Error: Compile Error: Initial term of field expression must be a concrete SObject: MAP<Id,Lead> at line 20 column 75 ". Offending expression in bold red. How do I refer to the Assigned_Date__c field so that the code recognizes it? I've tried l.Assigned_Date__c but then I get a variable doesn't exist error. I've also tried setting up a new variable but I can't pass the Lead's value into the variable. Any help is appreciated. 

 

 

trigger LeadInsertUpdate on Lead(after insert, after update){

Set<Id> LeadSetOfIds = new Set<Id>();
BusinessHours bh = [SELECT Id FROM BusinessHours WHERE IsDefault=true];
DateTime No_Contact_Reassign_Date;

//then iterate through your Leads
for(Lead l : trigger.new){
if(l.Id != null){
LeadSetOfIds.add(l.Id);
}
}

Map<Id,Lead> LeadMap = new Map<Id,Lead>([select Id, Assigned_Date__c, No_Contact_Reassign_Date__c, No_Conversion_Reassign_Date__c from Lead
where Id in : LeadSetOfIds]);


if(LeadMap.get(LeadMap.Assigned__Date__c)!=null)
// {No_Contact_Reassign_Date = BusinessHours.addGmt(bh.Id, LeadMap.get(LeadMap.Assigned__Date__c), 8 * 60 * 60 * 1000L);}
// need to figure out how to get assigned date here..
}

  • August 30, 2012
  • Like
  • 0

Just started using Force.com IDE and I've got some questions, probably very simple. Sorry if these seem inconsequential or a waste of time - they aren't very critical questions, but I just like to fully comprehend the programs I use.

 

 

So, Ideally I'd like my local files to reflect whats in production as accurately as possible, so I do not have to do all this logging in and selecting of specific data every time I start something new. The question is if doing something like that is advisable, or a poor idea?   

-----------------------------------

I'm sure they aren't duplicates, but I was wondering why are there two listings of custom fields on custom objects when choosing the metadata components on creation of a new project.?

 

 

Hello, I'm very new to triggers and need some assistance with some code. When I try to save the following trigger, I receive the error "Error: Compile Error: Initial term of field expression must be a concrete SObject: MAP<Id,Lead> at line 20 column 75 ". Offending expression in bold red. How do I refer to the Assigned_Date__c field so that the code recognizes it? I've tried l.Assigned_Date__c but then I get a variable doesn't exist error. I've also tried setting up a new variable but I can't pass the Lead's value into the variable. Any help is appreciated. 

 

 

trigger LeadInsertUpdate on Lead(after insert, after update){

Set<Id> LeadSetOfIds = new Set<Id>();
BusinessHours bh = [SELECT Id FROM BusinessHours WHERE IsDefault=true];
DateTime No_Contact_Reassign_Date;

//then iterate through your Leads
for(Lead l : trigger.new){
if(l.Id != null){
LeadSetOfIds.add(l.Id);
}
}

Map<Id,Lead> LeadMap = new Map<Id,Lead>([select Id, Assigned_Date__c, No_Contact_Reassign_Date__c, No_Conversion_Reassign_Date__c from Lead
where Id in : LeadSetOfIds]);


if(LeadMap.get(LeadMap.Assigned__Date__c)!=null)
// {No_Contact_Reassign_Date = BusinessHours.addGmt(bh.Id, LeadMap.get(LeadMap.Assigned__Date__c), 8 * 60 * 60 * 1000L);}
// need to figure out how to get assigned date here..
}

  • August 30, 2012
  • Like
  • 0

Hi,

 

I am working with a client that wants to produce a quote that lists all OpportunityLineItems sub-divded by Product family. I have controller that display Opportunitylineitems on VF page as below...

 

Basic                 1.0  1    03/08/2012  12  USD 149.0  USD 1788.0
                            1.0  12  25/07/2012  10  USD 300.0  USD 3000.0
                            1.0  12  16/08/2012  11   USD 273.0 USD 3003.0

                                                                                              subtotal????

 

Custom              1.0   03/08/2012   USD 1800.0
Single                 1.0    03/08/2012  USD 5500.0
                                                             subtotal????

 

How can i do the subtotal of each product family? Here is the controller that works fine without subtotal.

class:

public class OppsControllerExtension {

    private final Opportunity opps;
    
   public OppsControllerExtension(ApexPages.StandardController stdController) {
        this.opps = (Opportunity)stdController.getRecord();

}

List<OpportunityLineItem> OppsLicence = [SELECT id, ServiceDate, Opportunity.name FROM OpportunityLineItem 
                                         WHERE License_service__c = 1 AND Opportunity.id = 
            :System.currentPageReference().getParameters().get('id')];
   
        public integer getLicenceRowNumber() {
            if (OppsLicence.size() >= 1)
            return OppsLicence.size() - 1;       
           
        else
            return 0;
        }
        public list <OpportunityLineItem> getLicenceServicelist () {
        return [SELECT id, ServiceDate, License_service__c, PricebookEntry.Product2.Quote_service_group__c, PricebookEntry.Product2.Quote_service_schedule__c, Opportunity.name FROM OpportunityLineItem 
                                         WHERE License_service__c = 1 AND Opportunity.id = 
            :System.currentPageReference().getParameters().get('id')];
     }
        
List<OpportunityLineItem> OppsSponsor = [SELECT id, ServiceDate, Opportunity.name FROM OpportunityLineItem 
                                         WHERE Sponsorship_Service__c = 1 AND Opportunity.id = 
            :System.currentPageReference().getParameters().get('id')];
    
     
    public integer getSponsorRowNumber() {
        if (OppsSponsor.size() >= 1) 
                 return OppsSponsor.size() - 1;
        else
            return 0;
        }
    
    public list <OpportunityLineItem> getSponsorServicelist () {
        return [SELECT id, ServiceDate, Sponsorship_Service__c, PricebookEntry.Product2.Quote_service_group__c, PricebookEntry.Product2.Quote_service_schedule__c, Opportunity.name FROM OpportunityLineItem 
                                         WHERE Sponsorship_Service__c = 1 AND Opportunity.id = 
            :System.currentPageReference().getParameters().get('id')];
     }
}

 

Many thanks,

The RFPforce from Salesforce labs is really great and our Company is really enjoying it. However, I now need move a new app from Sandbox to Production and I can't deploy because the Custom Object "Questions" with the trigger "AvoidDuplicateUsageEntry" created by the RFPforce app does not have an Apex test.

 

API NameTypeLineColumnProblem
AvoidDuplicateUsageEntry   Test coverage of selected Apex Trigger is 0%, at least 1% test coverage is required

 

NameAvoidDuplicateUsageEntrySobject TypeQuestion
Is ValidCode Coverage0%

 

I was thinking if could add a new Apex test in the Production environment it would clear this error - and then push over the new app.  Is that correct?

 

Can someone help me write the test? I don't know anything about development and I don't know where to go for assistance.

This is the trigger in the "Questions" custom object:

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
trigger AvoidDuplicateUsageEntry on Question__c (before insert) 
{
    for (Question__c question: Trigger.new)
    {
        if (question.Override_Warning__c == false)
        {
            try
            {
              Question__c[] q = [SELECT q.CreatedById, q.CreatedDate, q.Question__c from Question__c q where q.Response__c = :question.Response__c and q.RFP__c = :question.RFP__c ORDER BY CreatedDate desc];
              if (q.size() > 0)
              {
                  User u = [SELECT u.Name from User u where id = :q[0].CreatedById];
                  String questionStr = String.escapeSingleQuotes(q[0].Question__c);
                  questionStr = questionStr.replace('\"', '\\\"');
                  String userStr = String.escapeSingleQuotes(u.Name);
                  userStr = userStr.replace('\"', '\\\"');
                  String dateStr = q[0].CreatedDate.format('MM/dd/yyyy hh:mm a');
                  String errorJSON = 'var errorJSON = {timesUsed: ' + q.size() + ', question: \"' + questionStr + '\", user: \"' + userStr + '\", time: \"' + dateStr + '\"};';  
                  question.Response__c.addError(errorJSON);
              } // endif
            }
            catch (QueryException e)
            {
                // This is actually the non-error case.  The Question should not 
                // already exist.  Do nothing.
            }
        } // endif
    } // endfor
}

 

Any help at all would be greatly appreciated.

I am trying to display all the Child Records within a "pageBlockTable" using the parent as the Standard Controller but I can't seem to figure out the correct Value.  How do I identify the correct term?  

 

While I'm here, I don't seem to understand the idea behind the "var".  Is this something I need?

  • August 27, 2012
  • Like
  • 0

Hi, I am not very experienced with APEX development, but I am trying to write a trigger that places the value of the Last_AM_Verbal_Contact, Last_AS_Verbal_Contact, Last_BD_Verbal_Contact, and Last_SF_Verbal_Contact fields on the account level onto the same fields on the Opportunity level.  This is what I have so far:

 

trigger UpdateOppLastVerbalContactfromAcct on Account (after insert) {
Set<Id> Ids= new Set<Id>();
for (Account acc : Trigger.new)
{
Ids.add(acc.Id);
}
List<Account> accountList = new List<Account>([Select Id,Last_AM_Verbal_Contact__c,Last_AS_Verbal_Contact__c,Last_BD_Verbal_Contact__c,Last_SF_Verbal_Contact__c From Account a where Id in :Ids]);

for(Account temp : accountList )
{
Opportunity opp = new Opportunity();
opp.Last_AS_Verbal_Contact__c = temp.Last_AS_Verbal_Contact;
insert opp;

}

}
  
 
 Error: Compile Error: Invalid field Last_AS_Verbal_Contact for SObject Account at line 12 column 41

 

 

I'm kinda confused why it's the field is invalid.  On the Account level, these fields are populated from a trigger.  I would figure that once the trigger populates it, then it wouldn't matter.  Also the field type is a date, so that might be the issue too?

 

 

 

Hi Guys,

 

i already asked this question on stackoverflow, so first i redirct you there ;).

 

I think this problem has something to do with rights on the custom object.

 

Thanks in advance.

Tim

I have a force.com external site page. My idea is after the user is done the task I want them to have the ability to return to the beginning and do it again. To do this I'm trying to refresh the current page and re-run the constructor so they'll see the new information they had just added.

 

I have following button:

<apex:commandButton styleClass="btn  btn-large" action="{!cancelThis}"	value="Add/Edit More Sites" />

 That launches this method that should be returning to the same page and refreshing it after re-inserting the URL paremeters:

 

public PageReference cancelThis() {
		PageReference currPage1 =  new PageReference('http://MYSITE.COM/MYVFPAGE');
		currPage1.getParameters().put('accountId',urlAccountId);
		currPage1.getParameters().put('contactId',urlContactId);
		currPage1.setRedirect(true);
		return currPage1;
	}

 

The issue I'm running into is its not re-running the constructor. I have a debug statement at the top of my constructor that doesn't show up when cancelThis() runs. If I manually refresh the page after the 'redirect' it does.

 

Any idea why the constructor isn't re-running when I'm setting redirect=true? Is it because it knows its going back to itself instead of a new page?

 

Thanks!

I want to make a record read only based on the record type to all profiles except system admin.How to achieve this.
For eg. I have a record type "Candidate".For all the records which have candidate as record type should be read only to all profiles except system admin.

Hello,

 

I tried to write an apex code to sum the field of child related list obect.

 

I have 2 custom objects : "Server__c" and "Component__c"

i have a field, type :number, called "Memory__c" in the component object.

there are n Components related to Server.

 

I would like to sum the Memory of each component related to my server.

 

i tried this, but it doesn't work. I'm new in the apexcode

 

public class CustomserverController {

Id idServer = null;
Integer SumMemory = 0;

public CustomChassisController(ApexPages.StandardController conMain) {
// Set Variables
idServer = conMain.getId();
}

List<Server__c> LstServer = [SELECT (select Memory__c FROM Components__r) FROM Server__c WHERE Id = :idServer];

for(Server__c a: LstServer)
{
for(Components__c o: a.Components__r)
{
SumMemory += Memory__c;
}
}
}

 

Thanks for your help

 

Antoine

 

Hello Everybody,

 

   Currently I am facing a very weird problem. Here goes the description:

 

I converted a lead to create an opportunity. One of the field is CloseDate with value as 9/30/2012. The product added to the opportunity has a quarterly schedule. A field called BookedDate contains today's date i.e. 8/17/2012. Opportunity stage is 5- Closed Won.

 

Now by virtue of a trigger, the schedules should be generated starting from 9/30/2012, however when the CloseDate is updated to today's date and quarterly schedules are generated off today's date, and then again the CloseDate is assigned 9/30/2012 by virtue of a Field Update.

 

The Opportunity  history shows two entries:

1st) CloseDate changed from 9/30 to 8/17.

2nd) CloseDate changed from 8/17 to 9/30.

 

Now the most confusing part is the trigger :

It first generates the schedules from 8/17, however due to the update from 8/17 to 9/30 on CloseDate on Opportunity, its logic is not executed. I put a debug log and what it shows for that instance is that the Trigger.new and Trigger.old CloseDate  are the same, which is not true since Old Close Date is 8/17 and New CloseDate is 9/30, but debug log shows New and Old CloseDate as 9/30.

 

The problem is so confusing that it's difficult to express it right away. Any suggestion would be very helpful.

 

Thanks a lot.

K

In our org, we have enabled the customer portal. This portal is mainly for the distributors who will maintain their invoices and daily stocks. I initially created objects for distributor, invoice, daily stock and defined the relationships between them. Is it correct to create a distributor object or should a contact be  treated as a distributor by adding a record type. Pls help...

When registering a portal user we are creating the contact, the Non-Profit Starter Pack automatically creates the individual account for the contact, then we set the individual account owner id to a user (always the same one) who is in the role hierarchy. Then we call Site.createPortalUser. This was all working fine, but a few days ago we started seeing the following error more and more often:

 

There was an error in registering a user in site Application_Portal. The error message is: portal account owner must have a role

 

There could be over a 1000 portal users whose accounts are all owned by this same portal owner user. Could this be the cause of the problem? Is there a limit on how many individual accounts a portal owner user can own?

  • August 10, 2012
  • Like
  • 0

Hello,

 

I have some functionality that will be prompting a user to export a .csv file (which contains data on Opportunities, Account, and a custom object related to Opps)  that will be consumed by an external ROI tool.  The ROI will then adjust the data and spit it back out in the exact same format.  I then have functionality to allow the user to go to a VF page (from an Opportunity) and then 'upload' the ROI tool.  In actuality what this is doing is updating the data from the .csv into SF.  I have the Controllers and VF pages themselves working just fine, however I am having trouble with the test code.  I have the controllers in two separate classes, but I am hoping to cover them both in a single test class.  Specifically I was hoping to be able to test the Export Controller and then assign the VF page to blob that I can pass in to the Import controller.  But when testing I am getting an error (in the debug log) that says getContent (at the end of the test method below) is not supported in test methods.  Below I will post both Controllers, the Export ROI page (the Import VF page just passes the uploaded file into the controller) and the test class I have so far.  Any and all help would be appreciated!

 

 

Export Controller:

public class ROIExportController {
     
     //this method will return all data needed that is stored on the Opportunity itself.
     public String getOpportunityID(){
        return (ApexPages.currentPage().getParameters().get('id'));
     }
     
     public String getOpportunityName(){
     	Opportunity o = [Select Name FROM Opportunity WHERE Id = :ApexPages.currentPage().getParameters().get('id')];
     	return (o.Name);
     }
     
     public String getOpportunityData(){        
        Opportunity o = [Select Id, Name, RecordTypeId, RecordType.Name, Owner.Name, OwnerId, NoofRooms__c, NoofHotels__c, CurrencyIsoCode, Contract_Term_in_Months__c, Amount, Pricing_Tool_Margin__c From Opportunity o WHERE o.id = :ApexPages.currentPage().getParameters().get('id')]; 
        return (o.Id + ',' + o.Name + ',' +o.Owner.Name + ',' + o.Contract_Term_in_Months__c + ',' + o.NoofHotels__c + ',' + o.NoofRooms__c + ',' + o.CurrencyIsoCode + ',' + o.RecordType.Name + ',' + o.Amount + ',' + o.Pricing_Tool_Margin__c) ;     
     }
     
     public String getAccountData(){
        Account a = [Select a.ShippingStreet, a.ShippingState, a.ShippingPostalCode, a.ShippingCountry, a.ShippingCity, a.Region__c, a.Phone, a.Name, a.Id, a.Account_Market_Segment__c From Account a WHERE a.id = :ApexPages.currentPage().getParameters().get('accountId') ];
        return  (a.Id + ',' + a.Name + ',' + a.ShippingStreet + ',' + a.ShippingCity + ',' + a.ShippingState + ',' + a.ShippingCountry + ',' + a.ShippingPostalCode + ',' + a.Phone + ',' + a.Account_Market_Segment__c + ',' + a.Region__c);
     }
     public String getExchangeRateData(){
        CurrencyType CAD = [Select c.ConversionRate From CurrencyType c WHERE c.IsoCode LIKE 'CAD%' AND c.IsActive = True];
        CurrencyType EUR = [Select c.ConversionRate From CurrencyType c WHERE c.IsoCode LIKE 'EUR%' AND c.IsActive = True];
        CurrencyType GBP = [Select c.ConversionRate From CurrencyType c WHERE c.IsoCode LIKE 'GBP%' AND c.IsActive = True];
        CurrencyType SGD = [Select c.ConversionRate From CurrencyType c WHERE c.IsoCode LIKE 'SGD%' AND c.IsActive = True];
        CurrencyType AUD = [Select c.ConversionRate From CurrencyType c WHERE c.IsoCode LIKE 'AUD%' AND c.IsActive = True];
        return (CAD.ConversionRate + ',' + EUR.ConversionRate + ',' + GBP.ConversionRate + ',' + SGD.ConversionRate + ',' + AUD.ConversionRate);
     }
     public List<Opportunity_Product__c> getOpportunityProductData(){
        List<Opportunity_Product__c> oppProds = [Select Id, Pricing_Record__c, Product_Service__c, Quoted_Recurring_Fee__c, Quoted_Fee_Recurrence__c, Quoted_Multiplier_Fee__c, Quoted_Multiplier_Type_Rec__c, Quoted_Number_of_Transactions__c, Quoted_Number_of_Units_of_Time__c, Quoted_One_Time_Fee__c, Quoted_One_Time_Type__c, Quoted_Time_Based_Fee__c, Quoted_Transaction_Fee__c, Quoted_Transaction_Type__c, Quoted_Unit_of_Time__c, Rack_Recurring_Fee__c, Rack_Fee_Recurrence__c, Rack_Multiplier_Fee__c, Rack_Multiplier_Type_Rec__c, Rack_One_Time_Fee__c, Rack_One_Time_Type__c, Rack_Time_Based_Fee__c, Rack_Transaction_Fee__c, Rack_Transaction_Type__c, Rack_Unit_of_Time__c FROM Opportunity_Product__c WHERE Opportunity_Name__r.Id = :ApexPages.currentPage().getParameters().get('id')];
        return oppProds;
     }
}

 

 

Import Controller (includes a standard from code share Parser):

public class ROIUploadController {

	public Blob contentFile { get; set; }
    public String nameFile { get; set; }
    public Integer rowCount { get; set; }
    public Integer colCount { get; set; } 
    public String errorMessage { get; set; }
    public String successMessage { get; set; }
    
    
    public void updateRecordsWithROICSV(){
    	List<List<String>> attachedCSV = getResults();
    	if(attachedCSV != null){
			//get and update Opportunity Data
			Id oppID = (ApexPages.currentPage().getParameters().get('id'));
			Opportunity Opp = [Select Id From Opportunity WHERE Id = :oppID];
			//assign the appropriate row of data as the Opporutniy data row
			List<String> oppDataRow = attachedCSV.get(2);
			//Had to use trim() method below to get rid of a leading space in the Opp's ID.  I will use this in the rest of this code for ALL IDs listed in the .csv
			ID csvOppID = oppDataRow.get(0).trim(); 			
			//If the ID in the .csv = the ID of the Opp selected in SF are, then update the Opp's Amount and Margin from the relevant fields in the uploaded .csv
			If( csvOppID == oppID){
				//update the Opp fields IN MEMORY ONLY.  The real update to the record takes place below where all Opp Prod records will also be updated.
				Opp.amount = decimal.ValueOf(oppDataRow.get(8));
				Opp.Pricing_Tool_Margin__c = decimal.ValueOf(oppDataRow.get(9));
				//make sure there is an entry on the first Opp Prod row, if so there is at least one Opp Prod in the .csv
				If(attachedCSV.get(11) != null){
					//get a full list of Opp Prods in SF and a list of those in the CSV, compare them before making any updates.					
					List<Opportunity_Product__c> oppProdsInSF = [Select ID, Pricing_Record__c, Product_Service__c from Opportunity_Product__c WHERE Opportunity_Name__c = :oppID];
					Set<ID> oppProdIDsinSF = new Set<ID>();
					Set<ID> oppProdIDsinCSV = new Set<ID>();
					For(Opportunity_Product__c oP :oppProdsInSF){
						oppProdIDsinSF.add(oP.ID);
					}
					//set up a while loop that adds all IDs for Opp Prods in the .csv to a set of IDs(to be compared to the list in SF), meanwhile create a list of lists for all of the Opp Product rows in the csv
					Integer i = 11;
					List<List<String>> allOppProdRows = new List<List<String>>();
					List<String> currentOppProdCSV = new List<String>();
					While( i < attachedCSV.size() ){
						currentOppProdCSV = attachedCSV[i];
						allOppProdRows.add(attachedCSV[i]);
						ID currentOPID = currentOppProdCSV[0].trim();
						oppProdIDsinCSV.add(currentOPID);
						i++;
					}
					//compare the two Sets of IDs and if they are = continue, else give error saying they do not match.
					If(oppProdIDsinSF == oppProdIDsinCSV){
						boolean isError = false;
						For(Opportunity_Product__c currentSFOppProd :oppProdsInSF){
							IF (isError == false){
								For(List<String> currentOppProdRow :allOppProdRows){
									//check to see if IDs match, if so follow that to make sure P/S and pricing record IDs match.  If those match, make the updates.
									If(currentOppProdRow[0].trim() == currentSFOppProd.Id){
										If(currentOppProdRow[1].trim() == currentSFOppProd.Pricing_Record__c && currentOppProdRow[2].trim() == currentSFOppProd.Product_Service__c){
											currentSFOppProd.Quoted_Recurring_Fee__c = decimal.ValueOf(currentOppProdRow[3]);
											currentSFOppProd.Quoted_Fee_Recurrence__c = currentOppProdRow[4];
											currentSFOppProd.Quoted_Multiplier_Fee__c = decimal.ValueOf(currentOppProdRow[5]);
											currentSFOppProd.Quoted_Multiplier_Type_Rec__c = currentOppProdRow[6];
											currentSFOppProd.Quoted_Number_of_Transactions__c = decimal.ValueOf(currentOppProdRow[7]);
											currentSFOppProd.Quoted_Number_of_Units_of_Time__c = decimal.ValueOf(currentOppProdRow[8]);
											currentSFOppProd.Quoted_One_Time_Fee__c = decimal.ValueOf(currentOppProdRow[9]);
											currentSFOppProd.Quoted_One_Time_Type__c = currentOppProdRow[10];
											currentSFOppProd.Quoted_Time_Based_Fee__c = decimal.ValueOf(currentOppProdRow[11]);
											currentSFOppProd.Quoted_Transaction_Fee__c = decimal.ValueOf(currentOppProdRow[12]);																	
											currentSFOppProd.Quoted_Transaction_Type__c = currentOppProdRow[13];
											currentSFOppProd.Quoted_Unit_of_Time__c = currentOppProdRow[14];											
										} else {
											//set isError = true and break the loop, the error will be thrown by the parent Else in the parent IF(), which will also break the parent FOR()
											isError = true;
											break;																					}
									}							
								}	
							} else {
								//errorMessage = 'The selected Product/Service records in SF do not match those in the uploaded .csv.  If you have made any changes to the Product/Services and/or Pricing records listed for this Opportunity, you MUST export a new .csv for the ROI, re-enter the quoted prices there and upload the new .csv file it creates.';
								ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'The selected Product/Service records in SF do not match those in the uploaded .csv.  If you have made any changes to the Product/Services and/or Pricing records listed for this Opportunity, you MUST export a new .csv for the ROI, re-enter the quoted prices there and upload the new .csv file it creates.'));								
								break;								
							}														
						}		
						If(isError == false){
							//at this point all updates can be made:					
							database.update(Opp);
							database.update(oppProdsInSF);
							//errorMessage = '';
							//successMessage = 'File successfully uploaded and Opportunity updated.  Please close this window and refresh the Opportunity page.';
							ApexPages.addmessage(new ApexPages.message(ApexPages.severity.CONFIRM, 'File successfully uploaded and Opportunity updated.  Please close this window and refresh the Opportunity page.'));
						}						
					} else {
						//throw Error for when list of Opp Prod IDs do not match.
						//errorMessage = 'The list of Opportunity Products in the uploaded .csv does not match the list for this Opportunity in SF.  If you added or removed an Opportunity Product for this Opportunity, you MUST export a new .csv for the ROI, re-enter the quoted prices there and upload the new .csv file it creates.';
						ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'The list of Opportunity Products in the uploaded .csv does not match the list for this Opportunity in SF.  If you added or removed an Opportunity Product for this Opportunity, you MUST export a new .csv for the ROI, re-enter the quoted prices there and upload the new .csv file it creates.'));
					}					 
				}													
			} else{
				//errorMessage = 'The Opportunity in the selected .csv does not match the selected Opportunity in SF.  Please make sure you are selecting the correct Opportunity and .csv file when uploading.  If you still receive this error you may need to start over with a fresh export from SF.  Please contact SHS SF Support at SHSSalesForceSupport@sabre.com if you have any questions or concerns.';
				ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'The Opportunity in the selected .csv does not match the selected Opportunity in SF.  Please make sure you are selecting the correct Opportunity and .csv file when uploading.  If you still receive this error you may need to start over with a fresh export from SF.  Please contact SHS SF Support at SHSSalesForceSupport@sabre.com if you have any questions or concerns.'));								
			}									    		
    	}
    }
    
    /* begin standard Parser code.  getResults returns the parsedCSV in a List<List<String>> */

 

 

Export VF Page:

<apex:page controller="ROIExportController" contentType="application/csv#{!OpportunityName}.csv" cache="true" showheader="false">
<apex:outputText value="Opportunity Data"/>
    ID,Name,Analyst Name,Contract Length,Number of Properties,Rooms,Currency, Record Type Name, Amount, Pricing Tool Margin
   {!OpportunityData}
    Account Data
    Account ID,Account Name,Shipping Street,Shipping City,Shipping State,Shipping Country,Shipping Zip,Phone Number,Customer Type,Region
    {!AccountData}
    Exchange Rates
    CAD,EUR,GBP,SGD,AUD
    {!ExchangeRateData}
    Products
    Opportunity Product ID,Pricing Record ID,Product/Service ID,Quoted: Recurring Fee,Quoted: Fee Recurrence,Quoted: Multiplier Fee,Quoted: Multiplier Type/Rec,Quoted: Number of Transactions,Quoted: Number of Units of Time,Quoted: One-Time Fee,Quoted: One-Time Type Fee,Quoted: Time-Based Fee,Quoted: Transaction Fee,Quoted: Transaction Type,Quoted: Unit of Time,Rack: Recurring Fee,Rack: Fee Recurrence,Rack: Multiplier Fee,Rack: Multiplier Type/Rec,Rack: One-Time Fee,Rack: One-Time Type,Rack: Time Based Fee,Rack: Transaction Fee,Rack: Transaction Type,Rack: Unit of Time
    <apex:repeat value="{!OpportunityProductData}" var="currentOppProd">
        {!currentOppProd.Id},{!currentOppProd.Pricing_Record__c},{!currentOppProd.Product_Service__c},{!currentOppProd.Quoted_Recurring_Fee__c},{!currentOppProd.Quoted_Fee_Recurrence__c},{!currentOppProd.Quoted_Multiplier_Fee__c},{!currentOppProd.Quoted_Multiplier_Type_Rec__c},{!currentOppProd.Quoted_Number_of_Transactions__c},{!currentOppProd.Quoted_Number_of_Units_of_Time__c},{!currentOppProd.Quoted_One_Time_Fee__c},{!currentOppProd.Quoted_One_Time_Type__c},{!currentOppProd.Quoted_Time_Based_Fee__c},{!currentOppProd.Quoted_Transaction_Fee__c},{!currentOppProd.Quoted_Transaction_Type__c},{!currentOppProd.Quoted_Unit_of_Time__c},{!currentOppProd.Rack_Recurring_Fee__c},{!currentOppProd.Rack_Fee_Recurrence__c},{!currentOppProd.Rack_Multiplier_Fee__c},{!currentOppProd.Rack_Multiplier_Type_Rec__c},{!currentOppProd.Rack_One_Time_Fee__c},{!currentOppProd.Rack_One_Time_Type__c},{!currentOppProd.Rack_Time_Based_Fee__c},{!currentOppProd.Rack_Transaction_Fee__c},{!currentOppProd.Rack_Transaction_Type__c},{!currentOppProd.Rack_Unit_of_Time__c}
    </apex:repeat>
</apex:page>

 

finally the Test Code so far:

@isTest
private class TESTROIExportAndImportController {

    static testMethod void myUnitTest() {
    	User u = [Select LastName, Id, FirstName, Email From User WHERE IsActive = True AND UserType = 'Standard' AND UserRole.Name LIKE '%Admin%' LIMIT 1];
    	Account a = new Account(Name = 'Test Account', OwnerID = u.id);
        insert a;
        Contact c = new Contact(AccountID = a.id, OwnerID = u.Id, FirstName = u.FirstName, LastName = u.LastName, Email = u.Email);
    	insert c;
        Opportunity o = new Opportunity(Name = 'Test Opp', AccountID = a.Id, StageName = 'Qualified', CloseDate = date.Today(), OwnerID = u.id);
        insert o;
        Opportunity_Product__c oP = new Opportunity_Product__c (Opportunity_Name__c = o.id);
        insert oP;
        
        //set current page to that of the ROIExport page.
        PageReference pg = Page.ROIExport;
        pg.getParameters().put('id', o.Id);
        pg.getParameters().put('accountId', a.Id);
        Test.setCurrentPage(pg);
        
        //Add parameters to page URL
        ApexPages.currentPage().getParameters().put('id', o.Id);
        ApexPages.currentPage().getParameters().put('accountId', a.Id);
        
        
        
        //instantiate the Controller and then assign all methods in the ROIExportController class to variables
        ROIExportController exportController = new ROIExportController();
        String OppID = exportController.getOpportunityID();
        String OppName = exportController.getOpportunityName();
        String OppData = exportController.getOpportunityData();
        String AccountData = exportController.getAccountData();
        String ExchangeData = exportController.getExchangeRateData();
        List<Opportunity_Product__c> OppProds = exportController.getOpportunityProductData();
        
        
        
        Blob csvFile = pg.getContent();// Apexpages.currentPage().getContent() does not work either.
        System.debug(csvFile);
        
        
    }
}

 

 

 

Thanks in advance for any and all help!

Jeremy Stender

Hi, I want to create a master list of options that can then be selected by a user to report status against.

 

When the user logs in they then get to see only the selection options and can then enter a status report.

 

Any help appreciated.

My faithful saviors,

I have tried a dozen different ways of doing the below mentioned by reading through the discussion boards for ideas.  It sounds SO simple, but its very frustrating.

 

I have one VF page.

I have two objects (one standard, one custom)

I want to display a tab panel on my VF page that shows a list on one tab from the standard object, and a list on the second tab from the custom object.

 

I have the list working great for the standard object.  No issues there.  But now I want to display the custom object list, and all I get are errors.  I understand that there is an issue with controllers here, but I am not able to get an effective and clear result from the 9,215 different suggested ways to configure my pages and classes.

 

It doesnt help that I suck at apex.

 

So ... here goes:

<apex:page showHeader="false" sidebar="false" standardController="Opportunity" tabStyle="Opportunity" extensions="getAllRecords">
                                                                  
                 <apex:pageBlock id="block1" mode="detail" rendered="true">
                    <apex:tabPanel selectedTab="MaintenanceRenewals" id="theTabPanel"  tabClass="activeTab" inactiveTabClass="inactiveTab"  width="100%">                    
                        <apex:tab label="Maintenance Renewals" name="MaintenanceRenewals" labelWidth="250px" >
                            <apex:pageBlockSection id="underFive" title="Within 5 Days or Past Due Maintenance Renewals" columns="1" collapsible="false"> 
                               <apex:PageBlockTable value="{!DuePastDue}" var="records" rowClasses="brightRed1,brightRed2"> 
                                    <apex:column value="{!records.CloseDate}" headerValue="Renewal Due By" width="16%"/>
                                    <apex:column headerValue="Manufacturer Name" width="20%">
                                        <apex:outputLink target="URLFOR('//006/e')" value="/{!records.Id}">{!records.Name}</apex:outputLink>
                                    </apex:column>
                                    <apex:column value="{!records.Contract_Owner__c}" headerValue="Contract Owner" width="16%"/>
                                    <apex:column value="{!records.StageName}" headerValue="Stage" width="16%"/>
                                    <apex:column value="{!records.Renewal_Status__c}" headerValue="Renewal Status" width="16%"/>
                                    <apex:column value="{!records.Amount}" headerValue="Renewal Amount" width="16%" />
                                </apex:pageBlockTable>                                 
                             <apex:form >
                                 <input type="button" value="Hide / Unhide Renewals" onClick="collapse('{!$Component.fiveThirty},{!$Component.thirtySixty},{!$Component.over60}');return false;">
                                 </input>
                             </apex:form>
                            </apex:pageBlockSection>                                                                  
                            <apex:pageBlockSection id="fiveThirty" title="5-30 Days Maintenance Renewals" columns="1" collapsible="false"> 
                               <apex:PageBlockTable value="{!FiveThirty}" var="records" rowClasses="red1,red2">
                                    <apex:column value="{!records.CloseDate}" headerValue="Renewal Due By" width="16%"/>
                                    <apex:column headerValue="Manufacturer Name" width="20%">
                                        <apex:outputLink target="URLFOR('//006/e')" value="/{!records.Id}">{!records.Name}</apex:outputLink>
                                    </apex:column>
                                    <apex:column value="{!records.Contract_Owner__c}" headerValue="Contract Owner" width="16%"/>
                                    <apex:column value="{!records.StageName}" headerValue="Stage" width="16%"/>
                                    <apex:column value="{!records.Renewal_Status__c}" headerValue="Renewal Status" width="16%"/>
                                    <apex:column value="{!records.Amount}" headerValue="Renewal Amount" width="16%" />
                                </apex:pageBlockTable>                                    
                            </apex:pageBlockSection>
                            <apex:pageBlockSection id="thirtySixty" title="31-60 Days Maintenance Renewals" columns="1" collapsible="false">
                               <apex:PageBlockTable value="{!ThirtySixty}" var="records" rowClasses="yellow1,yellow2">
                                   <apex:column value="{!records.CloseDate}" headerValue="Renewal Due By" width="16%"/>
                                    <apex:column headerValue="Manufacturer Name" width="20%">
                                        <apex:outputLink target="URLFOR('//006/e')" value="/{!records.Id}">{!records.Name}</apex:outputLink>
                                    </apex:column>
                                    <apex:column value="{!records.Contract_Owner__c}" headerValue="Contract Owner" width="16%"/>
                                    <apex:column value="{!records.StageName}" headerValue="Stage" width="16%"/>
                                    <apex:column value="{!records.Renewal_Status__c}" headerValue="Renewal Status" width="16%"/>
                                    <apex:column value="{!records.Amount}" headerValue="Renewal Amount" width="16%" />
                                </apex:pageBlockTable>
                            </apex:pageBlockSection>
                            <apex:pageBlockSection id="over60" title="61-120 Days Maintenance Renewals" columns="1" collapsible="false">
                                <apex:PageBlockTable value="{!OverSixty}" var="records" rowClasses="green1,green2">
                                   <apex:column value="{!records.CloseDate}" headerValue="Renewal Due By" width="16%"/>
                                    <apex:column headerValue="Manufacturer Name" width="20%">
                                        <apex:outputLink target="URLFOR('//006/e')" value="/{!records.Id}">{!records.Name}</apex:outputLink>
                                    </apex:column>
                                    <apex:column value="{!records.Contract_Owner__c}" headerValue="Contract Owner" width="16%"/>
                                    <apex:column value="{!records.StageName}" headerValue="Stage" width="16%"/>
                                    <apex:column value="{!records.Renewal_Status__c}" headerValue="Renewal Status" width="16%"/>
                                    <apex:column value="{!records.Amount}" headerValue="Renewal Amount" width="16%" />
                                </apex:pageBlockTable>
                            </apex:pageBlockSection>     
                        </apex:tab>
                        <apex:tab label="COMING SOON" name="scorecard" labelWidth="250px" >
                            <apex:pageBlockSection title="New things to come!" columns="1" collapsible="false">
                               
                            </apex:pageBlockSection>
                        </apex:tab>                        
                    </apex:tabPanel>
                  </apex:pageBlock>
                </div>
            </div>
        </div>
    </body>   
</html>
</apex:page>

 I removed all the javascript and css as it was not relevant and took up space.

public class getAllRecords {
    public getAllRecords(ApexPages.StandardController Controller) {
    }  
    //method to get all maint. renewals
    public Opportunity[] getRecordDetail(){
    //declare and instantiate recordList
    Opportunity[]recordList = new List<Opportunity>();
    //SOQL call to get all the records
        recordList = [SELECT Name,
                             Contract_Owner__c,
                             Amount,
                             CloseDate,
                             StageName,
                             Renewal_Status__c
                        FROM Opportunity
                       WHERE AccountId IN 
                            (SELECT AccountId 
                             From User 
                             WHERE username=:UserInfo.getUsername())
                         AND (Stagename = 'Baseline' OR Stagename = 'Review' OR Stagename = 'Execution' OR Stagename = 'Customer Input Required')
                       ORDER BY CloseDate];
       return recordList;
    }
    //method to strip out pastdue to 5 days from close_date
    public Opportunity[] getDuePastDue(){
    List<Opportunity> recordList = getRecordDetail();
    List<Opportunity> pastDueList = new List<Opportunity>();
        for(Opportunity obj:recordList) {
                if(obj.CloseDate < (system.today() +5)) {
                   pastDueList.add(obj);
                }    
        }
    return pastDueList;
    }
    //method to strip out 5-30 days from close_date
    public Opportunity[] getFiveThirty(){
    List<Opportunity> recordList = getRecordDetail();
    List<Opportunity> fiveThirtyList = new List<Opportunity>();
        for(Opportunity obj4:recordList) {
            if((obj4.CloseDate > (system.today() + 5)) && (obj4.CloseDate <= (system.today() + 30)))  {
                fiveThirtyList.add(obj4);
            }
        }
    return fiveThirtyList;
    }
    //method to strip out over 60 days from close date
    public Opportunity[] getOverSixty(){
        List<Opportunity> recordList = getRecordDetail();
        List<Opportunity> overSixtyList = new List<Opportunity>();
            for(Opportunity obj2:recordList) {
                if((obj2.CloseDate <= (system.today() + 120)) && (obj2.CloseDate > (system.today() + 60))){
                    overSixtyList.add(obj2);
                }
            }
    return overSixtyList;
    }    
    //method to strip out 30-60 days from close date
    public Opportunity[] getThirtySixty(){
    List<Opportunity> recordList = getRecordDetail();
    List<Opportunity> thirtySixtyList = new List<Opportunity>();
        for(Opportunity obj3:recordList) {
            if((obj3.CloseDate <= (system.today() + 60)) && (obj3.CloseDate > (system.today() + 30))) {
                thirtySixtyList.add(obj3);
            }
        }
    return thirtySixtyList;
    }  
}

 Now what I need to do us get the custom object list inserted into the "Coming Soon" section.

 

Could someone please give me a code sample to push me in the right direction?  Much appreciated!!

What is the Full form of APEX A - Means ?? P - Means ?? E - Means ?? X - Means ?? Is there any fullform or its a general english word

Just started using Force.com IDE and I've got some questions, probably very simple. Sorry if these seem inconsequential or a waste of time - they aren't very critical questions, but I just like to fully comprehend the programs I use.

 

 

So, Ideally I'd like my local files to reflect whats in production as accurately as possible, so I do not have to do all this logging in and selecting of specific data every time I start something new. The question is if doing something like that is advisable, or a poor idea?   

-----------------------------------

I'm sure they aren't duplicates, but I was wondering why are there two listings of custom fields on custom objects when choosing the metadata components on creation of a new project.?