• 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);
			}
		}
	}
}

 

 

I started to write it properly, but I ran into some issues and fell back to some bad practices to get the trigger working.  It works, tests fine, but I just got a DML governance limit email on it.  My suspicion is that email to case inserted enough cases to exceed the limit.

 

Purpose and requirements: Tracking case changes and measuring time that a case is in any status.  Created a custom object called csh__c that holds some case values.  When a case is created and any time those values change, a record is created in the new object with the values of the fields.  There is also a custom field on the case object that holds the last record id that was created.  This allows us to use our visualization software to make a gantt chart like bar that shows the life-cycle of a case.

 

My problem came while trying to figure out how to handle getting the Id of the custom record created back into the case.  For the updates, it was simple, the trigger.new had the case id in it already, I could just update the trigger and it works.  The inserts were more complicated, so I had do use an after insert to make sure I got the case id.  Which meant I needed to do yet another DML statement to update each case.

 

I think I was close, but I'm trying to decide whether I should break it into two triggers and deal with them separately or continue down the path of refining this one trigger.

 

Here's the code, with the original stuff commented out that would have made it bulk safe:

 

trigger cshTrigger on Case (after insert, before update) {

	// create array of case history records for populating
	// csh__c[] cshs = new csh__c[]{};

	// create a string to hold the id of the lead or contact
	String leadcontactid;
	
	// Start iteration thorough cases
	for (Case c : Trigger.new) {

		// check for lead AND contact, set value for contact if it exists
		if(c.ContactId != Null) {
			leadcontactid = String.valueOf(c.ContactId);
		} else {
			leadcontactid = String.valueOf(c.Lead_Name__c);
		}

		// check to see if this is an insert
		if (Trigger.isInsert){
		csh__c newCsh = new csh__c(cid__c = c.id);
		newCsh.accountid__c = c.AccountId;
		newCsh.leadcontactid__c = leadcontactid;
		newCsh.userid__c = System.Userinfo.getUserId();
		newCsh.bugnumber__c = c.BugNumber__c;
		newCsh.priority__c = c.Priority;
		newCsh.impact__c = c.Impact__c;
		newCsh.urgency__c = c.Urgency__c;
		newCsh.casetype__c = c.Type;
		newCsh.status__c = c.Status;
		newCsh.statusdetail__c = c.Status_Detail__c;
		newCsh.closedreason__c = c.Case_Closed_Reason__c;
		newCsh.requesttype__c = c.Request_Type__c;
		newCsh.product__c = c.Product__c;
		newCsh.productversion__c = c.Version__c;
		// cshs.add(newCsh);
		insert newCsh;
		Case updateCase = [select Id from Case where Id=:c.id];
		updateCase.pcshid__c = newCsh.id;
		update updateCase;
		} else {
			// not an insert, check if any fields changed
			for (case oc : trigger.old){
				if (c.Priority != oc.Priority || 
					c.Impact__c != oc.Impact__c ||
					c.Urgency__c != oc.Urgency__c ||
					c.Type != oc.Type ||
					c.Status != oc.Status ||
					c.Status_Detail__c != oc.Status_Detail__c ||
					c.Case_Closed_Reason__c != oc.Case_Closed_Reason__c ||
					c.Request_Type__c != oc.Request_Type__c ||
					c.Product__c != oc.Product__c ||
					c.Version__c != oc.Version__c ||
					c.AccountId != oc.AccountId ||
					c.ContactId	!= oc.ContactId ||
					c.Lead_Name__c != oc.Lead_Name__c ||
					c.bugnumber__c != oc.bugnumber__c
					) {
						csh__c newCsh = new csh__c(cid__c = c.id);
						newCsh.pid__c = c.pcshid__c;
						newCsh.accountid__c = c.AccountId;
						newCsh.leadcontactid__c = leadcontactid;
						newCsh.userid__c = System.Userinfo.getUserId();
						newCsh.bugnumber__c = c.BugNumber__c;
						newCsh.priority__c = c.Priority;
						newCsh.impact__c = c.Impact__c;
						newCsh.urgency__c = c.Urgency__c;
						newCsh.casetype__c = c.Type;
						newCsh.status__c = c.Status;
						newCsh.statusdetail__c = c.Status_Detail__c;
						newCsh.closedreason__c = c.Case_Closed_Reason__c;
						newCsh.requesttype__c = c.Request_Type__c;
						newCsh.product__c = c.Product__c;
						newCsh.productversion__c = c.Version__c;
						// cshs.add(newCsh);
						insert newCsh;
						c.pcshid__c = newCsh.id;
				}
			}
		}
	}
/*	//System.debug(cshs);
	// insert array
	insert cshs;

	// create a map of ids from the insert to update the new cases
	Map<ID,ID> pids = new Map<ID,ID>();
	for (csh__c ch : cshs) {
		pids.put(ch.cid__c,ch.Id);
	}
	System.debug(pids);

	// update the cases for the case history records
	for (case cu : Trigger.new){
		if (Trigger.isInsert){
			Case updateCase = [select Id from Case where Id=:cu.id];
			updateCase.pcshid__c = pids.get(cu.id);
			update updateCase;
			
		} else {
		cu.pcshid__c = pids.get(cu.id);
		}
	} */
	System.debug(Trigger.new);
}

 

 

Thanks in advance for your help!

 

Barry

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 

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

I am trying to create an visualforce page to leverage the inline editing function introduced last year for views. 

 

I want to have a block that has an input text field to specify the value of a filter criteria for the view.  Ideally I'd just leverage the standard controller for leads.  The "search" is only going to check that the Company field contains the value in the input field.

 

Then there would be a block below, populated with the view generated from clicking the submit button.

 

I've got the view created, I just need to figure out how to tell the view to filter on something.

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

 

This tag works: {!relatedTo.Owner.Name}
This tag does NOT work: {!relatedTo.Owner.Title}

I've also tried using {!User.Title} and {$User.Title}

Any suggestions on how to get to the rest of the Owner fields?
Thanks!
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
I have a custom object that can be related to either a Lead or a Contact.  I want to search both objects by the email address in the custom object.

I know I should probably create a map, but I'm having difficulty getting to the point where I can actually make the trigger work.

Here is where I started, create a set with all the emails from the trigger:

Code:
SET<String> emails = new SET<String>();
for (Registration__c r : Trigger.new) {
 if (r.email__c != null) {
  emails.add(r.email__c);
 }
}

Now, I want to search for matches from Leads and contacts based on that set... Here's what I thought I would do:
Code:
Map<ID, Contact> conMap = new Map<ID, Contact>([select id,email from Contact where email IN :emails]);
Map<ID, Lead> leadMap = new Map<ID, Lead>([select id, email from Lead where email IN :emails]);

Still think this may work, but the problem is, how do I either get that into a single <String,ID> map where I can iterate through the trigger and update the relationship fields or search each map individually by the email in the trigger to get the ID for the relationship fields.

Thanks in advance for the advice.

 
 

I've created a visualforce page that uses the Opportunity controller to iterate through the opportunity line items and I want to reference the email value from the contact that's marked Primary on the Opportunity.

This seems pretty straightforward, but I'm not sure how to do it.

I've been able to traverse the relationships to get to field values on the other objects, but essentially I have to do a query to get the ContactId from OpportunityContactRole where IsPrimary is true and then use that Id to get the email address from the contact object.

I could probably create a controller extension to do this, but it seems like it should be possible with a formula in a merge field.

Thanks in advance.

Barry
I am looking for an experienced developer to help me with my integration efforts.  Part time is possible, but we're looking for someone who wants to join a winning team.  Please don't reply if you're with a consulting company. 

I have done quite a bit with my limited knowledge of APEX and S-controls but I need someone to take this to the next level.  We need to be able to create custom integration points for our Licensing systems and e-commerce systems as well as streamlining existing solutions.

Our company is located in the "center of the universe," the Fremont neighborhood in Seattle. 

If you are interested or know someone who would be, please reply to this post or email me directly: bplum@tableausoftware.com

Thanks,
Barry
There are a couple of posts on here that indicate that multiple elements in a response object is not supported by Salesforce.com. 

I'm dealing with a system that, unfortunately, I can't modify.  I'm getting the first element in my code, and I assume that I'm not getting the second element (the one that I want) because of this limitation.

Anyone have any ideas how to work around this?

Thanks in advance.
Barry
Is there a crc32 method/function/class available in APEX anywhere?  Or, is there some way to build one?

We want to have all opportunities that are processed by sales operations become locked so that they cannot be moved around except by Admins.

The approval process works fine for that, but I've discovered that while they can't directly change ownership of the opportunity, if they transfer ownership of the Account AND they are the owner of the locked opportunity AND check the Transfer closed opportunities checkbox on the account transfer gui, it will actually transfer the locked opportunities.  Salesforce.com support says this is a "feature."

I figure the only way to fix this "feature" is to write a 'before update' trigger on opportunity to check if the opportunity is locked and if it is, roll back any changes being made to it unless you are an administrator (which kind of sounds like what locking is supposed to do, but hey, who am I to judge).

My question (finally) is: how do I determine that the record is actually locked? 

There are a couple of child relationships (ProcessInstances and ProcessSteps)  that appear to be related, but niether of them have a field that says anything about Locked or IsLocked, there is an IsPending in ProcessSteps, but if it is no longer pending, but still locked, that field will not be useful.

I could probably add yet another field to my object and have the approval process update that field to say that it's locked, but that just seems silly, as there has to be some way to determine whether the record is or is not locked.

Thanks,
Barry
I wrote a trigger to fix the case where a task is created by automated systems with no Type.  We use type in analysis all the time, but not all integrations (including Mass Email within salesforce.com) will set the type.  Here is the original post.

So, here's the trigger, which works perfectly interactively:
Code:
trigger nullTaskType on Task (before insert,before update) {
  for (Task newTask : Trigger.new) {
   if (newTask.Type == null) {
    if (newTask.subject.startsWith('Email:') || 
     newTask.subject.startsWith('Brochure')||
     newTask.subject.startsWith('Mass Email') 
     ) {
    newTask.Type = 'Email';
  }
  if (newTask.subject.contains('Website Visit')) {
   newTask.Type = 'Website Visit';
  }
  if (newTask.subject.contains('Unsubscribed') || 
   newTask.subject.contains('Email click through') || 
   newTask.subject.contains('Email Viewed') || 
   newTask.subject.contains('Bounceback') || 
   newTask.subject.contains('Subscribed')
   ) {
    newTask.Type = 'Eloqua Response';
  }
   }
  }
}

 As you can see, it's very simple.  It works with my test code and works interactively, but there are still task sneaking in with no types.

I used one and prgramatically updated it (AJAX Tools rock) and the trigger fired as expected.

Any help would be appreciated.

I created a lookup relationship between Opportunities and Accounts.  This is different from the default relationship, I'm using it for other internal purposes.

Anyway, I want to create a trigger that will fire when the Opportunity is created or updated and the relationship has been established.  In user terms, they click on the lookup icon and select the related account.

I have two problems which are probably related:

1:  How do I do the above in a test class for my trigger?
    If the lookup field (on Opportunity) is Partner_Account, do I set o.Partner_Account__c(r?)=<some account id>?

2: How do I refer to this relationship in the trigger for both the criteria and the updates?
    o.Partner_Account__r.Id !=null
    o.Partner_Account__r.<fieldname>

Thanks
I wrote a trigger in my sandbox and it seems to work exactly as designed.  I moved it over to production and, of course, I need a class to test the trigger.  I created a class and got all the coverage I needed, but the test results aren't coming back as expected.

Here is the trigger code:
Code:
trigger nullTaskType on Task (before insert,before update) {
  private Task[] newTask = Trigger.new;
  if (newTask[0].Type == null) {
   system.debug(newTask[0].subject);
   if (newTask[0].subject.contains('Email') || newTask[0].subject.contains('Brochure') ) {
  newTask[0].Type = 'Email';
 }
 if (newTask[0].subject.contains('Web')) {
  newTask[0].Type = 'Web';
 }
  }
} 

 Here is the Testing Code:
Code:
public class nullTaskType {
 static testMethod void testNullTaskType() {
  Task t1 = new Task (subject='Email');
  system.debug(t1.subject);
  system.debug(t1.type);
  Task t2 = new Task (subject='Brochure');
  Task t3 = new Task (subject='Mass Email');
  Task t4 = new Task (subject='Web');
  Task t5 = new Task (subject='Something Else');
  Task t6 = new Task (type='Email');
  Task[] myTasks = new Task[] {t1,t2,t3,t4,t5,t6};
  insert myTasks;
  system.debug(t1.type);
  system.debug(t2.type);
  system.debug(t3.type);
  system.debug(t4.type);
  system.debug(t5.type);
//  System.assertEquals('Email', t1.type);
//  System.assertEquals('Email', t2.type);
//  System.assertEquals('Email', t3.type);
//  System.assertEquals('Web', t4.type);
  System.assertEquals(null, t5.type);
//  System.assertEquals('Email', t6.type);
 }
}

 
I'm a relative newbie at Apex, so be gentle.
:smileywink:

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