You need to sign in to do that
Don't have an account?
Semira@gmail.com
System.AssertException: Assertion Failed:
Hi I wrote an apex extension class to auto assign the record type looking at a parent record. However I'm getting Null value on assertion. Can someone please help me? I have been wrecking my brain and can't figure it out.
//I'm inserting the parent - testJobObj insert testJobObj; ID jobId = testJobObj.Id; //System.currentPageReference().getParameters().put('retURL', jobId); Work_order__c order = new Work_Order__c(Job_Number__c = testJobObj.id); insert order; ApexPages.StandardController sc = new ApexPages.standardController(order); WorkOrderRedirectExtension test = new WorkOrderRedirectExtension(sc); System.currentPageReference().getParameters().put('retURL','/'+ jobId); pageReference pr = test.redirect(); System.assertEquals(system.currentPageReference().getParameters().get('RecordType'), '012Q00000000kxB' ); } }Then here's my apex extension method:
public PageReference redirect(){ Id parentId = ApexPages.currentPage().getParameters().get('retURL').substring(1,16); system.debug('This is the parent Id Im recieving' + parentId); String param = ''; List<job__c> job = [select id, division__c from Job__c where id =: ParentId limit 10]; for(job__c j: job){ if(j.Division__c == 'Contents'){ param = getParameters()+'&RecordType=012Q00000000kxB'; System.debug('This is the job division' + j.Division__c); } else if(j.Division__c == 'Structure'){ param = getParameters()+'&RecordType=012Q00000000l42'; System.debug('This is the job division' + j.Division__c); } else param = getParameters()+'&RecordType=012Q00000000kxG'; } system.debug('RecordType' + param); String prefix = Work_Order__c.SObjectType.getDescribe().getKeyPrefix(); Pagereference page = new PageReference('/'+prefix+'/e?nooverride=1&'+param); Page.setRedirect(true); return page; }
Where are you setting record type value in your code.
I'm setting this inside the redirect method but this is where I'm getting my param.