You need to sign in to do that
Don't have an account?

assigning values dynamically.
I need to know if I can do this in salesforce
Create a map in the following way:
key--> api name of a field on account
value--> a number.
Then assign map.get('key')=='another number';(Assume this stmt as assigning some value to a field on account)
Then call update account.
Any help is much appreciated.
Hi,
You can create a map like that, but if you do this,
map.get('key')='another number';
you will get an error (Expression cannot be assigned)
Instead you do like this, map.put(key, newnumber)
and when you dml on account,
Account acc = new Account();
acc.NumberOfEmployees = map.get(key); //work fine because its datatype is number i.e map returns integer
acc.Description = map.get(key); // throws error. its is a LongTextArea
If you are actually trying to set values on an sObject, you don't need a map. You can put the value onto the object.
But you must be careful with the value, and use putSobject for references.