• SidM
  • NEWBIE
  • 25 Points
  • Member since 2009

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 13
    Replies

Hi everyone,

 

We have a requirement to send a templated email to the manager of the currently logged in user, summarising several standard and custom fields that reside on the Event object. The email template has been defined in VisualForce and works when doing a merge test from the VisualForce email edit UI and I have written the Apex code below to do send the email itself.

 

Although the email is being sent at the right time and to the right person (which we're triggering via an AJAX call to the Apex class via a Custom Button), it is not correctly related to the Event record (its "relatedTo" object), so doesn't display any Event information.

 

Here's the Apex code that send the email:

 

global class EmailUtilities {

	WebService static boolean sendEventEmailToManager(Id eventId) {
		List<Messaging.SendEmailResult> results;
		
		// Ensure we are not going to exceed single send limits by sending this (throws System.LimitException)
		Messaging.reserveSingleEmailCapacity(1);
		
		// Retrieve the user record for this user, including their manager's user record Id
		User user = [Select Id, Name, ManagerId, Email From User Where Id = :UserInfo.getUserId()];
		
		if (user.ManagerId == null) {
			throw new ManagerNotSetException('User ' + user.Name + ' has no manager assigned in their user record.');
		}
		
		// Retrieve the template to be used
		EmailTemplate template = [SELECT id FROM EmailTemplate WHERE developerName = 'EventSummary'];
		
		// Create the message
		Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
		email.setSenderDisplayName(UserInfo.getName());
		email.setReplyTo(user.Email);
		email.setWhatId(eventId);
		email.setSaveAsActivity(false);
		email.setTargetObjectId(user.ManagerId);
		email.setTemplateId(template.Id);
	
		// Send a blind copy to the sender
		email.setBccSender(true);
		
		// Send email
		results = Messaging.sendEmail(new Messaging.SingleEmailMessage[] { email });
		
		return results.get(0).isSuccess();
	}
	
	class ManagerNotSetException extends Exception {}
}

 

From looking at the documentation, the WhatId cannot use an Event object, but if we can't use this, then I'm at a loss as to how an Event record to this email template within Apex! Perhaps there is no way to do it, but it seems particularly limiting if so.

 

Does anyone have any pointers? Thanks in advance for any help anyone is able to provide.

  • March 16, 2011
  • Like
  • 0

Hi,

 

We have a requirement to produce a form on force.com sites for use by our client's customers and as this is a form on a consumer website (not an internal tool), there is a heavy focus on the user experience, particularly surrounding the way any field validation errors are displayed to the user.

 

Currently, either having the validation defined at the object level, or as validation rules means that when the user submits the multi-section form, they will only get back the first validation error.

 

This could potentially result in the user having to fix their mistake and re-validate so many times that the user experience will become a major issue.

 

What I would like to know is any mechanism by which we can use Salesforce's in-built validation, but display ALL errors at once, ideally aligned to the each field causing the error.

 

From our initial research, it appears that Salesforce will stop all processing the moment any validation fails, reporting back only that one failure.

 

Many thanks.

Message Edited by SidM on 01-26-2010 08:55 AM
  • January 26, 2010
  • Like
  • 0

We have a VF page which uses the Opportunity standard controller and an extension class called ManageLineItems.cls.

 

One of the key actions a user can perform on this VF page is to auto-generate a quote by clicking a button, so we need to display a couple of fields in this VF page which belong to our custom 'quote' object, such as the validity period (date), among other fields.

 

For some reason, the changes to these fields made on the VF just aren't fed through to the extension class and we can't figure out why. What makes it even more puzzling is that the inputField appears to be bound correctly to the value, as it shows the default value specified by the setter (Date.today() + 14).

 

Any help would be greatly appreciated!

 



Simplified code extract:

 

public class ManageLineItemController {
public BC_Quote__c quote;
public BC_Quote__c getQuote() {
if (quote == null) {
quote = new BC_Quote__c(Valid_Until__c = Date.today() + 14);
}
return quote;
}

// NB: we have also tried the following standard getter/setter approach

public BC_Quote__c quote {
get {
if (quote == null) {
quote = new BC_Quote__c(Valid_Until__c = Date.today() + 14);
}
return quote;
}
private set;
}

public PageReference createQuote() {

// this ignores the date posted from the VF page

System.debug('createQuote(): validityPeriod = ' + quote.Valid_Until__c);

return null;
}
}

 

And the simplified VF example:

 

<apex:page standardController="Opportunity"
extensions="ManageLineItemController"
sidebar="false"
tabStyle="Opportunity">

<apex:inputField id="validityPeriod" value="{!quote.Valid_Until__c}" required="true" />
<apex:commandButton action="{!createQuote}" value=" Create Quote " />
</apex:page>

 
I may well be missing something really obvious, so please feel free to hurl insults if so! ;-)

Message Edited by SidM on 09-14-2009 07:18 AM
  • September 14, 2009
  • Like
  • 0

I am in the process of creating a more advanced version of the Opportunity Line Item entry page in VisualForce. All going well so far, except that I need to allow the user to select a Pricebook Entry as a lookup relationship when adding  a new line item.

 

If I use the following code, everything seems fine until I click the lookup search button to select a new price book entry (product) and I get an error in the search lookup saying:

 

Required parameter "Missing the parent_id" not defined.

 

Here's the code:

 

<apex:column headerValue="Product" style="width:80px;">

<a href="../{!item.id}">{!item.PricebookEntry.Name}</a>

<apex:outputPanel rendered="{!isnull(item.PricebookEntry.Name)}">

<apex:inputField id="priceBookEntry" required="true" value="{!item.PricebookEntryId}" />

</apex:outputPanel>

</apex:column>

 

Should I be using this Id, or is there another way of doing this? I have also tried using {!item.Product2Id} but obviously then I have to loop through the new product selections and find their relevant pricebook entries when I save.

 

Any help greatly appreciated :-) 

Message Edited by SidM on 06-12-2009 02:11 PM
  • May 25, 2009
  • Like
  • 0

Hi everyone,

 

We have a requirement to send a templated email to the manager of the currently logged in user, summarising several standard and custom fields that reside on the Event object. The email template has been defined in VisualForce and works when doing a merge test from the VisualForce email edit UI and I have written the Apex code below to do send the email itself.

 

Although the email is being sent at the right time and to the right person (which we're triggering via an AJAX call to the Apex class via a Custom Button), it is not correctly related to the Event record (its "relatedTo" object), so doesn't display any Event information.

 

Here's the Apex code that send the email:

 

global class EmailUtilities {

	WebService static boolean sendEventEmailToManager(Id eventId) {
		List<Messaging.SendEmailResult> results;
		
		// Ensure we are not going to exceed single send limits by sending this (throws System.LimitException)
		Messaging.reserveSingleEmailCapacity(1);
		
		// Retrieve the user record for this user, including their manager's user record Id
		User user = [Select Id, Name, ManagerId, Email From User Where Id = :UserInfo.getUserId()];
		
		if (user.ManagerId == null) {
			throw new ManagerNotSetException('User ' + user.Name + ' has no manager assigned in their user record.');
		}
		
		// Retrieve the template to be used
		EmailTemplate template = [SELECT id FROM EmailTemplate WHERE developerName = 'EventSummary'];
		
		// Create the message
		Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
		email.setSenderDisplayName(UserInfo.getName());
		email.setReplyTo(user.Email);
		email.setWhatId(eventId);
		email.setSaveAsActivity(false);
		email.setTargetObjectId(user.ManagerId);
		email.setTemplateId(template.Id);
	
		// Send a blind copy to the sender
		email.setBccSender(true);
		
		// Send email
		results = Messaging.sendEmail(new Messaging.SingleEmailMessage[] { email });
		
		return results.get(0).isSuccess();
	}
	
	class ManagerNotSetException extends Exception {}
}

 

From looking at the documentation, the WhatId cannot use an Event object, but if we can't use this, then I'm at a loss as to how an Event record to this email template within Apex! Perhaps there is no way to do it, but it seems particularly limiting if so.

 

Does anyone have any pointers? Thanks in advance for any help anyone is able to provide.

  • March 16, 2011
  • Like
  • 0

Background
We have activated the Multi-Currency feature in our Org. 
 

 

I read the on-line help and the document at this url and have not been able to find any pertinent information. https://na6.salesforce.com/help/doc/en/salesforce_using_multiple_currencies.pdf 

 

We are building a standalone solution on Force.com with no integration into SFDC CRM objects. 

 

 

Question:

How do we get the DATA for the conversion rates?  Does Salesforce store the daily conversion rates in a table somewhere from where we can retrieve the actual conversion rate on a particular date?  In other words, we call an SFDC API passing in the (date, from currency, to currency) and the SFDC system returns the conversion rate for that date? 

 

OR 

 

Do we have to load this data into our own org on a daily basis by calling a webservice such as the one provided by the NY Fed Reserve http://www.newyorkfed.org/markets/pilotfx.html  and write the conversion rates to the currency table provided by SFDC (manage currencies section). 

 

After all, SFDC document at the url above says the system admin maintains the currencies but it seems absurd that it would be a manual process to input each conversion rate...  what am I missing here?

 

 

 

Thanks!!

  • February 18, 2010
  • Like
  • 1

Is there any way to change or delete a Scheduled Job ?  I am able to create one easily enough, but once it is made I can only look at the values in the CronTrigger object, but not update them.  Also, it seems I cannot delete them.  I also looked at the System.AbortJob method, but that seems to only stop a job that is already running - I get an error if I try it on a Queued job.

 

The reason I am doing this is to try to create a 'sliding' job.  So, when a trigger is fired the job will run in 5 minutes.  But if the trigger is fired again before that 5 minutes is up, it will find the old job and either delete it and make a new one for 5 minutes out, or update the old one so the next scheduled time is in 5 minutes.

 

Any ideas are welcome!

 

Jason

 

 

Hi all,

 

 

Here once again posting.

 

In API say PHP salesforce API we can handle huge data with querymore, querylocator. I have implemented. 

 

In Apex I have implemented standardsetController, paging. it is working fine for records upto 10000. I know its LIMIT and WELL KNOW ISSUE (as everyone taking about this ONLY).

 

I know there are more than 100000 records will return by query, I have to fetch and display with pagination. My concern is fetch and display.

 

 

 

 

Q. How to handle query records more than 100000 in apex?

 

Can anyone please answer this question so I can implement it?

 

 

Thanks 

 

Message Edited by Dowithforce on 10-29-2009 02:27 AM
Message Edited by Dowithforce on 10-29-2009 02:43 AM
Message Edited by Dowithforce on 10-29-2009 02:44 AM

We have a VF page which uses the Opportunity standard controller and an extension class called ManageLineItems.cls.

 

One of the key actions a user can perform on this VF page is to auto-generate a quote by clicking a button, so we need to display a couple of fields in this VF page which belong to our custom 'quote' object, such as the validity period (date), among other fields.

 

For some reason, the changes to these fields made on the VF just aren't fed through to the extension class and we can't figure out why. What makes it even more puzzling is that the inputField appears to be bound correctly to the value, as it shows the default value specified by the setter (Date.today() + 14).

 

Any help would be greatly appreciated!

 



Simplified code extract:

 

public class ManageLineItemController {
public BC_Quote__c quote;
public BC_Quote__c getQuote() {
if (quote == null) {
quote = new BC_Quote__c(Valid_Until__c = Date.today() + 14);
}
return quote;
}

// NB: we have also tried the following standard getter/setter approach

public BC_Quote__c quote {
get {
if (quote == null) {
quote = new BC_Quote__c(Valid_Until__c = Date.today() + 14);
}
return quote;
}
private set;
}

public PageReference createQuote() {

// this ignores the date posted from the VF page

System.debug('createQuote(): validityPeriod = ' + quote.Valid_Until__c);

return null;
}
}

 

And the simplified VF example:

 

<apex:page standardController="Opportunity"
extensions="ManageLineItemController"
sidebar="false"
tabStyle="Opportunity">

<apex:inputField id="validityPeriod" value="{!quote.Valid_Until__c}" required="true" />
<apex:commandButton action="{!createQuote}" value=" Create Quote " />
</apex:page>

 
I may well be missing something really obvious, so please feel free to hurl insults if so! ;-)

Message Edited by SidM on 09-14-2009 07:18 AM
  • September 14, 2009
  • Like
  • 0

I am in the process of creating a more advanced version of the Opportunity Line Item entry page in VisualForce. All going well so far, except that I need to allow the user to select a Pricebook Entry as a lookup relationship when adding  a new line item.

 

If I use the following code, everything seems fine until I click the lookup search button to select a new price book entry (product) and I get an error in the search lookup saying:

 

Required parameter "Missing the parent_id" not defined.

 

Here's the code:

 

<apex:column headerValue="Product" style="width:80px;">

<a href="../{!item.id}">{!item.PricebookEntry.Name}</a>

<apex:outputPanel rendered="{!isnull(item.PricebookEntry.Name)}">

<apex:inputField id="priceBookEntry" required="true" value="{!item.PricebookEntryId}" />

</apex:outputPanel>

</apex:column>

 

Should I be using this Id, or is there another way of doing this? I have also tried using {!item.Product2Id} but obviously then I have to loop through the new product selections and find their relevant pricebook entries when I save.

 

Any help greatly appreciated :-) 

Message Edited by SidM on 06-12-2009 02:11 PM
  • May 25, 2009
  • Like
  • 0

What is the best way of preventing this?

 

The problem is that f.ex.  a sales rep can remove/replace previously attached quotes or other attachments from an opportunity after it has been closed.

 

The opportunity itself is locked for editing, so it seems this should apply to attachments too.

  • March 05, 2009
  • Like
  • 0
Anyone know how to write an apex trigger that will copy the parent account team details to all child account teams everytime a change is made to the parent?

I am developing a page in which i want to show total number accounts who have certain condition, my code is like this:
Code:
 if (ptotalRecords == 0)
       {
            try
            {
              ptotalRecords = [select count() from Account WHERE (Hierarchy_Status__c = 0 OR Hierarchy_Status__c = null) AND (parent_duns_number__c != null OR Ultimate_Parent_D_B_Number__c != null)];
            }
            catch(Exception ex)
            {
                 ptotalRecords = -1; 
            }
      }
       
      if (ptotalRecords == -1)
         return '10,000+';
      else
         return ptotalRecords+ '';

 Even though i have put everything in try and catch block i still get the following error:

System.Exception: Too many query rows: 10001

it seems as a developer i do not have the right to choose the fate of my App!



I am writing some APEX callouts to call webservice on our company network,  I want to restrict access to these webservice only allow the Salesforce IP address, but I can't find the IP address ranges I should use.  Can anyone help me?
 
Thanks