• p_bhat
  • NEWBIE
  • 0 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 1
    Replies
When i try to execute below code snippet, Ideally only my 1st element in the list should get failed as I am trying to set quantity field to 0 and rest of records should get saved to Database successfully. But all the records are getting failed.

List<OpportunityLineItem> lstOLI  = [SELECT Id,Quantity FROM OpportunityLineItem LIMIT 10];
lstOLI[0].Quantity = 0;
List<Database.SaveResult> resultSet = Database.update(lstOLI,false);
system.debug('---resultSet-- '+resultSet);

Output -
USER_DEBUG [4]|DEBUG|---resultSet-- (Database.SaveResult[getErrors=(Database.Error[getFields=(Quantity);getMessage=field integrity exception: Quantity (quantity must be nonzero);getStatusCode=FIELD_INTEGRITY_EXCEPTION;]);getId=null;isSuccess=false;]
, Database.SaveResult[getErrors=(Database.Error[getFields=(unknown);getMessage=field integrity exception: unknown (total price must be specified);getStatusCode=FIELD_INTEGRITY_EXCEPTION;]);getId=null;isSuccess=false;] 
, Database.SaveResult[getErrors=(Database.Error[getFields=(unknown);getMessage=field integrity exception: unknown (total price must be specified);getStatusCode=FIELD_INTEGRITY_EXCEPTION;]);getId=null;isSuccess=false;]
, Database.SaveResult[getErrors=(Database.Error[getFields=(unknown);getMessage=field integrity exception: unknown (total price must be specified);getStatusCode=FIELD_INTEGRITY_EXCEPTION;]);getId=null;isSuccess=false;]
, Database.SaveResult[getErrors=(Database.Error[getFields=(unknown);getMessage=field integrity exception: unknown (total price must be specified);getStatusCode=FIELD_INTEGRITY_EXCEPTION;]);getId=null;isSuccess=false;]
, Database.SaveResult[getErrors=(Database.Error[getFields=(unknown);getMessage=field integrity exception: unknown (total price must be specified);getStatusCode=FIELD_INTEGRITY_EXCEPTION;]);getId=null;isSuccess=false;]
, Database.SaveResult[getErrors=(Database.Error[getFields=(unknown);getMessage=field integrity exception: unknown (total price must be specified);getStatusCode=FIELD_INTEGRITY_EXCEPTION;]);getId=null;isSuccess=false;]
, Database.SaveResult[getErrors=(Database.Error[getFields=(unknown);getMessage=field integrity exception: unknown (total price must be specified);getStatusCode=FIELD_INTEGRITY_EXCEPTION;]);getId=null;isSuccess=false;]
, Database.SaveResult[getErrors=(Database.Error[getFields=(unknown);getMessage=field integrity exception: unknown (total price must be specified);getStatusCode=FIELD_INTEGRITY_EXCEPTION;]);getId=null;isSuccess=false;]
, Database.SaveResult[getErrors=(Database.Error[getFields=(unknown);getMessage=field integrity exception: unknown (total price must be specified);getStatusCode=FIELD_INTEGRITY_EXCEPTION;]);getId=null;isSuccess=false;])
  • October 18, 2016
  • Like
  • 0
When i try to execute below code snippet, Ideally only my 1st element in the list should get failed as I am trying to set quantity field to 0 and rest of records should get saved to Database successfully. But all the records are getting failed.

List<OpportunityLineItem> lstOLI  = [SELECT Id,Quantity FROM OpportunityLineItem LIMIT 10];
lstOLI[0].Quantity = 0;
List<Database.SaveResult> resultSet = Database.update(lstOLI,false);
system.debug('---resultSet-- '+resultSet);

Output -
USER_DEBUG [4]|DEBUG|---resultSet-- (Database.SaveResult[getErrors=(Database.Error[getFields=(Quantity);getMessage=field integrity exception: Quantity (quantity must be nonzero);getStatusCode=FIELD_INTEGRITY_EXCEPTION;]);getId=null;isSuccess=false;]
, Database.SaveResult[getErrors=(Database.Error[getFields=(unknown);getMessage=field integrity exception: unknown (total price must be specified);getStatusCode=FIELD_INTEGRITY_EXCEPTION;]);getId=null;isSuccess=false;] 
, Database.SaveResult[getErrors=(Database.Error[getFields=(unknown);getMessage=field integrity exception: unknown (total price must be specified);getStatusCode=FIELD_INTEGRITY_EXCEPTION;]);getId=null;isSuccess=false;]
, Database.SaveResult[getErrors=(Database.Error[getFields=(unknown);getMessage=field integrity exception: unknown (total price must be specified);getStatusCode=FIELD_INTEGRITY_EXCEPTION;]);getId=null;isSuccess=false;]
, Database.SaveResult[getErrors=(Database.Error[getFields=(unknown);getMessage=field integrity exception: unknown (total price must be specified);getStatusCode=FIELD_INTEGRITY_EXCEPTION;]);getId=null;isSuccess=false;]
, Database.SaveResult[getErrors=(Database.Error[getFields=(unknown);getMessage=field integrity exception: unknown (total price must be specified);getStatusCode=FIELD_INTEGRITY_EXCEPTION;]);getId=null;isSuccess=false;]
, Database.SaveResult[getErrors=(Database.Error[getFields=(unknown);getMessage=field integrity exception: unknown (total price must be specified);getStatusCode=FIELD_INTEGRITY_EXCEPTION;]);getId=null;isSuccess=false;]
, Database.SaveResult[getErrors=(Database.Error[getFields=(unknown);getMessage=field integrity exception: unknown (total price must be specified);getStatusCode=FIELD_INTEGRITY_EXCEPTION;]);getId=null;isSuccess=false;]
, Database.SaveResult[getErrors=(Database.Error[getFields=(unknown);getMessage=field integrity exception: unknown (total price must be specified);getStatusCode=FIELD_INTEGRITY_EXCEPTION;]);getId=null;isSuccess=false;]
, Database.SaveResult[getErrors=(Database.Error[getFields=(unknown);getMessage=field integrity exception: unknown (total price must be specified);getStatusCode=FIELD_INTEGRITY_EXCEPTION;]);getId=null;isSuccess=false;])
  • October 18, 2016
  • Like
  • 0