You need to sign in to do that
Don't have an account?
GetFieldValue(FieldName) ?
I am struggling with logging the input that come in via a webservice call. The method is something like this
webservice boolean runTransaction(Account wAccount){
logAccount(wAccount);
processAccount();
}
with logAccount(Account lAccount) being something like this:
String strAccount = "Incoming Account Transaction\n";
strAccount = strAccount + "FieldName1" + lAccount.fieldName1 + "\n";
strAccount = strAccount + "FieldName2" + lAccount.fieldName2 + "\n";
...
strAccount = strAccount + "FieldNameN" + lAccount.fieldNameN + "\n";
logAccountValues(strAccount);
where logAccountValues creates a record in a custom object and records the values. The problem with this approach is that our schema is very dynamic and extensive. We have 200 fields in our object, and its a pain to keep them all in synch. We want to make it more dynamic, by leveraging the schema definition. Given a field name, how do I find the value? I am looking for something like this:
String fieldValue = Account.getFieldValue(fieldName);
Its impractical to query the database because we don't want to log what is stored in the database, but rather what are the values in the incoming webservice calls. Any help/pointers appreciated.
Check this out. You can call methods like
Object val = Account.get("fieldName") ;
To set the value you can use
CustomObject.put(customObjFieldName, account.get(accountfieldName));
For more details check these apex docs.
http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_methods_system_sobject.htm