We have a managed package installed in about 1800 different orgs and, as such, there are multiple versions of the managed package out there. I'm trying to write an unmanaged package that will interact with those different versions. Doing so is giving me a "Variable does not exist" error due to a field not existing in the older version that does in the newer version. I've written a check to see if the field exists and put the variable inside an if statement but that doesn't resolve the error.
So I have
sObjTemplate = new nihrm__DocumentTemplate__c();
merge2 = doesFieldExist ('nihrm__DocumentTemplate__c','mycustomfield__c');
if(merge2){sObjTemplate.mycustomfield__c = merge2Sel;}
My development environment is running the lowest version so mycustomfield__c doesn't exist and, as such, throws the "Variable does not exist" error. Is there a way around this? Or do I have to have multiple dev orgs at multiple versions of the managed package and create multiple unmanaged packages for them?
I'm hoping I've written this in a way that makes sense. Basically I'm looking for something similar to a conditional compile so I can get this code to work on multiple versions.