You need to sign in to do that
Don't have an account?
Prady01
Test class on content object for trigger based on contentversion
Hello People, Thanks in advance for any help i could get... I am writing a test class for a trigger on content object and when i insert a new record on content version and then try to set the custom field on that object but i get an error saying FIELD_INTEGRITY_EXCEPTION, You cannot set custom fields or tags on a document published into a personal library. Fields set: Opportunity: [], plz any help would be greatly appreciated, thanks...
@istest private class ProjectName_test { static testMethod void testProjectName(){ Employee__c e1 = new Employee__c(First_Name__c = 'test11', Last_Name__c = 'test11', Start_Date__c = Date.valueOf('2009-10-05')); insert e1; Profile p = [select id from profile where name='System Administrator']; User u = new User(alias = 'standt', email='standarduser1@testorg.com', emailencodingkey='UTF-8', lastname='Testing', languagelocalekey='en_US', localesidkey='en_US', profileid = p.Id,SFDC_EmployeeId__c = e1.id, timezonesidkey='America/Los_Angeles', username='standarduser1@testorg.com'); account a = new account(); a.name='Test name'; insert a; Project__c dp = new Project__c(); insert dp; Opportunity op = new Opportunity(); op.Accountid = a.id; op.Name = 'Swarm Test Opp'; op.StageName = 'Different Stage'; op.CloseDate = Date.newInstance(2010, 03, 26); op.Amount = 555; op.Project__c = dp.id; insert op; ContentVersion cv = new ContentVersion(); //cv.FirstPublishLocationId='068Q00000006bsz'; cv.title='Test title'; cv.VersionData=blob.valueof('New Bitmap Image.bmp'); cv.Account__c = a.id; cv.Opportunity__c=op.id; // cv.RecordtypeId='012400000009Bj8AAE'; // cv.RecordtypeId='058400000004CY3';//sales documents record type id // cv.RecordtypeId ='00h40000000zGVa'; insert cv; ContentVersion cov = [select id,Project__c,Opportunity__c,RecordTypeId from ContentVersion where id=:cv.id]; cov.Opportunity__c = op.id; update cov; system.assertequals(cov.DreamTeam_Project__c,op.DreamTeam_Project__c); } }
This will help anyone if they having probles with content object... All thanks to EchoEcho