• David Gunn
  • NEWBIE
  • 5 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 1
    Likes Given
  • 4
    Questions
  • 4
    Replies
I have Apex code that sends an email that contains a link to a Survey Monkey survey, similar to this stripped-down snippet:
 
public static void sendLink(String oppId, String emailaddr) { 
    Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage(); 
    String body; mail.setToAddresses(new string[] {emailaddr}); 
    mail.setSenderDisplayName('noreply@companyname.com'); 

    mail.setSubject('My subject'); body = 'This is a link: https://www.domain.net/asdf&z=' + oppId;
    mail.setPlainTextBody(body); 
    Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail } ); 
}
The email sends fine but the link received by the recipient is drastically different.

If the receipient is an email adress here at work the link is something like this: https://urldefense.proofpoint.com/v2/url?u=https-3A__ ... GC5BJ...D0063B...=...wICA&z=...nzTkWOdJlub_y7...&r=...bOKUVzc...

If it is sent to my personal hotmail address the URL is likewise changed and starts with this:
https://nam04.safelinks.protection.outlook.com/?url=https%3A...

I suspect that both target email systems have safeguards in place that "scrub" links that are found in emails. Is there something I can do in Apex that will allow the links to arrive to the recipient in tact?

Thank you.
I have an Apex method with this if statement:
 
if (((accountObj.Type == 'Distributor') || (accountObj.Type == 'Reseller')) && ((opp.CustomPickList__c == null) || (opp.CustomPickList__c.trim() == '')))
{
    return "Message";
}

If the account type is Reseller then Message is returned (and displays).  However, if the account type is Distributor then Message isn't returned.

Type is a picklist, as is the custom field.

Can anyone see why the message is displayed for a Reseller account but not for a Distributor?

Thanks!
I have a 263-line class and associated test class and I'm m trying to test to make sure I get good coverage.  I'm in the Developer Console in the Sandbox.  I run a test on the class.  After it's finished I double-click on the class in the Overall Code Coverage panel; it brings up my class with highlighted lines showing what lines were hit and which ones were missed.  It looks fine until line 121, when the highlighting gets messed up: some comment lines as well as some lines with just a bracket are highlighted with red, while some code is not highlighted at all.  The last line with any highlighting (red) is line 149.  There's a *lot* of code below that tline with no highlighting on it.  Obviously something is messed up here...is this a bug in Developer Console on the Sandbox?  I don't see the same problem on Production.

Here's the code between lines 102 and 130 that illustrate the problem:

Bad highlighting sample

Thanks in advance!
In our instance we have a custom quote button (URL button) that only contains this code:

/apex/NewQuoteRedirect?retURL=%2F{!Opportunity.Id}&oppid={!Opportunity.Id}

I would like to change this to an OnClick Javascript button to which I can add some validation code (to make sure a new Opportunity Product custom field is populated in each of the opportunity's products)

How can I convert the above line to Javascript?
I have an Apex method with this if statement:
 
if (((accountObj.Type == 'Distributor') || (accountObj.Type == 'Reseller')) && ((opp.CustomPickList__c == null) || (opp.CustomPickList__c.trim() == '')))
{
    return "Message";
}

If the account type is Reseller then Message is returned (and displays).  However, if the account type is Distributor then Message isn't returned.

Type is a picklist, as is the custom field.

Can anyone see why the message is displayed for a Reseller account but not for a Distributor?

Thanks!

Hello fellow developers!

I've looked at the developer boards and can't quite find what I'm looking for.
Basically, what I'm trying to achieve is to create an internal contact record for every User record that is created. **This contact should be associated to the Internal Accounts that essentially hold internal contact information.

I'm fairly new to writing code and have gotten as far as creating a new Contact record each time a User record is created, but I'm unable to see how a 'conditional account assignment' can be done to this.

trigger AutoCreateContactonUser on User (after insert){

if(Trigger.isInsert){
    List<Contact> ct = new List<Contact>();
    
    for(User u : trigger.new){
        Contact c = new Contact(LastName = u.lastname);

ct.add(c); 
        
    }
insert ct;
}


}

==============================================
To this, I would like to add a condition which would logically read as 'IF the User being created is from Australia (country / address info) THEN create a contact in the Internal APAC Account'

Appreciate any assistance,
Thanks

If I click a link in google to an article on developers.salesforce.com in any browser, the article loads, then there is a page refresh and takes me to the intiial forums page. I then have to search and try to find the same article within the site
In our instance we have a custom quote button (URL button) that only contains this code:

/apex/NewQuoteRedirect?retURL=%2F{!Opportunity.Id}&oppid={!Opportunity.Id}

I would like to change this to an OnClick Javascript button to which I can add some validation code (to make sure a new Opportunity Product custom field is populated in each of the opportunity's products)

How can I convert the above line to Javascript?
If I click a link in google to an article on developers.salesforce.com in any browser, the article loads, then there is a page refresh and takes me to the intiial forums page. I then have to search and try to find the same article within the site