function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
dmedme 

INVALID_FIELD_FOR_INSERT_UPDATE error

Using flex and apex for my app developement. When tried to update an custom object getting the following error. Below displayed my code snippets. can any one help me.

 
          [0] (com.salesforce.results::Error)#5
            fields = "Name"
            message = "Unable to create/update fields: Name. Please check the security settings of this field and verify that it is read/write for your profile."
            statusCode = "INVALID_FIELD_FOR_INSERT_UPDATE"
            StatusCode = 0
        uid = "4DEF471D-F08C-791A-FE1A-9928F5BF03A4"

 

var a:Array = [];
for( var i:int = 0; i < updateList.length; i++ )
{
var tempVO:DataVO = dmeModel.acExpensesToAssign.getItemAt(i) as DataVO;

var o:Object = tempVO.toObject();
var so:SObject = new SObject(o);
a.push( so );
}
apex.update(a,new AsyncResponder(handleSaveAllResult,handleFault) );

 

 

public function toObject():Object
{
var o:Object = {};

o.ExpenseName__c = this.Name;
o.UserName__c = this.UserName;

if(this.Id) o.Id = this.Id;
if(this.ExpenseId)o.Name = this.ExpenseId;

o.Amount__c = this.Amount;

if( this.Incurred )
o.IncurredDate__c = Util.dateToString(this.Incurred);
if( this.Submitted )
o.SubmittedDate__c = Util.dateToString(this.Submitted);

o.ExpenseReport__c = this.ExpenseReport;
o.Project__c = this.Project;
o.Type__c = this.ExpenseType;
o.Category__c = this.Category;
o.type = this.type;

return o;
}

 

 

 

Thanks

dme


  

 

dmedme

worked fine after commenting teh following line in toObject method

 

if(this.ExpenseId)o.Name = this.ExpenseId;

 

the mistake is i tried to update the name(standard field)  in custom object. Can't it be updated?

 

regards

dme

SuperfellSuperfell
Would depend on how you've configured your custom object.