• BakT
  • NEWBIE
  • 40 Points
  • Member since 2012

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 9
    Replies
Hey there,

I have a workflow rule which is designed to create a new task and assign it another user, then change the old task to 'failed to action'.

This workflow rule is emant to trigger when this occurs:

and( (Subject = 'Call Prospective Client'), ( Expiry_Test__c = now()), (ISPICKVAL(Status, 'Not Started')) )

It is howeer not working, is it possible to trigger a workflow in this way? Would it be better to do this via a trigger?

Thank you
Hi guys,

I tried following the email services sample code but I am running into a problem with the test class. For some reason it's giving me the error: Error: Compile Error: unexpected token: '=' at line 11 column 28

Here's the link to the sample email services: https://developer.salesforce.com/page/An_Introduction_To_Email_Services_on_Force.com 
  • April 22, 2014
  • Like
  • 0

I hope somebody will be able to help me with this:

 

I have a trigger on Account that checks if the Account is created from a record forwarded by the partner using Salesforce to Salesforce. I am trying to create a test class for this but unfortunately, I don't think it's possible to create an account record on a test class and tell it that it came from a parter and not created locally. Any help?

  • January 19, 2012
  • Like
  • 0

Hi,

 

I am trying to automate the Account sharing on a Salesforce to Salesforce connection. Here's the catch: the Account has a Related record called Object1 and Object 1 has a related record called Object 2. I was able to forward the Account record along with its Object1 records but I can't get to include the Object2 records. How can this be done? Sample code anyone?

  • January 15, 2012
  • Like
  • 0

I have a class that is used for converting a Lead. I need to write a test class for this but I can't seem to get it. Please help. Here's the class:

 

Public Class CustomLeadCont
{
string pr;
private final lead l;
public CustomLeadCont(ApexPages.StandardController stdController) {
this.l = (Lead)stdController.getRecord();
}
public PageReference autoRun() {

String theId = ApexPages.currentPage().getParameters().get('id');

if (theId == null) {
// Display the Visualforce page's content if no Id is passed over
return null;
}
for (Lead l:[select id, name, Checkbox_1__c, Checkbox_2__c from Lead where id =:theId])
{
If (l.Checkbox_1__c & l.Checkbox_2__c)
{
Database.LeadConvert lc = new database.LeadConvert();
lc.setLeadId(l.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());
pr = lcr.getAccountId();
}
else{
pr = l.id;}
}
PageReference pageRef = new PageReference('/' + pr);
pageRef.setRedirect(true);
return pageRef;

}

}

----------------------------------------------------------------------------------------

Here's the Test Class:

 

@isTest
public class TestController{
static testMethod void TestControler()
{
Lead myLead = new Lead(LastName = 'Test', Company='Test Company', Checkbox_1__c = true, Checkbox_2__c=true);
insert myLead;
Apexpages.StandardController stdController = new Apexpages.StandardController(myLead);
CustomLeadCont cl= new CustomLeadCont(stdController);
cl.autoRun();
}
}

  • January 05, 2012
  • Like
  • 0
Good Morning,

I'm not a developer but I put together a trigger to update a checkbox field (Trigger_Email_on_Outstanding_Task__c) on the related Lead Object if the corresponding field on a Task (Trigger_email_on_Outstanding_Task__c) is checked (by a workflow):
____________________________________________________________________________________
trigger TriggerTaskNotification on Task (after insert, after update) {


    Set<Id> leadIds=new Set<Id>();

    for(Task t:trigger.new){
        if(t.Trigger_Email_on_Outstanding_Task__c==true){
            if(String.valueOf(t.whoId).startsWith('00Q')==TRUE){//check if the task is associated with a lead
              
              if( !leadIds.contains(t.whoid)){   //Dont forget '!'           
                                 leadIds.add(t.whoId);
                      }//if3
               
            }//if 2
        }//if 1
    }//for
   
    /* List<Lead> leadsToUpdate=[SELECT Id, Trigger_Email_on_Outstanding_Task__c FROM Lead WHERE Id IN :leadIds AND Trigger_Email_on_Outstanding_Task__c= True]; */

   Map<Id,Lead>  relatedleads = new Map<Id,Lead>([SELECT Id, Trigger_Email_on_Outstanding_Task__c FROM Lead WHERE Id IN :leadIds]);


   For(Task t2 : trigger.new){
            if(t2.Trigger_Email_on_Outstanding_Task__c==true){

                       if(relatedleads.get(t2.whoid) != null){  //if task is related to lead

                                     //make lead field to 'checked'
                                     relatedleads.get(t2.whoid).Trigger_Email_on_Outstanding_Task__c = true;
                        }//if2

           }//if1

}//for
 
    try{
        update relatedleads.values();
    }catch(DMLException e){
        system.debug('Leads were not all properly updated.  Error: '+e);
    }
}

______________________________________________________________________________

Looks like i'm receiving a System.NullPointerException: Attempt to de-reference a null object error, on execution of AfterUpdate
from line 8, column 1
if(String.valueOf(t.whoId).startsWith('00Q')==TRUE){//check if the task is associated with a lead

I'm assuming that it may be due to a task that doesn't have a related lead record but where the workflow has checked the checkbox on the task.  Is there a line I can omit or add that can account for these instances, where if there's a task with the checkbox checked but with no associated whoid then ignore....i'm assuming my trigger isn't very cleanly written since it's written by me. 

thanks everyone

Hi guys,

I tried following the email services sample code but I am running into a problem with the test class. For some reason it's giving me the error: Error: Compile Error: unexpected token: '=' at line 11 column 28

Here's the link to the sample email services: https://developer.salesforce.com/page/An_Introduction_To_Email_Services_on_Force.com 
  • April 22, 2014
  • Like
  • 0
Hey there,

I have a workflow rule which is designed to create a new task and assign it another user, then change the old task to 'failed to action'.

This workflow rule is emant to trigger when this occurs:

and( (Subject = 'Call Prospective Client'), ( Expiry_Test__c = now()), (ISPICKVAL(Status, 'Not Started')) )

It is howeer not working, is it possible to trigger a workflow in this way? Would it be better to do this via a trigger?

Thank you

I am in Windows 7 on a 64-bit laptop. When trying to install the Force.com IDE plugin from eclipse I got several messages that said,"MD5 hash not as expected. Expected...... and found......." Any Idea what that is about, or what to do about it?

 

Thanks,

Chuck

I hope somebody will be able to help me with this:

 

I have a trigger on Account that checks if the Account is created from a record forwarded by the partner using Salesforce to Salesforce. I am trying to create a test class for this but unfortunately, I don't think it's possible to create an account record on a test class and tell it that it came from a parter and not created locally. Any help?

  • January 19, 2012
  • Like
  • 0

Hi,

 

I am trying to automate the Account sharing on a Salesforce to Salesforce connection. Here's the catch: the Account has a Related record called Object1 and Object 1 has a related record called Object 2. I was able to forward the Account record along with its Object1 records but I can't get to include the Object2 records. How can this be done? Sample code anyone?

  • January 15, 2012
  • Like
  • 0

I have a class that is used for converting a Lead. I need to write a test class for this but I can't seem to get it. Please help. Here's the class:

 

Public Class CustomLeadCont
{
string pr;
private final lead l;
public CustomLeadCont(ApexPages.StandardController stdController) {
this.l = (Lead)stdController.getRecord();
}
public PageReference autoRun() {

String theId = ApexPages.currentPage().getParameters().get('id');

if (theId == null) {
// Display the Visualforce page's content if no Id is passed over
return null;
}
for (Lead l:[select id, name, Checkbox_1__c, Checkbox_2__c from Lead where id =:theId])
{
If (l.Checkbox_1__c & l.Checkbox_2__c)
{
Database.LeadConvert lc = new database.LeadConvert();
lc.setLeadId(l.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());
pr = lcr.getAccountId();
}
else{
pr = l.id;}
}
PageReference pageRef = new PageReference('/' + pr);
pageRef.setRedirect(true);
return pageRef;

}

}

----------------------------------------------------------------------------------------

Here's the Test Class:

 

@isTest
public class TestController{
static testMethod void TestControler()
{
Lead myLead = new Lead(LastName = 'Test', Company='Test Company', Checkbox_1__c = true, Checkbox_2__c=true);
insert myLead;
Apexpages.StandardController stdController = new Apexpages.StandardController(myLead);
CustomLeadCont cl= new CustomLeadCont(stdController);
cl.autoRun();
}
}

  • January 05, 2012
  • Like
  • 0