• Ron Reed
  • NEWBIE
  • 150 Points
  • Member since 2012


  • Chatter
    Feed
  • 6
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 13
    Replies
Hello,
I am making the transition from Admin to Developer, and I am working on building an Apex Class. Still very new at it. Very.
What I am trying to do is to build code that when a new Account is added, that the system goes and checks the Contracts Object to see if there is a matching Contract to that Account (sometimes Accounts will not have a contract). Normally, I would do this with Access beforehand, but the base files are getting to large for both contracts and accounts. 
What I need is that the code pulls the new account, checks that it has something in the Contract Number Custom Field (Contract_Number__c). If it does, it pulls all the Contracts and does basically a VLOOKUP against the custom field Bg Contract Number (BG_Contract_Number__c). If it finds a match, it fills in the Account lookup field on Contracts. 
Any help would be greatly appreciated.

Scenario: I have a decimal field defined with 4 decimal points of precision.  When entering data through the UI, if you enter additional decimal points, Salesforce will round the number to 4 decimal points and save this value to the database.

Entered in UI: 0.20006
Presented after saving: 0.2001
Saved in the database (using Eclipse to query): 0.2001

When using the Apex data loader, Salesforce does not enforce decimal precision.

CSV file: 1.283265
In the UI: 1.2833
Saved in the database: 1.283265

Attempting a quick edit of the record in the UI will show the rounded version, and formulas use the rounded version, but Apex code will use the value from the database.

The extended decimal value will stay this way until the record is re-saved through the UI. (even a quick edit on an unrelated field will cause the rounded version to be saved to the database)  An update via Apex DML statement will NOT change the value unless it's explicitly modified with Apex.

----

I realize I can prevent the data loader from importing such extended values by using a validation rule, or enforce a rounded value using a BeforeUpdate/BeforeInsert trigger, but why is Salesforce not rounding the values as they come in via the Data Loader?

The behaviour seems inconsistent to me.

Is this a "bug" or a "feature"?

Hi.

 

I am totally stumped on this one, and this is a simple scenario:

 

1. VAL rule on opportunity (create or edit)

2. Check Opportunity Record Type name against Account record type name

3. If the first two letters are different then error

 

       LEFT(Account.Record_Type_Label__c,2)<>LEFT($RecordType.Name,2)

 

4. Account.Record_Type_Label__c is a formula referencing the Record type name on account

 

It will error when I say LEFT(Account.Record_Type_Label__c,2) =  LEFT($RecordType.Name,2) but when

I do not equal to no error ... what the?

 

Record type name example is Opp Rectype Name = US Opportunity and Account Rectype Name = AU Account

 

ANY ideas on this one? I need to use the first two letters, have also tried MID, no luck ...

  • November 20, 2012
  • Like
  • 0

Error Message:

Error: GoogleChartsController Compile Error: Incompatible types since an instance of ApexPages.StandardController is never an instance of Account at line 5 column 15

Controller:

global class GoogleChartsController {
 global static Account acc;
 
    public GoogleChartsController(ApexPages.StandardController controller) {
        acc = (Account)controller.getRecord();
    }
@RemoteAction   
    global static AggregateResult[] loadChildCases(Id prmAccountId) {
        AggregateResult[] caseLst = [Select ParentId, count(Id) FROM Case  WHERE AccountId = :prmAccountId Group By ParentId ];
        
        return caseLst;
    }
    }

 

VF Page:

<apex:page extensions="GoogleChartsController" sidebar="false" standardController="Account" showHeader="false" pageStyle="Account"  >
    <apex:includeScript id="a" value="https://www.google.com/jsapi" />     
    <script type="text/javascript">
        // Load the Visualization API and the piechart package.
        google.load('visualization', '1.0', {'packages':['corechart']});
        // Set a callback to run when the Google Visualization API is loaded.
        google.setOnLoadCallback(initCharts);
        //load all the charts..
        function initCharts() {
              GoogleChartsController.loadChildCases('{!acc.Id}', function(resultCase, event){  
                  var visualization = new google.visualization.ColumnChart(document.getElementById('caseChart'));
                  var data1 = new google.visualization.DataTable();  
                  data1.addColumn('string', 'Cases');
                  data1.addColumn('number', 'Cases');       
                  //add rows from the remoting results
                  for(var i =0; i < resultCase.length; i++){
                      var r = resultCase[i];
                      data1.addRow([r.Id, r.expr0]);
                   }
                    // all done, lets draw the chart with some options to make it look nice.
                    visualization.draw(data1, {legend : {position: 'top', textStyle: {color: 'blue', fontSize: 10}}, width:150,vAxis:{textStyle:{fontSize: 10}},hAxis:{textStyle:{fontSize: 10},showTextEvery:1,slantedText:false}});
              }, {escape:true});
              
          }
    </script>
     <div id="caseChart" />
</apex:page>

Hi.

We are trying to get a case age formual to work like one that we currently have in an excel spreadsheet.

Custom Date Fields:
Date Opened - 1/3/2012 9:43am
Date Resolved - 1/18/2012 8:42am

Excel Formula: =IF(C5654="",0,(NETWORKDAYS(B5654,C5654,holidays)-1)*(end-start)+IF(NETWORKDAYS(C5654,C5654,holidays),MEDIAN(MOD(C5654,1),
end,start),end)-MEDIAN(NETWORKDAYS(B5654,B5654,holidays)*MOD(B5654,1),end,start))

EXCEL Age in Business Hours: 120:17

Salesforce Formula:
If(IsNull(Date_Resolved__c ),

CASE(MOD( DateValue(Date_Opened__c ) - DATE(1985,6,24),7), 0 ,
CASE( MOD( Today() - DateValue(Date_Opened__c ) ,7),1,2,2,3,3,4,4,5,5,5,6,5,1), 1 ,
CASE( MOD( Today() - DateValue(Date_Opened__c ) ,7),1,2,2,3,3,4,4,4,5,4,6,5,1), 2 ,
CASE( MOD( Today() - DateValue(Date_Opened__c ) ,7),1,2,2,3,3,3,4,3,5,4,6,5,1), 3 ,
CASE( MOD( Today() - DateValue(Date_Opened__c ) ,7),1,2,2,2,3,2,4,3,5,4,6,5,1), 4 ,
CASE( MOD( Today() - DateValue(Date_Opened__c ) ,7),1,1,2,1,3,2,4,3,5,4,6,5,1), 5 ,
CASE( MOD( Today() - DateValue(Date_Opened__c ) ,7),1,0,2,1,3,2,4,3,5,4,6,5,0), 6 ,
CASE( MOD( Today() - DateValue(Date_Opened__c ) ,7),1,1,2,2,3,3,4,4,5,5,6,5,0), 999)
+ (FLOOR(( Today() - DateValue(Date_Opened__c ) )/7)*5-1)*11,

CASE(MOD( DateValue(Date_Opened__c ) - DATE(1985,6,24),7), 0 ,
CASE( MOD( DateValue(Date_Resolved__c ) - DateValue(Date_Opened__c ) ,7),1,2,2,3,3,4,4,5,5,5,6,5,1), 1 ,
CASE( MOD( DateValue(Date_Resolved__c ) - DateValue(Date_Opened__c ) ,7),1,2,2,3,3,4,4,4,5,4,6,5,1), 2 ,
CASE( MOD( DateValue(Date_Resolved__c ) - DateValue(Date_Opened__c ) ,7),1,2,2,3,3,3,4,3,5,4,6,5,1), 3 ,
CASE( MOD( DateValue(Date_Resolved__c ) - DateValue(Date_Opened__c ) ,7),1,2,2,2,3,2,4,3,5,4,6,5,1), 4 ,
CASE( MOD( DateValue(Date_Resolved__c ) - DateValue(Date_Opened__c ) ,7),1,1,2,1,3,2,4,3,5,4,6,5,1), 5 ,
CASE( MOD( DateValue(Date_Resolved__c ) - DateValue(Date_Opened__c ) ,7),1,0,2,1,3,2,4,3,5,4,6,5,0), 6 ,
CASE( MOD( DateValue(Date_Resolved__c ) - DateValue(Date_Opened__c ) ,7),1,1,2,2,3,3,4,4,5,5,6,5,0), 999)
+ (FLOOR(( DateValue(Date_Resolved__c ) - DateValue(Date_Opened__c ) )/7)*5-1))*11


SALESFORCE Age in Business Hours: 121.00

How can I get the SFDC formula to stop rounding? I think that's what it's doing. 

Hi,

 

 

We've created an email template which references fields of a custom object named Intervention.

Intervention object has a  detail button that must send  email using that template. We are receiving the error "Invalid whatId" when we try to send email.

In javascript implemented in the button we have assigned the field Name (standard ID field ) of Intervention to property whatId of SingleEmailMessage.  

 

Can someone help us what is the problem with whatId?

 

A excerpt of our code below:

 

.....

var req = new sforce.SingleEmailMessage();
req.orgWideEmailAddressId = [orgWideEmailAddresstId ];
req.ccAddresses =[ ccSupervisao, ccSuporte ];
                       
//Sender will receive a copy of the mass e-mail sent
req.bccSender=true;
                                                                                
req.emailPriority='High';
req.replyTo=targetAddress;

req.targetObjectId=targetObjectId;
req.saveAsActivity=false;
var name = {!Intervention__c.Name};
req.whatId = name;

 

// Query template ID
var templateName = "{!Intervention__c.Modelo_de_Email__c}";
var queryEmailTemplate = sforce.connection.query("select Id from EmailTemplate where name ='" + templateName + "'");
var templateId = queryEmailTemplate.getArray("records")[0].Id;

req.templateId=templateId;

.....

 

Many thanks,

Ana

  • October 17, 2012
  • Like
  • 0
Hello,
I am making the transition from Admin to Developer, and I am working on building an Apex Class. Still very new at it. Very.
What I am trying to do is to build code that when a new Account is added, that the system goes and checks the Contracts Object to see if there is a matching Contract to that Account (sometimes Accounts will not have a contract). Normally, I would do this with Access beforehand, but the base files are getting to large for both contracts and accounts. 
What I need is that the code pulls the new account, checks that it has something in the Contract Number Custom Field (Contract_Number__c). If it does, it pulls all the Contracts and does basically a VLOOKUP against the custom field Bg Contract Number (BG_Contract_Number__c). If it finds a match, it fills in the Account lookup field on Contracts. 
Any help would be greatly appreciated.

I was asked by a supervisor to revise a standard e-mail template I created to use under the opportunity.  The way I had it set up was to be sent out as a cover sheet for our proposals to a customer.  At the bottom of the e-mail template I included a "thank you" from the "user" sending it (which includes the user name, title, phon number, extension number (USER FIELD) and e-mail address.

 

However, I was asked to add information in the body of the e-mail that basically says that the sales rep (ACCOUNT OWNER) will be in touch with you, but if you have any immediate question they can be contact by phone number xxx-xxx-xxxx, extension # xxx, and e-mail address xxxxxx@xxx.com.

 

What I cannot add into the e-mail template is the EXTENSION number as this is a custom field I set up in my USER object.

 

Would like the abiltiy to use these custom objects in a template.

 

Thank you.

Terry G

Hi all,

 

How can I create a VF page which looks exactly the same with the Opportunity edit page? Because I need to do some customizing on that edit page. Any ideas will be welcome. Thank you.

Scenario: I have a decimal field defined with 4 decimal points of precision.  When entering data through the UI, if you enter additional decimal points, Salesforce will round the number to 4 decimal points and save this value to the database.

Entered in UI: 0.20006
Presented after saving: 0.2001
Saved in the database (using Eclipse to query): 0.2001

When using the Apex data loader, Salesforce does not enforce decimal precision.

CSV file: 1.283265
In the UI: 1.2833
Saved in the database: 1.283265

Attempting a quick edit of the record in the UI will show the rounded version, and formulas use the rounded version, but Apex code will use the value from the database.

The extended decimal value will stay this way until the record is re-saved through the UI. (even a quick edit on an unrelated field will cause the rounded version to be saved to the database)  An update via Apex DML statement will NOT change the value unless it's explicitly modified with Apex.

----

I realize I can prevent the data loader from importing such extended values by using a validation rule, or enforce a rounded value using a BeforeUpdate/BeforeInsert trigger, but why is Salesforce not rounding the values as they come in via the Data Loader?

The behaviour seems inconsistent to me.

Is this a "bug" or a "feature"?

Hi,

 

 I have the test class written for the class which covers 81%, but i have hardcoded the ids of certian fields 

 

eg:cr.Call_plan__c='a0TW0000000eedn';

 

 

if i move this class to pd that might encounter an test class failure, since those ids wont be present,

 

Please help me hw do it with my code itself

 

@isTest
private class CallReportExtnTest
{


public class PADetails{


}
public static testMethod void CallReportExtn()
{


Test.startTest();
//User usr=[select id,UserName from User where OwnerId=:UserInfo.getUserId()];
//RecordType rt=[select id,developerName from RecordType where sObjectType='Account' and DeveloperName='Business Account'];
String RecTypeId= [select Id from RecordType where (Name='Person Account') and (SobjectType='Account')].Id;
ApexPages.StandardController sc = new ApexPages.standardController(new Call_Report__c());

// create an instance of the controller
CallReportExtn cre = new CallReportExtn(sc);

Call_Report__c cr = new Call_Report__c();
cr.Account__c = '001W00000072EXM';
cr.Name = 'Test GSK';
cr.Date__c=Date.today();
cr.OwnerId=UserInfo.getUserId();
cr.Call_plan__c='a0TW0000000eedn';
// cr.Objective__r.Name='gsktest';
// cr.Objective2__r.Name ='GSK Call report2';

insert cr;

Account acc = new account();
//acc.Name ='Test Account';
acc.RecordTypeId=RecTypeId;
acc.type='Hospital';
acc.BillingStreet='No:12, Sagar street';
acc.Billingcity='Hyderabad';
acc.BillingCountry='India';
acc.BillingState='Andhra Pradesh';
acc.BillingPostalCode='500052';
acc.phone='893964563';
acc.type='Organization';
acc.Segment_Status__c='a';
acc.Total_Number_Of_Patients__c=2;
acc.No_of_Seats__c=2;
acc.LastName = 'Test';
acc.Job_Title__pc='Dentist';
//acc.Primary_Customer__pc ='001W00000072EXM';

//acc.Last_Activity__pc =Date.Today();


insert acc;



CallReportExtn.PADetails CRPAD = new CallReportExtn.PADetails();
Contact con = new Contact();
con.LastName = 'Test';
con.Phone='6853235351';
con.Job_Title__c='Dentist';
con.Has_a_computer__c='yes';
insert con;




CallReportExtn.PdfWrapper wrapper= new CallReportExtn.PdfWrapper();






Brand_Lookup__c bpl = new Brand_Lookup__c();
bpl.Brand_Priority__c='1';
bpl.Name='a0UW00000006P2k';
insert bpl ;







Call_Item__c ci= new Call_Item__c ();

//ci.id='a0WW0000000WEKu';
ci.Brand__c='a0UW00000006P4a';
//ci.Brand__r.name='test';
ci.Position__c='1';
ci.Brand_Call_Plan__c='a0TW0000000ecJv';
ci.Call_Template__c='a0TW0000000ecJv';
insert ci;
//calltemplst = [select id,Brand__c,Brand__r.name,Position__c,Brand_Call_Plan__c from Call_Item__c where Brand_Call_Plan__c in:callplanIdSet ORDER BY Position__c limit 3];



Customer_Brand__c cb = new Customer_Brand__c ();
cb.BBL__c='Unknown';
cb.HCP__c='003W0000009LKIz';
insert cb;


cre.baAccInfo();









Test.stopTest();

}
}

 

Thanks in Advance

Hi.

 

I am totally stumped on this one, and this is a simple scenario:

 

1. VAL rule on opportunity (create or edit)

2. Check Opportunity Record Type name against Account record type name

3. If the first two letters are different then error

 

       LEFT(Account.Record_Type_Label__c,2)<>LEFT($RecordType.Name,2)

 

4. Account.Record_Type_Label__c is a formula referencing the Record type name on account

 

It will error when I say LEFT(Account.Record_Type_Label__c,2) =  LEFT($RecordType.Name,2) but when

I do not equal to no error ... what the?

 

Record type name example is Opp Rectype Name = US Opportunity and Account Rectype Name = AU Account

 

ANY ideas on this one? I need to use the first two letters, have also tried MID, no luck ...

  • November 20, 2012
  • Like
  • 0

Error Message:

Error: GoogleChartsController Compile Error: Incompatible types since an instance of ApexPages.StandardController is never an instance of Account at line 5 column 15

Controller:

global class GoogleChartsController {
 global static Account acc;
 
    public GoogleChartsController(ApexPages.StandardController controller) {
        acc = (Account)controller.getRecord();
    }
@RemoteAction   
    global static AggregateResult[] loadChildCases(Id prmAccountId) {
        AggregateResult[] caseLst = [Select ParentId, count(Id) FROM Case  WHERE AccountId = :prmAccountId Group By ParentId ];
        
        return caseLst;
    }
    }

 

VF Page:

<apex:page extensions="GoogleChartsController" sidebar="false" standardController="Account" showHeader="false" pageStyle="Account"  >
    <apex:includeScript id="a" value="https://www.google.com/jsapi" />     
    <script type="text/javascript">
        // Load the Visualization API and the piechart package.
        google.load('visualization', '1.0', {'packages':['corechart']});
        // Set a callback to run when the Google Visualization API is loaded.
        google.setOnLoadCallback(initCharts);
        //load all the charts..
        function initCharts() {
              GoogleChartsController.loadChildCases('{!acc.Id}', function(resultCase, event){  
                  var visualization = new google.visualization.ColumnChart(document.getElementById('caseChart'));
                  var data1 = new google.visualization.DataTable();  
                  data1.addColumn('string', 'Cases');
                  data1.addColumn('number', 'Cases');       
                  //add rows from the remoting results
                  for(var i =0; i < resultCase.length; i++){
                      var r = resultCase[i];
                      data1.addRow([r.Id, r.expr0]);
                   }
                    // all done, lets draw the chart with some options to make it look nice.
                    visualization.draw(data1, {legend : {position: 'top', textStyle: {color: 'blue', fontSize: 10}}, width:150,vAxis:{textStyle:{fontSize: 10}},hAxis:{textStyle:{fontSize: 10},showTextEvery:1,slantedText:false}});
              }, {escape:true});
              
          }
    </script>
     <div id="caseChart" />
</apex:page>

Hi.

We are trying to get a case age formual to work like one that we currently have in an excel spreadsheet.

Custom Date Fields:
Date Opened - 1/3/2012 9:43am
Date Resolved - 1/18/2012 8:42am

Excel Formula: =IF(C5654="",0,(NETWORKDAYS(B5654,C5654,holidays)-1)*(end-start)+IF(NETWORKDAYS(C5654,C5654,holidays),MEDIAN(MOD(C5654,1),
end,start),end)-MEDIAN(NETWORKDAYS(B5654,B5654,holidays)*MOD(B5654,1),end,start))

EXCEL Age in Business Hours: 120:17

Salesforce Formula:
If(IsNull(Date_Resolved__c ),

CASE(MOD( DateValue(Date_Opened__c ) - DATE(1985,6,24),7), 0 ,
CASE( MOD( Today() - DateValue(Date_Opened__c ) ,7),1,2,2,3,3,4,4,5,5,5,6,5,1), 1 ,
CASE( MOD( Today() - DateValue(Date_Opened__c ) ,7),1,2,2,3,3,4,4,4,5,4,6,5,1), 2 ,
CASE( MOD( Today() - DateValue(Date_Opened__c ) ,7),1,2,2,3,3,3,4,3,5,4,6,5,1), 3 ,
CASE( MOD( Today() - DateValue(Date_Opened__c ) ,7),1,2,2,2,3,2,4,3,5,4,6,5,1), 4 ,
CASE( MOD( Today() - DateValue(Date_Opened__c ) ,7),1,1,2,1,3,2,4,3,5,4,6,5,1), 5 ,
CASE( MOD( Today() - DateValue(Date_Opened__c ) ,7),1,0,2,1,3,2,4,3,5,4,6,5,0), 6 ,
CASE( MOD( Today() - DateValue(Date_Opened__c ) ,7),1,1,2,2,3,3,4,4,5,5,6,5,0), 999)
+ (FLOOR(( Today() - DateValue(Date_Opened__c ) )/7)*5-1)*11,

CASE(MOD( DateValue(Date_Opened__c ) - DATE(1985,6,24),7), 0 ,
CASE( MOD( DateValue(Date_Resolved__c ) - DateValue(Date_Opened__c ) ,7),1,2,2,3,3,4,4,5,5,5,6,5,1), 1 ,
CASE( MOD( DateValue(Date_Resolved__c ) - DateValue(Date_Opened__c ) ,7),1,2,2,3,3,4,4,4,5,4,6,5,1), 2 ,
CASE( MOD( DateValue(Date_Resolved__c ) - DateValue(Date_Opened__c ) ,7),1,2,2,3,3,3,4,3,5,4,6,5,1), 3 ,
CASE( MOD( DateValue(Date_Resolved__c ) - DateValue(Date_Opened__c ) ,7),1,2,2,2,3,2,4,3,5,4,6,5,1), 4 ,
CASE( MOD( DateValue(Date_Resolved__c ) - DateValue(Date_Opened__c ) ,7),1,1,2,1,3,2,4,3,5,4,6,5,1), 5 ,
CASE( MOD( DateValue(Date_Resolved__c ) - DateValue(Date_Opened__c ) ,7),1,0,2,1,3,2,4,3,5,4,6,5,0), 6 ,
CASE( MOD( DateValue(Date_Resolved__c ) - DateValue(Date_Opened__c ) ,7),1,1,2,2,3,3,4,4,5,5,6,5,0), 999)
+ (FLOOR(( DateValue(Date_Resolved__c ) - DateValue(Date_Opened__c ) )/7)*5-1))*11


SALESFORCE Age in Business Hours: 121.00

How can I get the SFDC formula to stop rounding? I think that's what it's doing. 

I am trying to deploy a new trigger and can't because the test below is failing. It is failing with the following error:

 

16:04:51.566 (566509000)|EXCEPTION_THROWN|[37]|System.DmlException: ConvertLead failed. First exception on row 0; first error: INVALID_STATUS, invalid convertedStatus: Qualified: []

 

Yet when I run the query specified in teh following line:

 

LeadStatus convertStatus = [SELECT Id, MasterLabel FROM LeadStatus WHERE IsConverted = true LIMIT 1];

 

The status returned is 'Qualified' which is a valid status. Could anyone shed light on what may be going on... Thank you in advance.

 

private class TestPopulateCloseDateOnOppOnLeadConvert {

static testMethod void PopulateCloseDateOnOppOnLeadConversion() {

//Create
Lead lead = new Lead(LastName='Test', Company='Test', Business_Unit__c='EPS', CurrencyISOCode='USD', Status='Unqualified');
insert lead;

//Invoke
test.startTest();
Database.LeadConvert lc = new Database.LeadConvert();
lc.setLeadId(lead.Id);
LeadStatus convertStatus = [SELECT Id, MasterLabel FROM LeadStatus WHERE IsConverted = true LIMIT 1];
lc.setConvertedStatus(convertStatus.MasterLabel);
Database.LeadConvertResult lcr = Database.convertLead(lc);
system.assert(lcr.isSuccess());
test.stopTest();

//Check
id oppId = lcr.getOpportunityId();
Opportunity opp = [SELECT Id, CloseDate FROM Opportunity WHERE Id = :oppId];
system.assertEquals(system.today().addDays(3), opp.CloseDate);

}
}

In case anyone is trying the new HttpCalloutMock to test a trigger ->  future method -> callout method combination:  i'm getting the same "uncommitted work pending" error as described in this thread:

 

http://boards.developerforce.com/t5/Apex-Code-Development/Testing-Webservice-Callouts-with-Winter-13-Test-setMock-fails/m-p/536485#M97364

 

This is occurring even when the only DML in my test code is the DML needed to fire the trigger.

 

The trigger and methods are working fine at the UI level, just not in unit tests.

Hi all,

 

I enabled customer portal and autoregistration (with authenticated website license) for my site.

The standard profile "Authenticated Website" doesn't permit to access to the custom object of my app.

 

How can I enable access to custom object for authenticated users on the site?

 

 

Hi,

 

 

We've created an email template which references fields of a custom object named Intervention.

Intervention object has a  detail button that must send  email using that template. We are receiving the error "Invalid whatId" when we try to send email.

In javascript implemented in the button we have assigned the field Name (standard ID field ) of Intervention to property whatId of SingleEmailMessage.  

 

Can someone help us what is the problem with whatId?

 

A excerpt of our code below:

 

.....

var req = new sforce.SingleEmailMessage();
req.orgWideEmailAddressId = [orgWideEmailAddresstId ];
req.ccAddresses =[ ccSupervisao, ccSuporte ];
                       
//Sender will receive a copy of the mass e-mail sent
req.bccSender=true;
                                                                                
req.emailPriority='High';
req.replyTo=targetAddress;

req.targetObjectId=targetObjectId;
req.saveAsActivity=false;
var name = {!Intervention__c.Name};
req.whatId = name;

 

// Query template ID
var templateName = "{!Intervention__c.Modelo_de_Email__c}";
var queryEmailTemplate = sforce.connection.query("select Id from EmailTemplate where name ='" + templateName + "'");
var templateId = queryEmailTemplate.getArray("records")[0].Id;

req.templateId=templateId;

.....

 

Many thanks,

Ana

  • October 17, 2012
  • Like
  • 0