• justinhowell82
  • NEWBIE
  • 10 Points
  • Member since 2013

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 6
    Questions
  • 14
    Replies

Currently, we have a VF page that contains a VF component that has an attribute passed into it that is a Sales Order ID.  The components controller then gathers all required data for that Sales Order and that page is rendered and emailed on a manual button click from Sales Order details page.  Trying to automate this process, I wrote a schedualable class that will grab all the Sales Orders that meet criteria to send this email and process them in batches, no problem there.  The problem I am having is when trying to send the email.  I would like to to be able to track these activities as well as send each email to multiple contacts so it seems as if I will need to use the MassEmailMessageClass.  I have a visualforce email template  with a component like this:

<messaging:emailTemplate subject="Smartnet Welcome Letter" recipientType="Contact" relatedToType="Sales_Order__c">
<messaging:plainTextEmailBody >
    <c:SOMessage SOID="{!relatedTO.id}"></SOMessage>
</messaging:plainTextEmailBody>
</messaging:emailTemplate>

What I don't understand is in my scheduled class to send these emails I loop over all the Sales Orders and build a collection of messages to be sent.  I grab and set the template ID (setTemplateId) and the list of contact ids (setTargetObjectIds) but how will the Sales Order ID get passed into the template to be used by the component?  I though I would use the setWhatId but it appears that for mass emails this has to be of type Contract, Case, Opportunity, or Product.  My other though was to use an html body instead of a template but when using the massemail class you have to use setTemplateID, setHTMLBody is not allowed.  Is there a way to use the massemail class for this instance?  Or do I need to use the single email with setTargetId, if so how can i cc or send to others as well?

Thanks,
Justin

I followed the simple code from the tech docs (https://developer.salesforce.com/page/Wrapper_Class) to create a page with editable pageblocktable that allows inline editing and the ability for used to select multiple records and perform specific actions on the selected.  Works great unitl I have a very large list and i was getting an error on the VF page that I've exceeded the max viewstate size.  In the linked tech doc there is a public property that is a list of the wrapper object:

03   //Our collection of the class/wrapper objects cContact
04   public List<cContact> contactList {get; set;}

The contactList which is what the pageblocktable is bound to is what was blowing up my viewstate but I am only getting the needed values in the SOQL to populate.  I did not think this would work but I changed it from public to transient which made it dissappear from viewstate as expected AND the form contiunes to work as designed.  I guess I was not expecting this to work due to the fact that that data is not stored in viewstate but it does appear ot be working.  I can still edit all the inputfield values line by line and call my save method which envokes the standard SF validation and everything still functions as before.  Can anyone shine some light on this for me?

Thanks,
Jsutin
I follwoed the instructions found here:  http://blog.jeffdouglas.com/2011/08/12/roll-your-own-salesforce-lookup-popup-window/  which are pretty straight forward to try to override the standard lookup functionality.  I implemented this within my apex component and it is never getting inside the function openLookup that I have defined within my component.  Is there anything that would need ot be done differently when called from a component vs a VF page?

I have a custom vf page on a Quote page layout to display all the Quote Lines in a page block table.  The standard related list was far to limited for what we need.  I have the table displaying correctly with the first column being a checkbox with a select all box in the header.  What I want to happen is to link to another page to edit just the selected records when a user clicks a button on the page.  This has to be very simple but I can not figure out how to capture the selected records in the pageblock table and pass those to my new edit page.  

 

Thanks,

Justin

Background:

We have a terrible .net/mssql quoting solution that we are planning to do away with.  We are shopping it around at the same time also trying to see if we can duplicate all of the "required" functionality with some custom SFDC objects/classes/controllers/pages.  The one functionality that I'm not to sure on how to replicate (becuase of govenor limits) is the use of SQL lookup tables.  To keep it simple, we have 4 tables Quote, QuoteLine, Product, PriceAgreements.  The way the quote line validation works is that for every quote line (up to 500 lines) we look to see if the product on that line is in the PriceAgreements table and if it is we enforce contractual pricing constraints.  I tried to do this quickly in SF (described below) and quiclkly ran into a governor limit of no more than 100 SOQL queries.

 

SFDC setup

We have a custom quote (Q) and quote line (QL) obect.  The QL has a lookup relationship to the standard salesforce Product (P) object.  We also have a priceagreement (PA) object that also has a lookup to P.  When I call a class to validate all lines on the quote I'm looping over a list of QL and querying the PA object to determine if the product on the quote line is in the priceagreement object.  Once I get to 100 quote lines it craps out.  I can't help but think this could be elegantly designed but that is where I am stuck.

 

Any ideas on a way to be able to perform this validation line by line without hitting a govenor limit.  We are flexible with our object structure as it is just a proof of concept so I'll take anything!!

 

Thanks,

Justin Howell

I wrote an apex controller and class to handle precessing a tab delimited text file that gets attached to a quote.  The file gets parsed into a list/array of string and the quotelines in the file get processed.  The quote line string contains a product code (manufacturer code), desctiption, manufacturer, price, quanity, and cost.  I am looping over the items in my list, parsing the line apart and attempting to create a new quoteline object, then adding all the individual line objects to a collection to get inserted.  It actually works great when the file coming in has less that 100 lines.  Once it is over 100 a governor limit is reached and I can no longer run my SOQL query inside my process method.  What is the best way to approach this.  I need to have the productId in order to insert a quote line?  I'm sure there is a more effeciant way but I'm drawing a blank.

 

Shothand version below please ignore sytax it's just to convey what I'm trying to do:

 

 

public boolean ProcessProductQuote()
{

    List<string> LinesToProcess = new List<string>();

 

    //add relevant quote lines to list****

     LinesToProcess.Add(filelines[i]);

    //*****

 

    for (string QuoteLine: LinesToProcess)
    {
          ProcessProductQuoteLine(QuoteLine, QuoteID);
    }

}

 

Private void ProcessProductQuoteLine(string QuoteLine,string QuoteID)
    {

         //get part number if it exists.  If nothing is returned for the part on this line a new product is added

         List<Product2> P = [select Id from Product2 where ProductCode = :PartNumber];

    }

I follwoed the instructions found here:  http://blog.jeffdouglas.com/2011/08/12/roll-your-own-salesforce-lookup-popup-window/  which are pretty straight forward to try to override the standard lookup functionality.  I implemented this within my apex component and it is never getting inside the function openLookup that I have defined within my component.  Is there anything that would need ot be done differently when called from a component vs a VF page?
I followed the simple code from the tech docs (https://developer.salesforce.com/page/Wrapper_Class) to create a page with editable pageblocktable that allows inline editing and the ability for used to select multiple records and perform specific actions on the selected.  Works great unitl I have a very large list and i was getting an error on the VF page that I've exceeded the max viewstate size.  In the linked tech doc there is a public property that is a list of the wrapper object:

03   //Our collection of the class/wrapper objects cContact
04   public List<cContact> contactList {get; set;}

The contactList which is what the pageblocktable is bound to is what was blowing up my viewstate but I am only getting the needed values in the SOQL to populate.  I did not think this would work but I changed it from public to transient which made it dissappear from viewstate as expected AND the form contiunes to work as designed.  I guess I was not expecting this to work due to the fact that that data is not stored in viewstate but it does appear ot be working.  I can still edit all the inputfield values line by line and call my save method which envokes the standard SF validation and everything still functions as before.  Can anyone shine some light on this for me?

Thanks,
Jsutin
I follwoed the instructions found here:  http://blog.jeffdouglas.com/2011/08/12/roll-your-own-salesforce-lookup-popup-window/  which are pretty straight forward to try to override the standard lookup functionality.  I implemented this within my apex component and it is never getting inside the function openLookup that I have defined within my component.  Is there anything that would need ot be done differently when called from a component vs a VF page?

I have a custom vf page on a Quote page layout to display all the Quote Lines in a page block table.  The standard related list was far to limited for what we need.  I have the table displaying correctly with the first column being a checkbox with a select all box in the header.  What I want to happen is to link to another page to edit just the selected records when a user clicks a button on the page.  This has to be very simple but I can not figure out how to capture the selected records in the pageblock table and pass those to my new edit page.  

 

Thanks,

Justin