You need to sign in to do that
Don't have an account?
Eric Dale 11
Field is null after insert in test
I have a test class which creates an object which includes this field "APXT_CongaSign__ContentDocumentId__c"... this is simply a text field. I then insert the object.
When I do a SOQL query on it, all other field seem to be fine except for this one, which does not show a value.
Here is the test class;
When I do a SOQL query on it, all other field seem to be fine except for this one, which does not show a value.
Here is the test class;
@isTest public static void TestBatterySignatureComplete(){ //Creating the account Account account = new Account(); account.Name = 'Test Account'; account.SGNS_Contractor_Primary_Email__c = 'test.test@test.ca'; account.SGNS_Contractor_Secondary_Email__c = 'test.test@test.ca'; insert account; //Creating Battery Battery_Energy_Storage_Applications__c batteryApplication = new Battery_Energy_Storage_Applications__c(); batteryApplication.Contractor__r = account; batteryApplication.Contractor__c = account.Id; batteryApplication.First_Name__c = 'test'; batteryApplication.Last_Name__c = 'test'; batteryApplication.Email__c = 'test.test@test.ca'; batteryApplication.Stage__c = 'Application Submitted'; insert batteryApplication; //create attachment ContentVersion contentVersion = new ContentVersion( Title = 'Battery Storage Program Participation Agreement', PathOnClient = 'sign.pdf', VersionData = Blob.valueOf('Test Content'), IsMajorVersion = true); insert contentVersion; List<ContentDocument> documents = [SELECT Id, Title, LatestPublishedVersionId FROM ContentDocument]; //create ContentDocumentLink record ContentDocumentLink cdl = new ContentDocumentLink(); cdl.LinkedEntityId = batteryApplication.Id; cdl.ContentDocumentId = documents[0].Id; cdl.ShareType = 'V'; cdl.Visibility = 'AllUsers'; insert cdl; //Creating the Conga Transaction record APXT_CongaSign__Transaction__c congaTransaction = new APXT_CongaSign__Transaction__c(); //of these variables are null, the Flow will fail. congaTransaction.Parent_a0l__c = batteryApplication.Id; congaTransaction.Parent_a0l__r = batteryApplication; congaTransaction.APXT_CongaSign__ContentDocumentId__c = documents[0].Id; insert congaTransaction; //AFTER THIS POINT APXT_CongaSign__ContentDocumentId__c APPEARS NULL AFTER A SOQL QUERY OF THE RECORD. //TEST STARTS CongaTransaction.APXT_CongaSign__Status__c = 'COMPLETE'; update CongaTransaction; List<Battery_Energy_Storage_Applications__c> updatedBatts = [SELECT Id, Stage__c from Battery_Energy_Storage_Applications__c WHERE Id = :batteryApplication.Id]; Integer invocations = Limits.getEmailInvocations(); System.assertEquals('Installation', updatedBatts[0].Stage__c); System.assertEquals(1, invocations, 'An email has been sent'); System.assertEquals(documents.size(), 1); }
after that APXT_CongaSign__Transaction__c.APXT_CongaSign__OriginalDocumentId__c is filled automatically with the ContentDocument.Id value.