+ Start a Discussion
iswarya sekar 7iswarya sekar 7 

How to update a boolean and decimal fields using Map

public class updateNameClass{
   // public String updateValue{get;set;}
    public updateNameClass(ApexPages.Standardcontroller controller){
    public PageReference gotostep2(){
        PageReference pref2=New PageReference('/apex/step2page');
        return pref2;
    public List<Opportunity>optyList{set;get;}
    public  Map<String, String>labelToAPIName {set;get;}
    public String fldValue {set;get;}
    public List<Opportunity>optyUpdate{set;get;}
    public updateNameClass(ApexPages.StandardSetcontroller controller){
        this.optyList=(List<Opportunity>)Controller.getRecords() ;
        labelToAPIName = new Map <String, String> ();
        Map<String, Schema.SObjectField>fieldsMap = Schema.SObjectType.Opportunity.fields.getMap();
        for (Schema.SObjectField field :fieldsMap.values())
          //  System.debug('label'+field.getDescribe().getLabel()+'*********Api**********'+field.getDescribe().getName());
            labelToAPIName.put(field.getDescribe().getLabel(), field.getDescribe().getName());
    public pageReference updateMethod(){
        optyUpdate=new List<opportunity>();
        String fld = System.currentPageReference().getParameters().get('fieldName');
            String apiFld=labelToAPIName.get(fld);
            for(opportunity op:optyList){
                Map<String, Object>fieldValueMap = new Map<String, Object>();
                fieldValueMap.put(apiFld,fldValue );
        PageReference pref2=New PageReference('/apex/oppupdatepage');
        return pref2;

when i give a new value for a field it should be updated in all records(Mass update records from list view). its updating for string fields but not for other fields like date, boolean, decimal etc. Can anyone help me on this? Thanks in Advance!
iswarya sekar 7iswarya sekar 7
Anyone help me on this?
Paul S.Paul S.
The variable fldValue is a string, which is why only string-based fields are being updated.
iswarya sekar 7iswarya sekar 7
Hi @Paul S.  How can i change this so that i can update all datatypes