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
rupinder jeetrupinder jeet 

cloning a standard object:exception

hi all,
 
i am trying to clone a SObject and thus creating a custom object. i am using the following code:
 
<!-- begin code -->
<!-- replace 'Closed' (without quotes) in the code below with the Status desired for case closure -->
<html>
<head>
<script src="/soap/ajax/8.0/connection.js"></script>
<script src="/desktop/desktopApi.js"></script>
<script>
alert("start");
// Query all the fields of the custom object
var result = sforce.connection.query("select Account,NextStep from Opportunity  where Id=: OpportunityId" );
var records = result.getArray("records");
 
// Create an instance of a custom_object
var new_Custom_Object = new sforce.SObject("Opporutnity_cloned__c");

new_Custom_Object.Account = records[0].Account;

new_Custom_Object.NextStep = records[0].NextStep ;
 
// Create the Object
 try
 {
 var saveResult = sforce.connection.create( new_Custom_Object );
  // Check to see that the object was created successfully
  if ( saveResult[0].getBoolean("success") )
  {
     alert( "Success  " );
  }
  else
  {
    alert( "Error occurred: " + saveResult[0] );
  }
//}
</script>
</head>
<body onload="init()">
<p>&nbsp;
</p>
</body>
</html>
 
plesae tell that where i am wrong in this code. It is giving exception in the query which is highlighted by red color.
 
regards,
RJS.
werewolfwerewolf
Didn't you post this exact same question yesterday?  And didn't Whyser and I reply to it with some solutions?
rupinder jeetrupinder jeet

nops :) somebody else might have posted it. i checked that answer series too but that seems to be more of like for custom objects. me trying for standard object.

i m facing exception in the query part which is highlighted in the code. pls put in ur valuable suggestions for the same.

best regards,

rjs.

werewolfwerewolf
It was definitely you.  See the answers to your other post here:

http://community.salesforce.com/sforce/board/message?board.id=ajax_toolkit&message.id=6312#M6312
rupinder jeetrupinder jeet

hey thanks dear.. for the help. i dint check that.. 

cheers,

rjs