Jeff in your last example
var intRecordId = CRM.GetContextInfo("lead","lead_leadid");
var FirstRecord = CRM.FindRecord("lead","lead_leadid="+intRecordId);
var NewRecord = CRM.CreateRecord("lead");
//copy the data from the first record to the second
e = new Enumerator(FirstRecord);
while (e.item())
{
NewRecord(e.item()) = FirstRecord(e.item())
e.moveNext();
}
//set the fields and properties unique to the new record
NewRecord.lead_description = NewRecord.lead_description +"- cloned";
NewRecord.lead_stage = "Assigned";
NewRecord.SetWorkflowInfo("Lead Workflow", "Assigned");
NewRecord.SaveChanges();
what if any .js files need to be included at the top I have created this script made a new tab on the opportunity and pointing it to the customfile .asp page created. the page trys to load and hangs on me. I don't see any errors in the logs but yet it doesn't create a clone opportunity. I used fiddler2 to see if I noticed anything and nothing stood out. Here is my code I am using.
<!-- #include file ="../crmwizard.js" -->
<!-- #include file ="../crmconst.js" -->
<%
var intRecordId = CRM.GetContextInfo("opportunity","oppo_opportunityid");
var FirstRecord = CRM.FindRecord("opportunity","oppo_opportunityid="+intRecordId);
var NewRecord = CRM.CreateRecord("opportunity");
//copy the data from the first record to the second
e = new Enumerator(FirstRecord);
while (e.item())
{
NewRecord(e.item()) = FirstRecord(e.item())
e.moveNext();
}
//set the fields and properties unique to the new record
NewRecord.oppo_description = NewRecord.oppo_description +"- cloned";
NewRecord.oppo_stage = "Sold";
NewRecord.SetWorkflowInfo("Opportunity Workflow", "Sold");
NewRecord.SaveChanges();
%>