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
Rohit2006Rohit2006 

How to get an Id of last inserted record using salesforce toolkit for flex

I am using create method of the salesforce toolkit for flex to enter the new record in the table and I want the ID of the inserted record to proceed further the callback function gives me the result object which when alerted using following syntax gives me a string that contains id.
Is there any method by which I can get the id of the inserted record in the code below?
 
Code:
private function CloneOpportunityType():void
 {
  try{
    var EMASOpportunityTypes:SObject = new SObject('EMAS_Opportunity_Types__c');
   EMASOpportunityTypes.Name = txtNewOpportunityTypeName.text.toString();
   EMASOpportunityTypes.Description__c = txtAreaOpportunityTypeDescription.text.toString();
   ta.text = EMASOpportunityTypes.toDebugString();
   
   apex.create([EMASOpportunityTypes], new AsyncResponder(
      function (result:Object):void {
       
       Alert.show(ObjectUtil.toString(result));
     }, genericFault
    ) );
  }
  catch (err:Object)
  {
   //Alert.show("");
  }
 }

 

Message Edited by Ron Hess on 08-12-2007 04:42 PM

Ron HessRon Hess
you can access the id field of the SaveResult

so add this line to your callback, then run.

    trace( 'new id: '+(result[0] as SaveResult).id );
Rohit2006Rohit2006

Hello Ron,

Your suggestion fulfilled my requirement. I saved have saved one query per operation because of this.Thanks a lot for your help :)