Discussions
- General Development
- Schema Development
- Apex Code Development
- Visualforce Development
- Formulas & Validation Rules
- Security
- Mobile
- Force.com Sites & Site.com
- Chatter Development
- Java Development
- .NET Development
- Perl, PHP, Python & Ruby
- Desktop Integration
- APIs and Integrations
- Visual Workflow
- Apple, Mac and OS X
- VB and Office Development
- AppExchange Directory & Packaging
- Salesforce Labs & Open Source Projects
- Other Salesforce Applications
- Jobs Board
- Force.com Discussion Boards
- :
- Developer Boards for Force.com and Database.com
- :
- Apex Code Development
- :
- I need a second pair of eyes (Code Covered: 0%)
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
I need a second pair of eyes (Code Covered: 0%)
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
12-31-2012 10:51 AM
This is on the sandbox and I can't figure out why this trigger test isn't firing. All system debug get hit and have the correct data, System.debug('@@@ trgInsertNote');
trigger trgInsertNote on Note (after insert) {
System.debug('@@@ trgInsertNote');
BMCServiceDesk__Incident__c toUpdate = new BMCServiceDesk__Incident__c();
for(Note n : Trigger.New){
String nName = n.ParentId;
String iName = Schema.getGlobalDescribe().get('BMCServiceDesk__In cident__c').getDescribe().getKeyPrefix();
if ( nName.startsWith(iName) && !n.IsPrivate ) {
toUpdate = [SELECT X3Ci_Last_Note__c FROM BMCServiceDesk__Incident__c WHERE Id = :nName][0];
if ( n.Body == '' || n.body == null )
toUpdate.X3Ci_Last_Note__c = n.Title;
else
toUpdate.X3Ci_Last_Note__c = n.Title + ': ' + n.Body;
}
}
if ( toUpdate != null)
update toUpdate;
}
@isTest(SeeAllData=true)
public with sharing class TestTrgInsertNote{
private static TestMethod void testInsertNoteMethod(){
Profile cvProfile = [select id from profile where name = 'Standard User' limit 1];
User usrCV = new User();
usrCV.LastName='Test Client Value';
usrCV.Username='dsfg@gmail.com23453245';
usrCV.Alias='tesy07';
usrCV.Email='sdfg@sdfg.com';
usrCV.CommunityNickname='Test CV Contact';
usrCV.TimeZoneSidKey='America/Los_Angeles';
usrCV.localesidkey='en_US';
usrCV.EmailEncodingKey='ISO-8859-1';
usrCV.LanguageLocaleKey ='en_US';
usrCV.ProfileId=cvProfile.id;
usrCV.IsActive = true;
Insert usrCV;
System.debug('@@@ TestTrgInsertNote.usrCV: ' + usrCV);
BMCServiceDesk__Incident__c testIncident = new BMCServiceDesk__Incident__c();
testIncident.Subject__c = 'Test Incident';
testIncident.BMCServiceDesk__FKClient__c = usrCV.Id;
insert testIncident;
System.debug('@@@ TestTrgInsertNote.testIncident: ' + testIncident);
Note newNote = new Note(Title='Test title', Body='Test body', ParentId = testIncident.Id, IsPrivate = false);
System.debug('@@@ TestTrgInsertNote.newNote: ' + newNote);
}
}
Solved! Go to Solution.
Re: I need a second pair of eyes (Code Covered: 0%)
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
12-31-2012 11:12 AM
What is this trigger supposed to do, exactly?
Certified Salesforce Developer
Re: I need a second pair of eyes (Code Covered: 0%)
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
12-31-2012 11:13 AM
Hello,
Your trigger fires after insert, so you need to add that to your test:
Test.startTest(); insert newNote; Test.stopTest();
You are just instantiating a Note object, but not inserting(commiting) it to the db.
Happy New Year!
Re: I need a second pair of eyes (Code Covered: 0%)
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
12-31-2012 12:25 PM
Thanks Adrian, that was it. Happy new year to you too, you made mine!
@SFAdmin5, the trigger copies the latest Note to a field to an object so users can include it in their reports. You can't use reports, workflows, etc. on note and attachments otherwise.

