• t_Chris
  • NEWBIE
  • 30 Points
  • Member since 2011

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

Hi all,

 

I have a Visualforce email template which includes a component which has it's own custom controller. I use this setup in order to be able to retrieve related objects which I want to display in the email going out to a contact.

 

However, for some reason, nothing gets displayed in my email templates and I haven't found a way of debugging it in order to be able to track when/where it goes wrong. However, I'm fairly certain that it is the opportunity ID that does not get passed from the template/component to the controller.

 

I've searched for an answer but haven't been able to find one. I've seen similar posts (e.g.. http://forums.sforce.com/t5/Apex-Code-Development/Custom-Controller-in-Email-Template-not-passing-values-to-Class/m-p/134744) but for some reason I still haven't been able to make it work in my own org.

 

Here is my component:

 

<apex:component id="cmpOrderForm" controller="OrderFormDomainOppComponentController" access="global">
	<apex:attribute name="paramOppId" description="Passes the ID of the opportunity to the custom controller" type="Id" assignTo="{!oppId}"/>
	<apex:outputText value="{!oppId}"/>
	<html>
		<body>
			<table>
				<apex:repeat value="{!links}" var="lnk">
					<tr>
						<td>Domain Name</td>
						<td>{!lnk.Domain__r.Name}</td>
					</tr>
				</apex:repeat>
			</table>
		</body>
	</html>
</apex:component>

 Here is my template:

<messaging:emailTemplate recipientType="Contact" relatedToType="Opportunity" subject="Order Form" replyTo="soren.nodskov@capgemini.com">
    <messaging:htmlEmailBody >
    	<c:OrderFormDomainOppComponent paramOppId="{!relatedTo.Id}"/>
    </messaging:htmlEmailBody>
</messaging:emailTemplate>

 Here is my controller:

public without sharing class OrderFormDomainOppComponentController {
	private final List<DomainOppLink__c> links;

	public Id oppId {get; set;}

	public OrderFormDomainOppComponentController() {
		// oppId = '006W0000002VDzZ';
		links = [SELECT Domain__r.Name FROM DomainOppLink__c WHERE Opportunity__c = :oppId];
	}

	public List<DomainOppLink__c> getLinks() {
		return links;
	}
}

 In the template I output the Opportunity ID just for debugging purposes and that works fine. It shows the ID correctly when testing the template from within the SF GUI (Setup --> Communication Templates --> Email Templates).

 

However, the DomainOppLink objects retrieved in the controller is not shown. If I hard code the opportunity ID in my controller (commented out in the code above), it all works fine. I.e.. I get an email with all the DomainOppLink objects.

 

So, the big WHY is: WHY doesn't it work when I am NOT hard coding the opportunity ID but using the ID passed on from my component/template?!

 

I feel like I'm SO close, and that I just cannot seen the forrest for all the trees.

 

All help is greatly appreciated.

 

Cheers.

 

/Søren Nødskov Hansen

Hi All,

 

I had a client come back to me with a bug whereby a calendar I built for them was showing two 04/01/2012 days.  This was only happening in April, and only in 2012.

 

On further inspection it looks as though adding 1 day to a DateTime variable with a date 03/31/12 and a time of 00:00:00:00  has the same output as adding 2 days to the same variable!  And this only seems to happen on this day, in 2012.

 

if you run this in the dev console, you'll see what I mean:

 

DateTime dt = dateTime.newInstance(date.newInstance(2012, 03, 31), time.newInstance(00, 00, 00, 00));
system.debug(dt.addDays(1).format('EEE dd/MM'));

 

The USER_DEBUG output is 'SUN 01/04...

 

Try running, adding 2 days to the variable

 

DateTime dt = dateTime.newInstance(date.newInstance(2012, 03, 31), time.newInstance(00, 00, 00, 00));
system.debug(dt.addDays(2).format('EEE dd/MM'));

 The USER_DEBUG output is 'SUN 01/04'!

 

Try different days and the method works ok...  If you add an hour on to the Time element of the dateTime, this seems to fix it... but that doesn't work in my overall architecture.

 

I can probably find a work around, just wondered if this is a bug, or is there something else I should be considering?

 

Cheers

 

Chris

Hey All.

 

Just a quick question regarding authenticating using OAuth with the ios toolkit.  My application authenticates fine over a physical dsl connection, but when I try to authenticate over 3G/Mobile Wireless I get an 'Activation Required' message.

 

I have been able to replicate the same issue with the sample app included with the toolkit and attached a screen shot.

 

I haven't been able to find anyone else with similar problems, I was wondering if it is a problem with location?  We are running our app on Australian 3G networks (Vodafone/Telstra)

 

If any one has any idea what may be happning, would be great to hear from you. Or, if this is how the auth proces is supposed to function then it would be good to know that so we can work around it.

 

Cheers

 

ChrisiPad Screen

I was developing a Lightning Component with JQuery and Dragula (a JS drag-and-drop library). Everything was going well, until the Sandbox updated to the Spring 19 Release and now I recieve an error when I try to drag-drop. The component still works in my other Sandbox that is in Winter 19. I receive the following error:

Uncaught TypeError: target.getBoundingClientRect is not a function throws at https://ceievents--maintask.lightning.force.com/resource/1546019884000/Dragula/dist/dragula.js:515:25

User-added image

The line referenced is a line in the library that calls the .getBoundingClientRect() function. I don't get any error or notes on the Console Log. Any guidance would be greatly appreciated.

How do I get Xcode to use Mobile SDK 2.0?

It currently uses SDK 1.5.

I renamed the folder SalesforceMobileSDK-iOS to xSalesforceMobileSDK-iOS and then installed SDK 2.0.

- thanks.

  • July 14, 2013
  • Like
  • 0

Thinking of enabling #Communities for your customer? Then be aware of the current #Gotcha that the default Apex Classes that are created when you enable your first Community do not ALL have code coverage >75%.

What this means:
You can enable Communities in Production, however as soon as you attempt to migrate anything from a sandbox into Production that triggers all tests to be run (doesn't have to be just code), your migration will fail as three of the classes only have 33%, 20% and 21%.

Let me repeat that, you might only be migrating a bunch of new custom fields and page layouts and the Change Set (or Eclipse/ANT) will fail.

I hit this problem this week in a go-live deployment so had to update Apex Classes to achieve average total code coverage >75% in order to proceed with our deployment.

The PM of Communities knows about the problem and advises he is looking at a fix, but in the meantime here are the four Apex Classes that need to be updated.

 

CommunitiesLandingControllerTest.cls

Just a one liner for this test class

/**
 * An apex page controller that takes the user to the right start page based on credentials or lack thereof
 */
@IsTest public with sharing class CommunitiesLandingControllerTest {
  @IsTest(SeeAllData=true) public static void testCommunitiesLandingController() {
    // Instantiate a new controller with all parameters in the page
    CommunitiesLandingController controller = new CommunitiesLandingController();

    // 25-Jun-2013 Manu Erwin - Fixing insufficient code coverage for default Communities Apex Tests
    PageReference pageRef = controller.forwardToStartPage();
  }
}

 

CommunitiesLoginControllerTest.cls

Just a one liner for this test class

/**
 * An apex page controller that exposes the site login functionality
 */
@IsTest global with sharing class CommunitiesLoginControllerTest {
  @IsTest(SeeAllData=true) 
  global static void testCommunitiesLoginController () {
    CommunitiesLoginController controller = new CommunitiesLoginController ();

    // 25-Jun-2013 Manu Erwin - Fixing insufficient code coverage for default Communities Apex Tests
    PageReference pageRef = controller.forwardToAuthPage();
  }  
}

 

CommunitiesSelfRegControllerTest.cls

A few controller variables to set prior to calling the controller method for the original test method, followed by a couple of additional test methods for further coverage.

/**
 * An apex page controller that supports self registration of users in communities that allow self registration
 */
@IsTest public with sharing class CommunitiesSelfRegControllerTest {
  @IsTest(SeeAllData=true) 
  public static void testCommunitiesSelfRegController() {
    CommunitiesSelfRegController controller = new CommunitiesSelfRegController();

    // 25-Jun-2013 Manu Erwin - Fixing insufficient code coverage for default Communities Apex Tests
    controller.firstName = 'Bob';
    controller.lastName = 'Jones';
    controller.email = 'bob@jones.com';
    controller.password = '8yhMsHDN&ituQgO$WO';
    controller.confirmPassword = '8yhMsHDN&ituQgO$WO';
    controller.communityNickname = 'bob-jones-testing';

    PageReference pageRef = controller.registerUser();
  }
  // 25-Jun-2013 Manu Erwin - Fixing insufficient code coverage for default Communities Apex Tests
  @IsTest(SeeAllData=true) 
  public static void testInvalidPassword() {
    CommunitiesSelfRegController controller = new CommunitiesSelfRegController();
    controller.firstName = 'Bob';
    controller.lastName = 'Jones';
    controller.email = 'bob@jones.com';
    controller.password = '8yhMsHDN&ituQgO$WO';
    controller.confirmPassword = 'not the same';
    controller.communityNickname = 'bob-jones-testing';

    PageReference pageRef = controller.registerUser();
    System.assert(pageRef == null, 'The returned page reference should be null');
  }
  // 25-Jun-2013 Manu Erwin - Fixing insufficient code coverage for default Communities Apex Tests
  @IsTest(SeeAllData=true) 
  public static void testNullPassword() {
    CommunitiesSelfRegController controller = new CommunitiesSelfRegController();
    controller.firstName = 'Bob';
    controller.lastName = 'Jones';
    controller.email = 'bob@jones.com';
    controller.communityNickname = 'bob-jones-testing';

    PageReference pageRef = controller.registerUser();
    System.assert(pageRef == null, 'The returned page reference should be null');
  }
}

 

CommunitiesSelfRegController.cls

A few additions to this class to set the Profile and Account Ids for portal user creation. Update the ProfileId value based on the "portal" license(s) (e.g., Customer Portal, Customer Community, etc) and set the AccountId to that of the Account you wish to use for self-registration. Note: this needs to be set even if you're not using self-registration so the class can be tested.

Plus some debug statements so I could see what was happening and needed to be tested.

/**
 * An apex page controller that supports self registration of users in communities that allow self registration
 */
public with sharing class CommunitiesSelfRegController {

  public String firstName {get; set;}
  public String lastName {get; set;}
  public String email {get; set;}
  public String password {get; set {password = value == null ? value : value.trim(); } }
  public String confirmPassword {get; set { confirmPassword = value == null ? value : value.trim(); } }
  public String communityNickname {get; set { communityNickname = value == null ? value : value.trim(); } }
  
  public CommunitiesSelfRegController() {}
  
  private boolean isValidPassword() {
    return password == confirmPassword;
  }

  public PageReference registerUser() {
  
    // it's okay if password is null - we'll send the user a random password in that case
    if (!isValidPassword()) {
      System.debug(System.LoggingLevel.DEBUG, '## DEBUG: Password is invalid - returning null');
      ApexPages.Message msg = new ApexPages.Message(ApexPages.Severity.ERROR, Label.site.passwords_dont_match);
      ApexPages.addMessage(msg);
      return null;
    }  

    // 25-Jun-2013 Manu Erwin - Fixing insufficient code coverage for default Communities Apex Tests
    //String profileId = ''; // To be filled in by customer.
    //String roleEnum = ''; // To be filled in by customer.
    //String accountId = ''; // To be filled in by customer.

    // Set this to your main Communities Profile API Name
    String profileApiName = 'PowerCustomerSuccess';
    String profileId = [SELECT Id FROM Profile WHERE UserType = :profileApiName LIMIT 1].Id;
    List<Account> accounts = [SELECT Id FROM Account LIMIT 1];
    System.assert(!accounts.isEmpty(), 'There must be at least one account in this environment!');
    String accountId = accounts[0].Id;
    
    String userName = email;

    User u = new User();
    u.Username = userName;
    u.Email = email;
    u.FirstName = firstName;
    u.LastName = lastName;
    u.CommunityNickname = communityNickname;
    u.ProfileId = profileId;
    
    String userId = Site.createPortalUser(u, accountId, password);
   
    if (userId != null) { 
      if (password != null && password.length() > 1) {
        System.debug(System.LoggingLevel.DEBUG, '## DEBUG: User creation successful and password ok - returning site.login');
        return Site.login(userName, password, null);
      }
      else {
        System.debug(System.LoggingLevel.DEBUG, '## DEBUG: User creation successful but password not ok - redirecting to self reg confirmation');
        PageReference page = System.Page.CommunitiesSelfRegConfirm;
        page.setRedirect(true);
        return page;
      }
    }
    System.debug(System.LoggingLevel.DEBUG, '## DEBUG: User creation not successful - returning null');
    return null;
  }
}

 

 

Hi all,

 

I have a Visualforce email template which includes a component which has it's own custom controller. I use this setup in order to be able to retrieve related objects which I want to display in the email going out to a contact.

 

However, for some reason, nothing gets displayed in my email templates and I haven't found a way of debugging it in order to be able to track when/where it goes wrong. However, I'm fairly certain that it is the opportunity ID that does not get passed from the template/component to the controller.

 

I've searched for an answer but haven't been able to find one. I've seen similar posts (e.g.. http://forums.sforce.com/t5/Apex-Code-Development/Custom-Controller-in-Email-Template-not-passing-values-to-Class/m-p/134744) but for some reason I still haven't been able to make it work in my own org.

 

Here is my component:

 

<apex:component id="cmpOrderForm" controller="OrderFormDomainOppComponentController" access="global">
	<apex:attribute name="paramOppId" description="Passes the ID of the opportunity to the custom controller" type="Id" assignTo="{!oppId}"/>
	<apex:outputText value="{!oppId}"/>
	<html>
		<body>
			<table>
				<apex:repeat value="{!links}" var="lnk">
					<tr>
						<td>Domain Name</td>
						<td>{!lnk.Domain__r.Name}</td>
					</tr>
				</apex:repeat>
			</table>
		</body>
	</html>
</apex:component>

 Here is my template:

<messaging:emailTemplate recipientType="Contact" relatedToType="Opportunity" subject="Order Form" replyTo="soren.nodskov@capgemini.com">
    <messaging:htmlEmailBody >
    	<c:OrderFormDomainOppComponent paramOppId="{!relatedTo.Id}"/>
    </messaging:htmlEmailBody>
</messaging:emailTemplate>

 Here is my controller:

public without sharing class OrderFormDomainOppComponentController {
	private final List<DomainOppLink__c> links;

	public Id oppId {get; set;}

	public OrderFormDomainOppComponentController() {
		// oppId = '006W0000002VDzZ';
		links = [SELECT Domain__r.Name FROM DomainOppLink__c WHERE Opportunity__c = :oppId];
	}

	public List<DomainOppLink__c> getLinks() {
		return links;
	}
}

 In the template I output the Opportunity ID just for debugging purposes and that works fine. It shows the ID correctly when testing the template from within the SF GUI (Setup --> Communication Templates --> Email Templates).

 

However, the DomainOppLink objects retrieved in the controller is not shown. If I hard code the opportunity ID in my controller (commented out in the code above), it all works fine. I.e.. I get an email with all the DomainOppLink objects.

 

So, the big WHY is: WHY doesn't it work when I am NOT hard coding the opportunity ID but using the ID passed on from my component/template?!

 

I feel like I'm SO close, and that I just cannot seen the forrest for all the trees.

 

All help is greatly appreciated.

 

Cheers.

 

/Søren Nødskov Hansen

Hi,

 

Anybody else having problems with images in summer '12?

Our sandbox has been updated and pdf generation now gives an error 'PDF generation failed. Check the page markup is valid.'

 

Test example below gives same issue. Any ideas?

 

<apex:page renderas="pdf">
  <h1>Congratulations</h1>
  This is your new Page
  <img src="http://www.developerforce.com/assets/images/discussions/banner.gif"></img>
</apex:page>

 A case has been logged -but just wondering if there is a quick fix.

 

Thanks!

Rich.

 

 

 

Hi All,

 

I had a client come back to me with a bug whereby a calendar I built for them was showing two 04/01/2012 days.  This was only happening in April, and only in 2012.

 

On further inspection it looks as though adding 1 day to a DateTime variable with a date 03/31/12 and a time of 00:00:00:00  has the same output as adding 2 days to the same variable!  And this only seems to happen on this day, in 2012.

 

if you run this in the dev console, you'll see what I mean:

 

DateTime dt = dateTime.newInstance(date.newInstance(2012, 03, 31), time.newInstance(00, 00, 00, 00));
system.debug(dt.addDays(1).format('EEE dd/MM'));

 

The USER_DEBUG output is 'SUN 01/04...

 

Try running, adding 2 days to the variable

 

DateTime dt = dateTime.newInstance(date.newInstance(2012, 03, 31), time.newInstance(00, 00, 00, 00));
system.debug(dt.addDays(2).format('EEE dd/MM'));

 The USER_DEBUG output is 'SUN 01/04'!

 

Try different days and the method works ok...  If you add an hour on to the Time element of the dateTime, this seems to fix it... but that doesn't work in my overall architecture.

 

I can probably find a work around, just wondered if this is a bug, or is there something else I should be considering?

 

Cheers

 

Chris

Hey All.

 

Just a quick question regarding authenticating using OAuth with the ios toolkit.  My application authenticates fine over a physical dsl connection, but when I try to authenticate over 3G/Mobile Wireless I get an 'Activation Required' message.

 

I have been able to replicate the same issue with the sample app included with the toolkit and attached a screen shot.

 

I haven't been able to find anyone else with similar problems, I was wondering if it is a problem with location?  We are running our app on Australian 3G networks (Vodafone/Telstra)

 

If any one has any idea what may be happning, would be great to hear from you. Or, if this is how the auth proces is supposed to function then it would be good to know that so we can work around it.

 

Cheers

 

ChrisiPad Screen

Has anyone else noticed that line number scrolling broken in Eclipse 3.4 on Mac OS? I did read one blog post that identifies the issue. This makes it EXTREMLY hard to track down errors by line number. Eclipse 3.5 is rumored to work fine.

 

Can anyone comment on when the Force.com IDE might work with Eclipse 3.5?

  • October 11, 2009
  • Like
  • 0