You need to sign in to do that
Don't have an account?
Shaijan Thomas
Class variable are not able to access dynamically1
Hi All,
I am trying to access the class varible dynamically for one of my requirment. Please see the code.
public class CaseUpdateTestingClass {
public string AssetSN = '1AED45';
public string CDIDId='3498474';
public string ContactFirstName='SalesForce';
}
CaseUpdateTestingClass es = new CaseUpdateTestingClass();
string ss = 'AssetSN;CDIDId;ContactFirstName'; // Here I do dynamic assignment
for ( string a : ss.split(';'))
system.debug('*********** : '+es.get(a));
Thanks
Shaijan Thomas
I am trying to access the class varible dynamically for one of my requirment. Please see the code.
public class CaseUpdateTestingClass {
public string AssetSN = '1AED45';
public string CDIDId='3498474';
public string ContactFirstName='SalesForce';
}
CaseUpdateTestingClass es = new CaseUpdateTestingClass();
string ss = 'AssetSN;CDIDId;ContactFirstName'; // Here I do dynamic assignment
for ( string a : ss.split(';'))
system.debug('*********** : '+es.get(a));
Thanks
Shaijan Thomas
In your code AssetSN, CDIDId, ContactFirstName are member variable. We should always refer them with the object you have created. Consider following code:
This worked with me. I hope this helps.
Regards,
Sandeep Mishra
Try this bunch of code.
please let me know if this will help.
Thanks,
Keyur Modi
string ss = 'AssetSN;CDIDId;ContactFirstName'; This is an example,
Suppose I have 100 value and store in custom setting or label, i can access it easily
string ss = 'v1, v2......v100';
Thanks
Shaijan Thomas
try this way.
public class CaseUpdateTestingClass {
public string AssetSN = '1AED45';
public string CDIDId='3498474';
public string ContactFirstName='SalesForce';
}
string fieldvalue='';
CaseUpdateTestingClass es = new CaseUpdateTestingClass();
String serialized = JSON.serialize(es );
Map<String, Object> parameters = new Map<String, Object>();
parameters = (Map<String, Object>) JSON.deserializeUntyped(serialized);
fieldvalue=parameters.get( 'AssetSN ');