You need to sign in to do that
Don't have an account?
Neil Hatch 9
replace string in Apex Class
Hi,
I've inherited an app that has very little apex code. However, the one bit of reusable code we have now needs modifying and I'm struggling to make the right change. This line is now causing an issue as a number of new fields are already reference fields and results in the class failing and stopping the process that runs it! Is there a simple change to this line that will replace any __[rc] with __r? This will capture those that need changing "c" and those that are actually already correct "r"?
I've inherited an app that has very little apex code. However, the one bit of reusable code we have now needs modifying and I'm struggling to make the right change. This line is now causing an issue as a number of new fields are already reference fields and results in the class failing and stopping the process that runs it! Is there a simple change to this line that will replace any __[rc] with __r? This will capture those that need changing "c" and those that are actually already correct "r"?
activeFieldName = userFieldName.replace('__c', '__r.IsActive');
Please try this.