• BarryPlum
  • NEWBIE
  • 50 Points
  • Member since 2007

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

I have based this code off of the VF Quote tool created by Salesforce.com Labs a couple of years back.

 

Esentially, I'm trying to take similar line items and get rid of them from the List and aggregate the quantity.  I end up with extra lines in my list for some reason.  I have a feeling it's because I'm trying to remove elements while in the loop, but I can't figure out another way to do this.

 

Any help is appreciated.

 

 

Quote_Item__c[] items = new Quote_Item__c[]{};
Quote_Item__c[] qiList = new Quote_Item__c[]{};

for(OpportunityLineItem oli:[select Maintenance_End__c, Maintenance_Start__c, quantity, unitprice, ListPrice, pricebookEntry.product2.name, pricebookEntry.product2id, pricebookEntry.product2.sort__c from opportunitylineitem where opportunityid = :opptyId order by pricebookEntry.product2.sort__c ASC]) 
{
	qiList.add(new Quote_Item__c(quantity__c = oli.quantity, unit_price__c = oli.unitprice, List_Price__c = oli.ListPrice, quote__c = renewalQuote.id, name = oli.pricebookentry.product2.name, sort__c = oli.pricebookentry.product2.sort__c, product__c = oli.pricebookentry.product2id, Maintenance_End__c = oli.Maintenance_End__c, Maintenance_Start__c=oli.Maintenance_Start__c));
}

// Iterate through working list
while(qiList.size()>0){
	Set<Id> removeAddress = new Set<Id>();
	Quote_Item__c qiTemp = qiList.get(0);
	removeAddress.add(qiTemp.Id);
	for(Quote_Item__c qi :qiList){
		If(qi.name==qiTemp.name && qi.unit_price__c==qiTemp.unit_price__c && qi.Maintenance_End__c==qiTemp.Maintenance_End__c && qi.Maintenance_Start__c==qiTemp.Maintenance_Start__c)
			{
				removeAddress.add(qi.id);
				qiTemp.Quantity__c += qi.Quantity__c;
			}
	}
	items.add(qiTemp);
	for(Id a : removeAddress){
		for(Integer i=0; i < qiList.size(); i++){
			if(a == qiList.get(i).Id)
			{
				qiList.remove(i);
			}
		}
	}
}

 

 

public class BusTicketExtension { private final BusTicket__c BusTicket; public BusTicketExtension (ApexPages.StandardController stdController) { this.BusTicket = (BusTicket__c)stdController.getRecord(); } public PageReference save() { insert(BusTicket); PageReference p = Page.NewSystemTicket; p.getParameters().put('msg','Thank you for submitting your ticket, someone will get back to you soon.'); p.setRedirect(true); return p; } public static testMethod void testBusTicketExtension() { PageReference pageRef = Page.NewSystemTicket; Test.setCurrentPage(pageRef); BusTicket__c bt = new BusTicket__c(system__c='Salesforce.com',category__c='access',title__c='MyTest'); ApexPages.StandardController btc = new ApexPages.Standardcontroller(bt); BusTicketExtension controller = new BusTicketExtension(btc); String nextPage = controller.save().getUrl(); System.assertEquals('/apex/newsystemticket?msg=Thank+you+for+submitting+your+ticket%2C+someone+will+get+back+to+you+soon.',nextPage); BusTicket__c t=[SELECT system__c FROM BusTicket__c WHERE createdDate = TODAY and title__c = 'MyTest' ]; System.assertEquals('Salesforce.com',t.system__c); } }

 I'm not really worried about the validity of the test, since the only reason I wrote the code was to support public submission to the custom object.  I've also written a VF page that's referenced in the above controller, so I can just ship them back to the input page with a message thanking them for their submission.

 

I have tried every different way I know of to deploy this code from a sandbox to production.  In my IDE AND in the sandbox org, running tests on the class pass with 100% test coverage.

 

I've tried running Deploy to server in the IDE

I've tried creating a Change Set.

 

Thanks in advance if anyone sees anything I'm missing.

 

Barry 

When a user clicks on a link, I want to open a new window and do an HTTP post to a non-SFDC URL. I don't want to use httpRequest/httpResponse class because the response is greater than 100K and SFDC restricts to 100K.


What is the best way to do this?

 

SFDC visual force pages only post to SFDC addresses. 

I'm 99% to a page with a decent layout for internal users.  This is probably trivial, but for whatever reason, I can't find it.  We only have one community, and it seems really stupid to force people to choose the community when they are creating an idea.

 

How do I 'hard code' the communityid in the VF page.

 

Here is my code that works, if I search and then select, my one community:

 

<apex:page standardController="idea">

<apex:form >

<apex:pageBlock title="New Idea">

<apex:pageBlockButtons >

<apex:commandButton action="{!save}" value="Save"/>

</apex:pageBlockButtons>

<apex:pageBlockSection title="Idea Details" columns="1">

<apex:inputField style="width:250px" value="{!idea.title}"/>

<apex:inputField required="true" value="{!idea.CommunityId}"/>

<apex:inputField required="true" value="{!idea.category}"/>

<apex:inputField required="true" value="{!idea.Requested_Priority__c}"/> <apex:inputField required="true" style="width:600px" value="{!idea.Business_Case__c}"/>

<apex:inputField required="true" style="width:600px" value="{!idea.body}"/>

</apex:pageBlockSection>

</apex:pageBlock>

</apex:form>

</apex:page>

 

 I've tried various tags, but there should be some way to just say that {!idea.communityid} = <id>

 

Also, I hope the answer isn't that I have to write a controller extension JUST to hard code this value... 

Message Edited by BarryPlum on 12-22-2009 09:37 AM

Salesforce.com just released Knowledge and we were able to get a few licenses to kick the tires on it.  But there are no sample visualforce pages for doing a search or displaying an article to the public.

 

I'm having a really hard time searching for information because it is so new and "knowledge" pulls up the Public Knowledgebase information regarding Solutions and "Articles" (which is what Knowledge calls it's records) brings up TONS of hits because everything on here is an article.

 

If anyone has implemented this, or has some VF code that they can share, I would appreciate it. 

I have a controller that I wrote to extend the Opportunity standard controller.  Essentially it supports a VF page that gives a list of Opportunities that fit custom criteria and allow you to update some fields on those opportunities.  Like an editable list view.

 

The code is working great, but I can't seem to get ANY test coverage.  I am still very new at controllers, only modifying them up until this point, so I've culled together some things that I thought should work.

 

Controller Extension:

 

public with sharing class myContractController {

List<Opportunity> lstOpportunity;

Integer numDays = integer.valueOf(ApexPages.currentPage().getParameters().get('days'));

Date dtStart = date.today();

Date dtEnd = dtStart.addDays(numDays);

public myContractController(ApexPages.StandardController controller) {

lstOpportunity = (List<Opportunity>)[Select Id, Name, Hold_MR_Follow_up__c, ContractEndDate__c, StageName, Maintenance_Email__c, Special_Handling__c

From Opportunity

where Hold_MR_Follow_up__c = false AND IsClosed = false AND ContractEndDate__c > :dtStart AND ContractEndDate__c < :dtEnd ORDER BY ContractEndDate__c ASC];

}

public List<Opportunity> getlstOpportunity(){

return lstOpportunity;

}

public PageReference save() {

update lstOpportunity;

return ApexPages.currentPage();

}

}

 VF Page:

 

<apex:page standardController="Opportunity" extensions="myContractController">

<apex:form >

<apex:sectionHeader title="Opportunities with Contract End Dates within {!$CurrentPage.parameters.days} days"/>

<apex:pageBlock mode="edit">

<apex:pageMessages />

<apex:pageBlockSection title="Opportunities" >

<apex:pageblocktable value="{!lstOpportunity}" var="AC" id="opportunityTable">

<apex:column headerValue="Hold MR Follow Up">

<apex:inputField value="{!AC.Hold_MR_Follow_up__c}" />

</apex:column>

<apex:column headerValue="Opportunity">

<apex:outputLink value="/{!AC.Id}" style="white-space:nowrap;" target="_blank">{!AC.Name}</apex:outputLink>

</apex:column>

<apex:column value="{!AC.ContractEndDate__c}"></apex:column>

<apex:column headerValue="Stage" style="white-space:nowrap;">

<apex:outputField value="{!AC.StageName}"></apex:outputField>

</apex:column>

<apex:column value="{!AC.Special_Handling__c}"></apex:column>

<apex:column value="{!AC.Maintenance_Email__c}"></apex:column>

</apex:pageblocktable>

</apex:pageBlockSection>

<apex:pageBlockButtons location="bottom">

<apex:commandButton value="Save" action="{!save}"/>

<apex:commandButton value="Cancel" action="{!cancel}"/>

</apex:pageBlockButtons>

<apex:pageBlockSection title="Links">

<apex:outputLink value="/apex/MRChecklist?days=67">67 Day Checklist</apex:outputLink><br/><br/>

<apex:outputLink value="/apex/MRChecklist?days=37">37 Day Checklist</apex:outputLink><br/><br/>

<apex:outputLink value="/apex/MRChecklist?days=21">21 Day Checklist</apex:outputLink><br/><br/>

<apex:outputLink value="/apex/MRChecklist?days=14">14 Day Checklist</apex:outputLink><br/><br/>

</apex:pageBlockSection>

</apex:pageBlock>

</apex:form>

</apex:page>

 

 And my attempt at a test class:

 

public class myContractControllerTest {

public static testMethod void testmyContractController() {

Opportunity o = new Opportunity(name='testOpp', closeDate=date.Today(),Hold_MR_Follow_up__c=false, ContractEndDate__c=date.today().addDays(20), StageName='Qualified', Maintenance_Email__c='bplum@tableausoftware.com', Special_Handling__c=false);

insert o;

 

ApexPages.StandardController oppCtrl = new ApexPages.Standardcontroller(o);

myContractController controller = new myContractController(oppCtrl);

PageReference testPageRef = new PageReference('/apex/MRChecklist');

Test.setCurrentPage(testPageRef);

String nextPage = controller.save().getUrl();

System.assertEquals('/apex/failure?error=noParam', nextPage);

ApexPages.currentPage().getParameters().put('days', '67');

Test.setCurrentPage(testPageRef);

String myPage = controller.save().getUrl();

}

}

 

If anyone can give me some advice, it would be great!

 

 

 

 

Message Edited by BarryPlum on 09-24-2009 01:55 PM
Message Edited by BarryPlum on 09-24-2009 02:00 PM

Is there somewhere where I can check how my Eclipse editor handles Force.com syntax coloring?  None of the syntax coloring is shown, everything is black.  I've tried changing the customizable Java syntax coloring, which has no effect.

 

I'm running Eclipse 3.4.2 on XP Pro with SP 3, if any of that makes a difference.

 

Thanks 

There is a known issue where Tasks created via Mass Emailing are not set to Type=Email.  I'm trying to develop an Apex class (possibly a custom controller for VF) that will allow me to have someone go in and hit a button that will set all the Nulls to Email for the Tasks created by Mass Email.

 

Here is my code, which works using anonymous execution, however, it came close to the governance limits (10k).

 

public class nullTaskCleanup { for (Task[] badTypes : [select Id, Type from Task where Type=Null AND Subject LIKE '%Email%']) { for(Task t : badTypes) { t.type = 'Email'; } update badTypes; } }

 

 1. Why am I running into governance limits, I thought using the code above would 'chunk' it and avoid this issue.

 

2. When I try to save the above, I get an error saying that it expected a } on the second line.

 

Thanks for any help on this.

Barry

 

I'm using the code sample Quote2PDF (here) and I love it.  The one problem I have is that when I create the PDF quote, the items seem to come in randomly.  I tried changing the layout of the quote page.  I've tried creating a custom getter method to sort them, but they still seem to have a mind of their own. 

Is there any way to sort a dataTable?

When I tried to create the custom getter method, I kept getting unexpected token errors on my SOQL statement when I put Order by on the end.

Anyone have any ideas?

Thanks,
Barry