• jacoclocked
  • NEWBIE
  • 25 Points
  • Member since 2012

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 10
    Questions
  • 10
    Replies
I need to set a custom text field before a lead is converted to a value.  This is needed so that I can map the custom field that is being set to a custom field on the opportunity.   Any ideas?

My dev console is stuck in this wierd mode and I can't figure how to get out of it.  It's occurring on multiple machines and appears to be user related.

 

The developer console will load. I can open triggers, classes, etc. I even see the query editor and other tabs. In front of the bottom of the dev console is this frame.  It will accept commands but I have no idea how to remove this from the console.

 

devconsole$

 

 

Looking for the best/easiest way to perform the below whether it be trigger or using a junction object and leverage workflows. 

 

Object 1: Project

Object 2: Milestone

 

Relationship exists only through lookup field.  Creating a master detail is not possible between these two objects.   A given project can have many milestones.  

 

Each milestone has a field called 'Current Planned Hours' which is a numerical text field that requires manual entry.  I'd like to display 'Total Current Planned Hours' on the project record.  Whenever an update is made to the 'Current Planned Hours' on any milestone this amount is reflected on the 'Total Current Planned Hours' on the project form.  The 'Total Current Planned Hours' is the sum of all the milestone's 'Current Planned Hours'. What's the best way to accomplish this? 

 

Project - XYZ

Total Current Planned Hours =  40

 

Milestone 1 for Project XYZ

Current Planned Hours = 20

 

Milestone 2 for Project XYZ

Current Planned Hours = 20

 

Thanks!!!

Is it possible to use the Force.com IDE to perform workflow modifications?  Specifically, I have field that touches approximately 100 workflows/validations rules respectively and i'd like to swap out the current picklist field for a lookup field.   I'm trying to avoid having to go into each of my workflows and validations.  Any insight provided here would be more than helpful. Thanks in advance! 

 

 

Is there a way to query workflow rules for information?  Specifically, I want to see what recipiants are being sent emails for workflow rules.  If not, is there any 3rd party tools that can help? 

I have a VF page laid out as such: 1st column: checkboxes, 2nd column: Account Name, 3rd column: Contact Lookup field.

 

Checkbox |  Account Name |  Contact Lookup

                      Company A          Return Contacts From Company A

                      Company B          Return Contacts From Company B

                      Company C          Return Contacts From Company C

 

The problem I am trying to solve is for each line, I only want to return the contacts for the respective company. I.E. if I click on the lookup filter on the Company A line, I should only be returned the contacts for Company A.  If I click the lookup filter on the line for Company B, I should only be returned the contacts for Company B.  

 

Any help provided would be awesome!!! Thanks 

                      

 

 

I'm curious to know how some of the code in my organization is working and was deployed as the code coverage is less than 75% for many of the triggers/controllers.  

 

I see that the creation date for most of the code is 2011.  Is this a recent requirement Salesforce implemented? (i've only been working with SFDC for about 4 months).  I know if I deploy code with less then 75% coverage, the code will not deploy. 

 

It would make sense to me that SFDC implemented this requirement and allowed code in production to continue to run even though the coverage was less than 75% but going forward would force developers to meet the requirement.  Any insight that can be provided would be of great benefit to me. Thanks!!!

 

 

I need a bit of help writing my first test class.  Below is the code that i've modified for our environment.  I've also included the test case.   I've got my test class working now. I've pasted the updated class below.  I'm having a problem getting more than 71% code converage.  When I look at my code coverage in my trigger my test class doesn't cover the two lines below in bold.  Please advise in how I can ensure these lines are covered in my test case.  Thank you in advance for any help you can provide.   

 

closingprojects.add(p.id);

 

trigger.newmap.get( (id)ar.get('Id')).pse__Is_Active__c.adderror('This is a customer Project - You cannot set project to inactive until all Milestones are closed.');


How do I test these above lines in my test class?
----

The Trigger

 

// Looks at active projects and checks to see if any milestones are open
// If a milestone is open and a user tries to set a project to inactive then return a message to user


trigger OpenMilestoneTrigger on pse__Proj__c (before update) {


// Creates set of all active projects
set<id> closingprojects = new set<id>();
for(pse__Proj__c p:trigger.new)


// if(p.RecordTypeId == '012Z00000000JWKIA2'&&(p.pse__Stage__c=='Completed'&&trigger.oldmap.get(p.id).pse__Stage__c!='Completed'))
// sets the RecordTypeID for the Customer record

if(p.RecordTypeId == '012Z00000000JWKIA2'&&(p.pse__Is_Active__c == false && trigger.oldmap.get(p.id).pse__Is_Active__c == true))


// Adds active projects to the closingprojects set
closingprojects.add(p.id);


// Checks to see if there are any open milestones within the closing projects set
for(AggregateResult ar:[SELECT pse__Project__c Id,COUNT(Id) FROM pse__Milestone__c
WHERE pse__Project__c IN :closingprojects AND pse__Status__c != 'Approved' GROUP BY pse__Project__c])

// If there are open milestones then add them to the newmap and send error to user
trigger.newmap.get( (id)ar.get('Id')).pse__Stage__c.adderror('This is a customer Project - You cannot set project to inactive until all Milestones are closed.');


}

 

----

The Test Class

@isTest (seealldata=true)
private class OpenMilestoneTriggerTestClass {

private static testMethod void validateOpenMilestoneTriggerNegative() {

//setup variables to be used for building projects. Region and Record type are required
//It is important not to hardcode these values as the Id's will differ in production
RecordType rectype = [Select id from RecordType where Name = 'Customer'];
pse__Region__c regtype = [Select id from pse__Region__c where name = 'West' LIMIT 1];

//select pse__Billing_Type__c from pse__Proj__c where pse__Billing_Type__c = 'Time and Materials' limit 1
//Setup the Project Record
pse__Proj__c p = new pse__Proj__c();
p.RecordTypeId = rectype.id;
p.Name='TestProject';
p.pse__Region__c = regtype.id;
p.pse__Billing_Type__c = 'Hybrid';
p.pse__Is_Active__c = true;

insert p;

//Setup the Milestone Record
pse__Milestone__c m = new pse__Milestone__c();
m.Name = 'TestMileStone';
m.pse__Project__c = p.ID;
m.pse__Milestone_Amount__c = 0;
m.pse__Target_Date__c = Date.today();

insert m;

Test.startTest();

//Set the project status to inactive
try
{
p.pse__Is_Active__c = false;

}
Catch (System.DMLException e)
{
System.assert(e.getMessage().contains('Project cannot be closed with Open Milestones'));
}
Test.stopTest();
}
private static testMethod void validateOpenMilestoneTriggerPositive() {

RecordType rectype = [Select id from RecordType where Name = 'Customer'];
pse__Region__c regtype = [select id from pse__Region__c where name = 'West'];

//Setup the TestProject2 Record
pse__Proj__c p = new pse__Proj__c();
p.RecordTypeId = rectype.id;
p.Name='TestProject2';
p.pse__Region__c = regtype.id;
p.pse__Is_Active__c = true;
p.pse__Billing_Type__c = 'Time and Materials';

insert p;

//Setup the Milestone2 Record
pse__Milestone__c m = new pse__Milestone__c();
m.Name = 'TestMileStone2';
m.pse__Project__c = p.ID;
m.pse__Milestone_Amount__c = 0;
m.pse__Target_Date__c = Date.today();
m.pse__Actual_Date__c = Date.today();

insert m;

Test.startTest();
//Set the milestone status to approved and the project to inactive
try
{
m.pse__Status__c = 'Approved';
p.pse__Is_Active__c = false;
}
Catch (System.DMLException e)
{
System.assert(e.getMessage().contains('Project can be closed if there are no Open Milestones'));
}
Test.stopTest();
}

private static testMethod void validateOpenMilestoneTriggerClosingProjects() {

RecordType rectype = [Select id from RecordType where Name = 'Customer'];
pse__Region__c regtype = [select id from pse__Region__c where name = 'West'];

//Setup the Project Record
pse__Proj__c p = new pse__Proj__c();
p.RecordTypeId = rectype.id;
p.Name='TestProject3';
p.pse__Region__c = regtype.id;
p.pse__Is_Active__c = false;
p.pse__Billing_Type__c = 'Time and Materials';

pse__Milestone__c m1 = new pse__Milestone__c();
m1.Name = 'TestMileStone1';
m1.pse__Project__c = p.ID;
m1.pse__Milestone_Amount__c = 0;
m1.pse__Target_Date__c = Date.today();
m1.pse__Actual_Date__c = Date.today();

insert m1;

pse__Milestone__c m2 = new pse__Milestone__c();
m2.Name = 'TestMileStone2';
m2.pse__Project__c = p.ID;
m2.pse__Milestone_Amount__c = 0;
m2.pse__Target_Date__c = Date.today();
m2.pse__Actual_Date__c = Date.today();

insert m1;



set<id> closingprojects = new set<id>();


// for(AggregateResult ar:[SELECT pse__Project__c Id,COUNT(Id) FROM pse__Milestone__c
// WHERE pse__Project__c IN :closingprojects AND pse__Status__c != 'Approved' GROUP BY pse__Project__c])

// trigger.newmap.get( (id)ar.get('Id')).pse__Is_Active__c.adderror('This is a customer project with a billing type of time and materials - You cannot set project to inactive until all milestones are closed.');


Test.StartTest();
Try
{
if(p.RecordTypeId == rectype.id &&(p.pse__Is_Active__c == false))
closingprojects.add(p.id);
}
Catch (System.DMLException e)
{
System.assertEquals(closingprojects.size(),1);
}
Test.StopTest();

}
}

I'm receiving a query exception for the highlighted lines in red.  When I run the test, it says my list has no rows.  When I run the select query in the developer console i'm returning the correct value without a problem.  You'll also note that in the RecordType line i'm performing the same logic with similar assignment.  I'm not having any issues with this line so i'd expect that region should function exactly the same.   Please note that pse__region__c is a lookup field though i wouldnt think this could be the problem if the SOQL query is returning the correct result in the developer console. Also, If I hardcode the id value of 'west', the test class will work fine.  Obviously, you don't want to do this.  Any help offered would be much obliged. #noob

 

//setup variables to be used for building projects. Region and Record type are required
//It is important not to hardcode these values as the Id's will differ in production


RecordType rectype = [Select id from RecordType where Name = 'Customer'];
pse__Region__c regtype = [select id from pse__Region__c where name = 'West' LIMIT 1];

//Setup the Project Record
pse__Proj__c p = new pse__Proj__c();
p.RecordTypeId = rectype.id;
p.Name='TestProject';
p.pse__Region__c == regtype.id;
p.pse__Is_Active__c = true;

insert p;

I have a project object and a related task object.  A Project can have N number of tasks.  

 

Rule: Do not allow the closure of a project if it has open tasks.  

 

This should be super simple but Salesforce makes this extremely difficult to accomplish without solid knowledge of Apex programming.  Any help provided would be much appreciated. 

 

*Note* I do not have the luxury of a master-detail relationship in this situation *Note* 

 

 

 

My dev console is stuck in this wierd mode and I can't figure how to get out of it.  It's occurring on multiple machines and appears to be user related.

 

The developer console will load. I can open triggers, classes, etc. I even see the query editor and other tabs. In front of the bottom of the dev console is this frame.  It will accept commands but I have no idea how to remove this from the console.

 

devconsole$

 

 

Looking for the best/easiest way to perform the below whether it be trigger or using a junction object and leverage workflows. 

 

Object 1: Project

Object 2: Milestone

 

Relationship exists only through lookup field.  Creating a master detail is not possible between these two objects.   A given project can have many milestones.  

 

Each milestone has a field called 'Current Planned Hours' which is a numerical text field that requires manual entry.  I'd like to display 'Total Current Planned Hours' on the project record.  Whenever an update is made to the 'Current Planned Hours' on any milestone this amount is reflected on the 'Total Current Planned Hours' on the project form.  The 'Total Current Planned Hours' is the sum of all the milestone's 'Current Planned Hours'. What's the best way to accomplish this? 

 

Project - XYZ

Total Current Planned Hours =  40

 

Milestone 1 for Project XYZ

Current Planned Hours = 20

 

Milestone 2 for Project XYZ

Current Planned Hours = 20

 

Thanks!!!

Is it possible to use the Force.com IDE to perform workflow modifications?  Specifically, I have field that touches approximately 100 workflows/validations rules respectively and i'd like to swap out the current picklist field for a lookup field.   I'm trying to avoid having to go into each of my workflows and validations.  Any insight provided here would be more than helpful. Thanks in advance! 

 

 

I have a VF page laid out as such: 1st column: checkboxes, 2nd column: Account Name, 3rd column: Contact Lookup field.

 

Checkbox |  Account Name |  Contact Lookup

                      Company A          Return Contacts From Company A

                      Company B          Return Contacts From Company B

                      Company C          Return Contacts From Company C

 

The problem I am trying to solve is for each line, I only want to return the contacts for the respective company. I.E. if I click on the lookup filter on the Company A line, I should only be returned the contacts for Company A.  If I click the lookup filter on the line for Company B, I should only be returned the contacts for Company B.  

 

Any help provided would be awesome!!! Thanks 

                      

 

 

I need a bit of help writing my first test class.  Below is the code that i've modified for our environment.  I've also included the test case.   I've got my test class working now. I've pasted the updated class below.  I'm having a problem getting more than 71% code converage.  When I look at my code coverage in my trigger my test class doesn't cover the two lines below in bold.  Please advise in how I can ensure these lines are covered in my test case.  Thank you in advance for any help you can provide.   

 

closingprojects.add(p.id);

 

trigger.newmap.get( (id)ar.get('Id')).pse__Is_Active__c.adderror('This is a customer Project - You cannot set project to inactive until all Milestones are closed.');


How do I test these above lines in my test class?
----

The Trigger

 

// Looks at active projects and checks to see if any milestones are open
// If a milestone is open and a user tries to set a project to inactive then return a message to user


trigger OpenMilestoneTrigger on pse__Proj__c (before update) {


// Creates set of all active projects
set<id> closingprojects = new set<id>();
for(pse__Proj__c p:trigger.new)


// if(p.RecordTypeId == '012Z00000000JWKIA2'&&(p.pse__Stage__c=='Completed'&&trigger.oldmap.get(p.id).pse__Stage__c!='Completed'))
// sets the RecordTypeID for the Customer record

if(p.RecordTypeId == '012Z00000000JWKIA2'&&(p.pse__Is_Active__c == false && trigger.oldmap.get(p.id).pse__Is_Active__c == true))


// Adds active projects to the closingprojects set
closingprojects.add(p.id);


// Checks to see if there are any open milestones within the closing projects set
for(AggregateResult ar:[SELECT pse__Project__c Id,COUNT(Id) FROM pse__Milestone__c
WHERE pse__Project__c IN :closingprojects AND pse__Status__c != 'Approved' GROUP BY pse__Project__c])

// If there are open milestones then add them to the newmap and send error to user
trigger.newmap.get( (id)ar.get('Id')).pse__Stage__c.adderror('This is a customer Project - You cannot set project to inactive until all Milestones are closed.');


}

 

----

The Test Class

@isTest (seealldata=true)
private class OpenMilestoneTriggerTestClass {

private static testMethod void validateOpenMilestoneTriggerNegative() {

//setup variables to be used for building projects. Region and Record type are required
//It is important not to hardcode these values as the Id's will differ in production
RecordType rectype = [Select id from RecordType where Name = 'Customer'];
pse__Region__c regtype = [Select id from pse__Region__c where name = 'West' LIMIT 1];

//select pse__Billing_Type__c from pse__Proj__c where pse__Billing_Type__c = 'Time and Materials' limit 1
//Setup the Project Record
pse__Proj__c p = new pse__Proj__c();
p.RecordTypeId = rectype.id;
p.Name='TestProject';
p.pse__Region__c = regtype.id;
p.pse__Billing_Type__c = 'Hybrid';
p.pse__Is_Active__c = true;

insert p;

//Setup the Milestone Record
pse__Milestone__c m = new pse__Milestone__c();
m.Name = 'TestMileStone';
m.pse__Project__c = p.ID;
m.pse__Milestone_Amount__c = 0;
m.pse__Target_Date__c = Date.today();

insert m;

Test.startTest();

//Set the project status to inactive
try
{
p.pse__Is_Active__c = false;

}
Catch (System.DMLException e)
{
System.assert(e.getMessage().contains('Project cannot be closed with Open Milestones'));
}
Test.stopTest();
}
private static testMethod void validateOpenMilestoneTriggerPositive() {

RecordType rectype = [Select id from RecordType where Name = 'Customer'];
pse__Region__c regtype = [select id from pse__Region__c where name = 'West'];

//Setup the TestProject2 Record
pse__Proj__c p = new pse__Proj__c();
p.RecordTypeId = rectype.id;
p.Name='TestProject2';
p.pse__Region__c = regtype.id;
p.pse__Is_Active__c = true;
p.pse__Billing_Type__c = 'Time and Materials';

insert p;

//Setup the Milestone2 Record
pse__Milestone__c m = new pse__Milestone__c();
m.Name = 'TestMileStone2';
m.pse__Project__c = p.ID;
m.pse__Milestone_Amount__c = 0;
m.pse__Target_Date__c = Date.today();
m.pse__Actual_Date__c = Date.today();

insert m;

Test.startTest();
//Set the milestone status to approved and the project to inactive
try
{
m.pse__Status__c = 'Approved';
p.pse__Is_Active__c = false;
}
Catch (System.DMLException e)
{
System.assert(e.getMessage().contains('Project can be closed if there are no Open Milestones'));
}
Test.stopTest();
}

private static testMethod void validateOpenMilestoneTriggerClosingProjects() {

RecordType rectype = [Select id from RecordType where Name = 'Customer'];
pse__Region__c regtype = [select id from pse__Region__c where name = 'West'];

//Setup the Project Record
pse__Proj__c p = new pse__Proj__c();
p.RecordTypeId = rectype.id;
p.Name='TestProject3';
p.pse__Region__c = regtype.id;
p.pse__Is_Active__c = false;
p.pse__Billing_Type__c = 'Time and Materials';

pse__Milestone__c m1 = new pse__Milestone__c();
m1.Name = 'TestMileStone1';
m1.pse__Project__c = p.ID;
m1.pse__Milestone_Amount__c = 0;
m1.pse__Target_Date__c = Date.today();
m1.pse__Actual_Date__c = Date.today();

insert m1;

pse__Milestone__c m2 = new pse__Milestone__c();
m2.Name = 'TestMileStone2';
m2.pse__Project__c = p.ID;
m2.pse__Milestone_Amount__c = 0;
m2.pse__Target_Date__c = Date.today();
m2.pse__Actual_Date__c = Date.today();

insert m1;



set<id> closingprojects = new set<id>();


// for(AggregateResult ar:[SELECT pse__Project__c Id,COUNT(Id) FROM pse__Milestone__c
// WHERE pse__Project__c IN :closingprojects AND pse__Status__c != 'Approved' GROUP BY pse__Project__c])

// trigger.newmap.get( (id)ar.get('Id')).pse__Is_Active__c.adderror('This is a customer project with a billing type of time and materials - You cannot set project to inactive until all milestones are closed.');


Test.StartTest();
Try
{
if(p.RecordTypeId == rectype.id &&(p.pse__Is_Active__c == false))
closingprojects.add(p.id);
}
Catch (System.DMLException e)
{
System.assertEquals(closingprojects.size(),1);
}
Test.StopTest();

}
}

I'm receiving a query exception for the highlighted lines in red.  When I run the test, it says my list has no rows.  When I run the select query in the developer console i'm returning the correct value without a problem.  You'll also note that in the RecordType line i'm performing the same logic with similar assignment.  I'm not having any issues with this line so i'd expect that region should function exactly the same.   Please note that pse__region__c is a lookup field though i wouldnt think this could be the problem if the SOQL query is returning the correct result in the developer console. Also, If I hardcode the id value of 'west', the test class will work fine.  Obviously, you don't want to do this.  Any help offered would be much obliged. #noob

 

//setup variables to be used for building projects. Region and Record type are required
//It is important not to hardcode these values as the Id's will differ in production


RecordType rectype = [Select id from RecordType where Name = 'Customer'];
pse__Region__c regtype = [select id from pse__Region__c where name = 'West' LIMIT 1];

//Setup the Project Record
pse__Proj__c p = new pse__Proj__c();
p.RecordTypeId = rectype.id;
p.Name='TestProject';
p.pse__Region__c == regtype.id;
p.pse__Is_Active__c = true;

insert p;

I have a project object and a related task object.  A Project can have N number of tasks.  

 

Rule: Do not allow the closure of a project if it has open tasks.  

 

This should be super simple but Salesforce makes this extremely difficult to accomplish without solid knowledge of Apex programming.  Any help provided would be much appreciated. 

 

*Note* I do not have the luxury of a master-detail relationship in this situation *Note* 

 

 

 

I have created a custom object which is going to be used for an internal support team.

 

Users will be entering in comments into the 'Comments' field that need to be date/time stamped and retained (nobody except sysadmin can edit once saved).

 

Only solution I can think of (but do not know how to accomplish):

There is a long text area field that comments will be entered.  When the record is saved, I would like to cut the text in this field and append it into another long text area field with a date/time stamp at the beginning of the line.  I can then make this field read-only to everybody but the sysadmin profile.

 

Help would be greatly appreciated!