• abhik dey 1
  • NEWBIE
  • 5 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 14
    Questions
  • 19
    Replies
I have a lookup relationship with a custom object to standard lead object. I wanted to delete the custom object records when the related lead record got deleted from the system.
I wanted to know apart from writing a logic in trigger , is their any other possible ways through which I can achieve this functioanlity ?
Any Ideas ?
I have a scenario where in i query an html email template with letterhead and populate its merge fields in my apex class itself.
however,when i use the sethtmlBody() method,it renders an empty email to the customers.

Below code snippet:

public class testclassforemail {
    public static void sendemail(){
        EmailTemplate etdfinalNotification=[Select id,HtmlValue from EmailTemplate where name = 'letterheadtemplate' limit 1];
        Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
        mail.setTemplateId(etdfinalNotification.Id);
        mail.setTargetObjectId(userinfo.getUserId());
        mail.setToAddresses(new String[] {'testuser@gmail.com'});
        String htmlbdy = etdfinalNotification.HtmlValue.replace('{!User.Name}','mynamecheck');
        mail.setHtmlBody(htmlbdy);
      //  mail.setSubject('User De-activate Status');
        //   mail.setPlainTextBody('The batch Apex job processed111 ');
        mail.setSaveAsActivity (false);
        mail.setTreatTargetObjectAsRecipient(false);
        system.debug('***'+mail);
        Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
    }
}

If I comment out the sethtmlbody and the setsubject , it works fine and the email gets delivered. However inorder to change the merge fields I have to use SETHTMLBODY with string replace.

Anyone experience this issue? or any workaround will help 
I have created a batch APEX,

Below code

global class batchApexJob implements Database.Batchable<sObject> {
global Database.QueryLocator start(Database.BatchableContext BC) { String UsrQuery='';
UsrQuery = 'SELECT Id,isActive,LastLoginDate,Email,ManagerId FROM USER WHERE isActive = true AND LastLoginDate !=null'; return Database.getQueryLocator(UsrQuery);
}
global void execute(Database.BatchableContext BC, List<user> usrRecords) {
EmailTemplate etId=[Select id from EmailTemplate where name = 'ManagerEmail' limit 1];
if(usrRecords.size()>0){
for (User u : usrRecords){
if(System.now() > u.LastLoginDate.addDays(60)){
// for less than 90 days
system.debug('@@@'+u);
Messaging.MassEmailMessage mail = new Messaging.MassEmailMessage ();
mail.setTargetObjectIds(ids);
mail.setSenderDisplayName('Notification 1'); mail.setTemplateId(etId.id);
mail.setSaveAsActivity (false);
listofemails.add(mail);
Messaging.SendEmailResult[] r1 = Messaging.sendEmail(new Messaging.MassEmailMessage [] { mail });
}

while writing the test class for the same how to modfify the lastlogindate of the user, I dont see any methods availbale to change the last login date. After creating the user, is their any way i can change the last login date?
Is their any login attempts i can make and change the lastlogindate so that my batch class run.

Any Ideas to cover the batch class code coverage?
Hi Everyone,

As part of these module, can you help me understanding the below logic

in order to display the expense from APEX, below is the logic used
({
    doinit : function(component, event, helper) {
        var action = component.get("c.getExpenses");
        action.setCallback(this,function(response){
           var state = response.getState();
            if(component.isValid() && state == "SUCCESS"){ 
           //     var expview = component.get("v.expenses");
            //    expview.push(response.getReturnValue());
               // component.set("v.expenses",JSON.parse(JSON.stringify(expview)));
                component.set("v.expenses",response.getReturnValue());
            }else{
                console.log(state);
            }
        });
        $A.enqueueAction(action);
    }
})

Apex:code
public class ExpensesController {

    @AuraEnabled
    public static List<Expense__c> getExpenses(){
        return [Select Id,Amount__c,Client__c,Date__c,Reimbursed__c,Name from Expense__c] ;       
    } 

Aura Attribute expenses is getting set with the controller response (component.set("v.expenses",response.getReturnValue());). But If I want to use the commented lines,  by doing a push and then set the component. It didn't work. WHy is that so ? I am doing a component get and then pushing the value which is the way even showed in the later section of this module while saving an expense record.

When to use the PUSH and when i can directly do a component.set?

can anyone help me in clarifying the doubts ??
Hi Everyone,

As part of these module, can you help me understanding the below logic

in order to display the expense from APEX, below is the logic used
({
    doinit : function(component, event, helper) {
        var action = component.get("c.getExpenses");
        action.setCallback(this,function(response){
           var state = response.getState();
            if(component.isValid() && state == "SUCCESS"){ 
           //     var expview = component.get("v.expenses");
            //    expview.push(response.getReturnValue());
               // component.set("v.expenses",JSON.parse(JSON.stringify(expview)));

                component.set("v.expenses",response.getReturnValue());
            }else{
                console.log(state);
            }
        });
        $A.enqueueAction(action);
    }
})

Apex:code
public class ExpensesController {

    @AuraEnabled
    public static List<Expense__c> getExpenses(){
        return [Select Id,Amount__c,Client__c,Date__c,Reimbursed__c,Name from Expense__c] ;       
    } 

Aura Attribute expenses is getting set with the controller response (component.set("v.expenses",response.getReturnValue());). But If I want to use the commented lines,  by doing a push and then set the component. It didn't work. WHy is that so ? I am doing a component get and then pushing the value which is the way even showed in the later section of this module while saving an expense record.

When to use the PUSH and when i can directly do a component.set?

can anyone help me in clarifying the doubts ??
I have a parent case on which three files are uploaded; now while creating the sub case from the related case section, these attachment should automatically visible in the subcase as well.

One solution: I did by re-inserting the same parent files in the sub case as well. with these the same file is created multiple times.
User-added image
Is their any way I can use the same file in multiple cases without re-inserting the same?
After every Production refresh activity, we have to manually update the workflow email alerts. Is their any way to automate the process through any Continuous Integration process ?

I used force.com CLI and metadata API but not finding any way to update the email alerts through any automation process 
While trying to use the query editor in developer console.

"SELECT ID FROM ACCOUNT"

It throws an erorr saying "This session is not valid for use with the REST API". Any idea what excatly tthe issue here. Earlier it workerd fine.
The same problem when i click on "Open" dialog of developer console and select objects.

"CANNOT LOAD OBjects.This session is not valid for use with the REST API"
Is it possible to capture the signed request in salesforce before it hits the Canvas end point? I have the canvas implemented in VF page and I wanted to capture the signed request from salesforce with which it hits the canvas end point URL.

Any Ideas how to capture the signed request?
I had developed an app using Canvas. While loading Canvas, it shows an error like,

" Oops, there was an error rendering Force.com Canvas application [My app].Your browsing session has ended or is invalid. Please re-login to Salesforce.com again "

The app was working fine before. But now it is frequently showing this error. Also it teminates the salesforce session
The Access Method in the Canvas App Settings is Signed Request (POST)

Can anyone help me with that?

I searched in lot of forums many people faced it but didn't have any solution posted.
In the HTML email template I want to distinguish between internal and external user while sending any email. I tried using If loop and it worked for me but while I try to access certain merge fields values its not populating any results.

{!Receiving_User.Contact}
{!Receiving_User.ContactId}
{!Receiving_User.Division}
{!Receiving_User.Legacy_Username__c}  [Custom Field]
{!Receiving_User.Email}
{!Receiving_User.ProfileId}

I know receiving user takes the value from the contact, if so then how come my {!Receiving_User.username} gets populated. Also , is their any other way to distinguis between this two types users .

Below is the If loop i used which worked fine but since the above merge fields is not providing any value, it is not helping me any further.

###### {!IF(Receiving_User.ContactId=="",'abc', "2")}.

Any help. I need this urgent !
Hi,
I have to freeze or lock out an external user based on a custom logic. Once the custom logic condition sets to true, I need to freeze or lock out that user so that the user wont be able to login until the admin unfreeze or unlock that external user.

I tried with isPasswordlockout  API field, but i got the error as 'Field is not re-writable' so I tried with freeze option but since when the user already logged in and the salesforce apex code or trigger runs in that user mode , i got the error "CANNOT SELF FREEZE" self frozen is not allowed.

My requirement is to lock or freeze that user when he performs some action and based on my custom logic , the user should be locked or freezed.
Also, I cant use the site.login method for 3 invalid attempts. So that option is gone apart from that anything is possible?

I tried with system.runas method but that works only in case of test method.

Any suggestions??
How to control the order in a future callouts for the same object. In the Account object I need to make two callouts in after insert trigger. Now being future notation my second call out is getting fired first and then the first call out. But I need the other way ....Any ideas?
VF Page:

<apex:page sidebar="false" controller="asd">
<apex:form id="abc">
<apex:actionFunction name="a1" action="{!checkparam}" reRender="foo">
<apex:param id="aname" value="" name="param1" assignTo="{!g1}"/>
</apex:actionFunction>
{!g1}
</apex:form>
<button type="button" onclick="a1('page1')">Click Me </button>

</apex:page>

Controller:

public class asd {
    public string g1{
    get {
    g1='getter';
    return g1;
    }
    set{
    g1='setter';
    }
    }
public asd(){
g1='cons';
}
    public void checkparam() {
    system.debug('$$$'+g1);
    }

}

Above are the page and the controller,on clicking the button click me I am passing the parameter to a Apex method in the controller.
but evrytime I got "getter" value in the debug statement in the method checkparam (above class).
Is it like whatever is their in the getter method I will be getting that value only in the methods irrespective of any modification???
Now if I change my code to :

public class asd {
    public string g1{get ;set}
public asd(){
g1='cons';
}
    public void checkparam() {
    system.debug('$$$'+g1);
    }

}

I am able to get the page value in the controller method debug statement.

Can anyone have any idea on this behaviour???

 
I have a lookup relationship with a custom object to standard lead object. I wanted to delete the custom object records when the related lead record got deleted from the system.
I wanted to know apart from writing a logic in trigger , is their any other possible ways through which I can achieve this functioanlity ?
Any Ideas ?
I have a lookup relationship with a custom object to standard lead object. I wanted to delete the custom object records when the related lead record got deleted from the system.
I wanted to know apart from writing a logic in trigger , is their any other possible ways through which I can achieve this functioanlity ?
Any Ideas ?
I have created a batch APEX,

Below code

global class batchApexJob implements Database.Batchable<sObject> {
global Database.QueryLocator start(Database.BatchableContext BC) { String UsrQuery='';
UsrQuery = 'SELECT Id,isActive,LastLoginDate,Email,ManagerId FROM USER WHERE isActive = true AND LastLoginDate !=null'; return Database.getQueryLocator(UsrQuery);
}
global void execute(Database.BatchableContext BC, List<user> usrRecords) {
EmailTemplate etId=[Select id from EmailTemplate where name = 'ManagerEmail' limit 1];
if(usrRecords.size()>0){
for (User u : usrRecords){
if(System.now() > u.LastLoginDate.addDays(60)){
// for less than 90 days
system.debug('@@@'+u);
Messaging.MassEmailMessage mail = new Messaging.MassEmailMessage ();
mail.setTargetObjectIds(ids);
mail.setSenderDisplayName('Notification 1'); mail.setTemplateId(etId.id);
mail.setSaveAsActivity (false);
listofemails.add(mail);
Messaging.SendEmailResult[] r1 = Messaging.sendEmail(new Messaging.MassEmailMessage [] { mail });
}

while writing the test class for the same how to modfify the lastlogindate of the user, I dont see any methods availbale to change the last login date. After creating the user, is their any way i can change the last login date?
Is their any login attempts i can make and change the lastlogindate so that my batch class run.

Any Ideas to cover the batch class code coverage?
Hi Everyone,

As part of these module, can you help me understanding the below logic

in order to display the expense from APEX, below is the logic used
({
    doinit : function(component, event, helper) {
        var action = component.get("c.getExpenses");
        action.setCallback(this,function(response){
           var state = response.getState();
            if(component.isValid() && state == "SUCCESS"){ 
           //     var expview = component.get("v.expenses");
            //    expview.push(response.getReturnValue());
               // component.set("v.expenses",JSON.parse(JSON.stringify(expview)));
                component.set("v.expenses",response.getReturnValue());
            }else{
                console.log(state);
            }
        });
        $A.enqueueAction(action);
    }
})

Apex:code
public class ExpensesController {

    @AuraEnabled
    public static List<Expense__c> getExpenses(){
        return [Select Id,Amount__c,Client__c,Date__c,Reimbursed__c,Name from Expense__c] ;       
    } 

Aura Attribute expenses is getting set with the controller response (component.set("v.expenses",response.getReturnValue());). But If I want to use the commented lines,  by doing a push and then set the component. It didn't work. WHy is that so ? I am doing a component get and then pushing the value which is the way even showed in the later section of this module while saving an expense record.

When to use the PUSH and when i can directly do a component.set?

can anyone help me in clarifying the doubts ??
Hi Everyone,

As part of these module, can you help me understanding the below logic

in order to display the expense from APEX, below is the logic used
({
    doinit : function(component, event, helper) {
        var action = component.get("c.getExpenses");
        action.setCallback(this,function(response){
           var state = response.getState();
            if(component.isValid() && state == "SUCCESS"){ 
           //     var expview = component.get("v.expenses");
            //    expview.push(response.getReturnValue());
               // component.set("v.expenses",JSON.parse(JSON.stringify(expview)));

                component.set("v.expenses",response.getReturnValue());
            }else{
                console.log(state);
            }
        });
        $A.enqueueAction(action);
    }
})

Apex:code
public class ExpensesController {

    @AuraEnabled
    public static List<Expense__c> getExpenses(){
        return [Select Id,Amount__c,Client__c,Date__c,Reimbursed__c,Name from Expense__c] ;       
    } 

Aura Attribute expenses is getting set with the controller response (component.set("v.expenses",response.getReturnValue());). But If I want to use the commented lines,  by doing a push and then set the component. It didn't work. WHy is that so ? I am doing a component get and then pushing the value which is the way even showed in the later section of this module while saving an expense record.

When to use the PUSH and when i can directly do a component.set?

can anyone help me in clarifying the doubts ??
I have a parent case on which three files are uploaded; now while creating the sub case from the related case section, these attachment should automatically visible in the subcase as well.

One solution: I did by re-inserting the same parent files in the sub case as well. with these the same file is created multiple times.
User-added image
Is their any way I can use the same file in multiple cases without re-inserting the same?
While trying to use the query editor in developer console.

"SELECT ID FROM ACCOUNT"

It throws an erorr saying "This session is not valid for use with the REST API". Any idea what excatly tthe issue here. Earlier it workerd fine.
The same problem when i click on "Open" dialog of developer console and select objects.

"CANNOT LOAD OBjects.This session is not valid for use with the REST API"
Is it possible to capture the signed request in salesforce before it hits the Canvas end point? I have the canvas implemented in VF page and I wanted to capture the signed request from salesforce with which it hits the canvas end point URL.

Any Ideas how to capture the signed request?
On a custom object, I've managed to auto populate the custom object's name field to a default value using below custom apex page code:
<apex:page standardController="CustomObject__c"
    action="{!URLFOR($Action.CustomObject__c.New, null, ['Name'='Default Value'], true)}"  
/>
Now in addition to the Name field I also want to auto populate a Master-Detail field on the Custom object but it's not working. My code:
<apex:page standardController="CustomObject__c"
    action="{!URLFOR($Action.CustomObject__c.New, null, ['Name'='Default Value', Master-Detail__c='Default Value'], true)}"  
/>

I have been struggling to find reference to the proper syntax. I also have been wondering how does one view all the apex codes created for a custom object, as a starting point to learn the apex coding language.
In the HTML email template I want to distinguish between internal and external user while sending any email. I tried using If loop and it worked for me but while I try to access certain merge fields values its not populating any results.

{!Receiving_User.Contact}
{!Receiving_User.ContactId}
{!Receiving_User.Division}
{!Receiving_User.Legacy_Username__c}  [Custom Field]
{!Receiving_User.Email}
{!Receiving_User.ProfileId}

I know receiving user takes the value from the contact, if so then how come my {!Receiving_User.username} gets populated. Also , is their any other way to distinguis between this two types users .

Below is the If loop i used which worked fine but since the above merge fields is not providing any value, it is not helping me any further.

###### {!IF(Receiving_User.ContactId=="",'abc', "2")}.

Any help. I need this urgent !
Hi,
I have to freeze or lock out an external user based on a custom logic. Once the custom logic condition sets to true, I need to freeze or lock out that user so that the user wont be able to login until the admin unfreeze or unlock that external user.

I tried with isPasswordlockout  API field, but i got the error as 'Field is not re-writable' so I tried with freeze option but since when the user already logged in and the salesforce apex code or trigger runs in that user mode , i got the error "CANNOT SELF FREEZE" self frozen is not allowed.

My requirement is to lock or freeze that user when he performs some action and based on my custom logic , the user should be locked or freezed.
Also, I cant use the site.login method for 3 invalid attempts. So that option is gone apart from that anything is possible?

I tried with system.runas method but that works only in case of test method.

Any suggestions??
VF Page:

<apex:page sidebar="false" controller="asd">
<apex:form id="abc">
<apex:actionFunction name="a1" action="{!checkparam}" reRender="foo">
<apex:param id="aname" value="" name="param1" assignTo="{!g1}"/>
</apex:actionFunction>
{!g1}
</apex:form>
<button type="button" onclick="a1('page1')">Click Me </button>

</apex:page>

Controller:

public class asd {
    public string g1{
    get {
    g1='getter';
    return g1;
    }
    set{
    g1='setter';
    }
    }
public asd(){
g1='cons';
}
    public void checkparam() {
    system.debug('$$$'+g1);
    }

}

Above are the page and the controller,on clicking the button click me I am passing the parameter to a Apex method in the controller.
but evrytime I got "getter" value in the debug statement in the method checkparam (above class).
Is it like whatever is their in the getter method I will be getting that value only in the methods irrespective of any modification???
Now if I change my code to :

public class asd {
    public string g1{get ;set}
public asd(){
g1='cons';
}
    public void checkparam() {
    system.debug('$$$'+g1);
    }

}

I am able to get the page value in the controller method debug statement.

Can anyone have any idea on this behaviour???

 
hi all,

i have a scenario where in i query an html email template and populate its merge fields in my apex class itself.
however,when i use the sethtmlBody() method,it renders an empty email.
So i have to comment the sethtmlbody() and go with setplaintextbody().

What can be the reason for this?
Also how do i use the setHtmlBody() along with setplainTextBody()?

Below is my code
 
public static void sendingEmail(String cid,String cname,String eventId)
    {
        String plainTxtBody='',startDate='',endDate='',scheduledDate='';
        String hbody='';
        Date sdate;

        //get the email template
        EmailTemplate template=[SELECT HtmlValue,Body FROM EmailTemplate WHERE          DeveloperName='Meeting_Reminder'];
        
        Event eve=[select subject,StartDateTime,EndDateTime,Owner.name,Owner.Email,Owner.Phone 
                    From Event where Id=:eventId];
                    
        hbody=template.HtmlValue;
        
        //setting the merge fields
        hbody=hbody.replace('{!Contact.Name}',cname);
        hbody=hbody.replace('{!Event.Subject}',eve.Subject);
         
        plainTxtBody=template.Body;
        plainTxtBody=plainTxtBody.replace('{!Contact.Name}',cname);
        plainTxtBody=plainTxtBody.replace('{!Event.Subject}',eve.Subject);
        
        //Construct the email message
        Messaging.SingleEmailMessage mail=new Messaging.SingleEmailMessage();
        mail.setTargetObjectId(cid);
        mail.setSaveAsActivity(false);
        mail.setSubject('Meeting Reminder');
        //mail.setHtmlBody(hbody);
        mail.setPlainTextBody(plainTxtBody);
        Messaging.sendEmail(new Messaging.SingleEmailMessage[]{mail});     
    }
Also can anyone explain why do we have to set the plaintextbody() even when the email template is of type html?

Any help is appreciated...

Thanks,
 
Hi,

I had developed an app using Canvas. While loading Canvas, it shows an error like,

‘“Oops, there was an error rendering Force.com Canvas application [Hello World].Your browsing session has ended or is invalid. Please re-login to Salesforce.com again.”
User-added image



The app was working fine before. But now it is frequently showing this error. But once I clear the browser cache and then try again, it works well for a while.  After some time it shows the same error.
The Access Method in the Canvas App Settings is Signed Request (POST)

The visual force page looks like,
<apex:page controller="CanvasController">
	..
	..
	<apex:canvasApp id="canvasFrame" applicationName="HelloWorld" parameters="{!parameters}" width="100%"/>
	..
	..
</apex:page>

And the Controller looks like
public class CanvasController{
	public string parameters{get;set;}
	public Contact contactRecord;
	...
	…
	public void someMethod(){
		..
		contactRecord = [SELECT Id, Name FROM Contact LIMIT 1];
		parameters = JSON.serialize(contactRecord);
	}
}
Please help me if you have any idea. Thanks in advance. 
I have the following code that sends a mass email out based on a end date being past due. Being a very new apex developer I need some help with the following task. The main list of people receiving the mass email is setup in the getSPEEmailAddresses module. The problem I am having is that there is a public group defined in the getpublicgroupaddresse module that I need to cc on each email going out in the getSPEEmailaddresses module and I don't know how to go about doing that. Can anyone adjust the below code to accomplish that task?

/**************************************************************************/
//The SPEs past due Notice Emailer
//
//This class can be scheduled to run nightly to send emails to SPE
//owners, and the public group called SPE_Pastdue_Notification
// when the End DAte (End_Date__c) is within 14 days of being past due
// and the routing status = approved.
//
/***************************************************************************/

global class SPEs_Pastdue implements Schedulable{


     //mandataory function called by the Apex Scheduler
  //**************************************************
  global void execute(SchedulableContext SC) {
        //**************************************************
        sendmail(); // our main function that does the email sending
     }//end execute

  //Get email addresses of people pastdue SPEs by 14 days
//**************************************************
    public List<Id> getSPEEmailAddresses(Date CalDate) {     
    //**************************************************
         List<Id> mailToIds = new List<Id>();
         
         //find a list of SPEs with overdue end dates
         Sales_Policy_Exceptions__c[] c = [SELECT Id, End_Date__C, Routing_Status__c, owner_email__c
             FROM Sales_Policy_Exceptions__c
             WHERE End_Date__c <= : CalDate
                            AND Routing_Status__c = 'Approved'
             ];                
                         // Old Date samples 
          // DAY_IN_MONTH(CloseDate) = : Day
      // AND CALENDAR_MONTH(CloseDate) = : Month
                        //  AND CALENDAR_Year(CloseDate) = : Year
           
           
   //add the list of Sales_Policy_Exceptions__c to a list       
         for(Sales_Policy_Exceptions__c recipient : c) {
         
          
           System.Debug('\n*******Found Sales_Policy_Exceptions__c Recipient');
                     
           if (recipient.owner_Email__c != '')
           {
            mailToIds.add(recipient.Id); // add to email SPE array
            System.Debug('\n*******Recipient: '+ recipient.owner_email__c); 
           } else {
            //Just add to chatter array
            System.Debug('\n*******NO Recipient');
           } //end if        
         } //end for loop

         return mailToIds;   //return the list
      } //end getSPEEmailAddresses()
   
    //**************************************************
    public List<String> getPublicGroupAddresses() {
    //**************************************************
  List<String> idList = new List<String>();
  List<String> mailCCAddresses = new List<String>();
        List<ID> mailCCAddressesID = new List<ID>();
  Group g = [SELECT (select userOrGroupId from groupMembers) FROM group WHERE name = 'SPE_Pastdue_Notification'];
   for (GroupMember gm : g.groupMembers) {
   idList.add(gm.userOrGroupId);
  } //End group
  User[] usr = [SELECT email FROM user WHERE id IN :idList];
  for(User u : usr) {
   mailCCAddresses.add(u.email);
            mailCCAddressesID.add(u.id);
  } //end for loop
return mailCCAddresses;      
}   //End getPublicGroupAddresses

//**************************************************
    public void sendMail() {
    //**************************************************
   //define variables     
   String debugAddress = 'xxx@newpagecorp.com';
   String SPEEmailTemplateName = 'Opportunity_Past_Due_Notice';  
   String debugMessage;
         String[] toAddresses;

            Date CalDate = date.Today().addDays(14);

            System.Debug('Date '+CalDate);


   // build the Overdue list

   //get the list of people with overdue Sales_Policy_Exceptions__c - this can justifiably come back empty.
         List<Id> SPEIdsList = getSPEEmailAddresses(CalDate);
            List<Id> SPEgroupList = getPublicGroupAddresses();

   //Set the templates
         EmailTemplate SPETemplate = [select Id,Name,Subject,body from EmailTemplate where DeveloperName = :SPEEmailTemplateName];
 
         if(SPETemplate != null && SPEIdsList.isEmpty() == false)
         {

             Messaging.MassEmailMessage SPEMail = new Messaging.MassEmailMessage();
       
             SPEMail.setTargetObjectIds(SPEIdsList);
             SPEMail.setTemplateId(SPETemplate.Id);
             SPEMail.setUseSignature(false);
             SPEMail.setSaveAsActivity(true);

             // Send the email
             try {
              Messaging.sendEmail(new Messaging.MassEmailMessage[] { SPEMail });
                    System.Debug('Mail sent');
             }catch(Exception e)
             {
              System.Debug(e);
             }
          
         }
         else
         {
             System.Debug('SPECronJob:sendMail(): Either an email template could not be found, or no opportunities are overdue');
         }//end if

               
  }//end sendMail()
}   //SPEs_Pastdue end
Hi

I want to encryption and decryption password field using apex and vfpage any ideas appreciate

Thanks,
Hareesh
  • April 28, 2014
  • Like
  • 0

I am having an issue getting my command line data loader to function.  I am using date loader 23.0

 

I have encrypted the password and security token as outlined in the cheatsheet for 9.0. 

 

I have verified that I can log onto data loader using the userid, password and security token, so I know the user is not locked out.

 

Here is my error message:

 

java.lang.RuntimeException: Invalid username, password, security token; or user locked out.
 at com.salesforce.dataloader.process.ProcessRunner.run(ProcessRunner.java:134)
 at com.salesforce.dataloader.process.ProcessRunner.run(ProcessRunner.java:74)
 at com.salesforce.dataloader.process.ProcessRunner.main(ProcessRunner.java:226)
Caused by: [LoginFault [ApiFault  exceptionCode='INVALID_LOGIN'
 exceptionMessage='Invalid username, password, security token; or user locked out.'
]]

 

Here is the password portion of my code:

<entry key="sfdc.password" value="41683bf7a6a116b7d92ce4e857e7b510"/>
                <entry key="process.encryptionKeyFile" value="C:\Program Files (x86)\salesforce.com\Apex Data Loader 23.0\conf\Key.txt" />

Any ideas?

 

 

 

 

 

  • January 17, 2013
  • Like
  • 0

On the Account object I have created a formula field called Domain_Name__c . The formula I have used is this,

 

SUBSTITUTE(Website, LEFT(Website, FIND("www.", Website)), NULL)

 

Where website is a standard field on Account.

 

If Website is www.xyzdomain.com or https://www.xyzdomain.com

 

In Domain_Name__c I expected result as xyzdomain.com

 

Instead i am getting the result either as

.xyzdomain.com or ww.xyzdomain.com depending on whether the Email entered was 'www.xyzdomain.com' or 'https://www.xyzdomain.com'


Any thoughts how I can only get the text after the .   

 

e.g If, in the field Website  I enter www.salesforce.com  or  https://www.salesforce.com the result in the Domain_Name__c should be salesforce.com