function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
CarlBCarlB 

System.UnexpectedException: Illegal arguments

Hello.

I am getting the above error in my code.  However, the code used to work, so I am wondering if Salesforce have changed something recently.

My code is in a Visualforce controller extension:

abstract global with sharing class BaseExtension {
	
	protected SObject m_Object;
	
	public BaseExtension (ApexPages.StandardController p_Controller) {
    	
		m_Object = p_Controller.getRecord();
		if (m_Object!=null) {
			recordTypeId = (String)m_Object.get('RecordTypeId');
		}
	}
}
Now, field 'RecordTypeId' does exist in the object in question.

I think the problem is that this controller is defined in a managed package which I have installed in another org and then I try to use the controller on an object that was defined in this other org.

However, I can't see why this should be an issue.

Any thoughts?

Carl
Valerijs ProkudinsValerijs Prokudins
Hi,
which line generates this error?
CarlBCarlB


recordTypeId = (String)m_Object.get('RecordTypeId');

throws the error.

Carl
Valerijs ProkudinsValerijs Prokudins
sorry, nothing from me.
The class is giving you error in both orgs? or only in one?
CarlBCarlB
It is rather strange.  I declare the class in org A and created a managed package.  I install that managed package in org B.  When I run the code in org B I get the error.

However, if I create a managed package in org B (containing the new object) and install both managed packages into org C and run the same code, I don't get an error.

It seems to be that the error occurs when you run the code in the same namespace as where the object is declared.

Carl
Dimitri SulsDimitri Suls
Hi CarlB,

I have the same issue.
Were you able to resolve it?

I have an Extension in OrgA, and an object in OrgB.
When executing the Extension in OrgB I get this error.

Both org's are a managed package.
Dimitri SulsDimitri Suls
Hi CarlB,

I was able to fix this by re-instantiating the controller:

public ParticipantNewAndEditExtension(ApexPages.StandardController controller)
{
    super(new ApexPages.StandardController(controller.getRecord()));
}