We cannot copy orders that are read-only which are orders with the status code of Complete or Fulfilled. This was a customization we created on the order form ribbon editor called "Copy Order". Does anyone know why this is the case? It mentions something about Entity and I'm thinking perhaps the entity is not being defined? this works for NON-Read Only forms though...which is puzzling.
CRM 2015 Online version
Javascript code:
var transactioncurrencyidGUID = Xrm.Page.data.entity.attributes.get("transactioncurrencyid").getValue()[0].id;
var transactioncurrencyName = Xrm.Page.data.entity.attributes.get("transactioncurrencyid").getValue()[0].name;
var pricelevelidGUID = Xrm.Page.data.entity.attributes.get("pricelevelid").getValue()[0].id;
var pricelevelName = Xrm.Page.data.entity.attributes.get("pricelevelid").getValue()[0].name;
var customeridGUID = Xrm.Page.data.entity.attributes.get("customerid").getValue()[0].id;
var customeridName = Xrm.Page.data.entity.attributes.get("customerid").getValue()[0].name;
var customerType = Xrm.Page.data.entity.attributes.get("customerid").getValue()[0].typename;
var name = Xrm.Page.data.entity.getEntityName();
// Xrm.Page.data.entity.attributes.get("name").getValue();
//Set the parameter values
var parameters = {};
parameters["neu_iscloning"] = "startcloning";
parameters["name"] = "Copy of Order: " + name;
parameters["neu_copiedfrom"] = FirstPrimaryItemId
parameters["transactioncurrencyid"] = transactioncurrencyidGUID;
parameters["transactioncurrencyidname"] = transactioncurrencyName;
parameters["pricelevelid"] = pricelevelidGUID;
parameters["pricelevelidname"] = pricelevelName;
parameters["customerid"] = customeridGUID;
parameters["customeridname"] = customeridName;
parameters["customeridtype"] = customerType;
Xrm.Utility.openEntityForm("salesorder", null, parameters);
}
Error Message when we execute the button:
System.ServiceModel.FaultException`1[[Microsoft.Xrm.Sdk.OrganizationServiceFault, Microsoft.Xrm.Sdk, Version=7.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]: System.Web.HttpUnhandledException: Microsoft Dynamics CRM has experienced an error. Reference number for administrators or support: #79FE5E44Detail:
<OrganizationServiceFault xmlns:i="www.w3.org/.../XMLSchema-instance" xmlns="schemas.microsoft.com/.../Contracts">
<ErrorCode>-2147220970</ErrorCode>
<ErrorDetails xmlns:d2p1="schemas.datacontract.org/.../System.Collections.Generic" />
<Message>System.Web.HttpUnhandledException: Microsoft Dynamics CRM has experienced an error. Reference number for administrators or support: #79FE5E44</Message>
<Timestamp>2015-12-14T18:40:53.5629282Z</Timestamp>
<InnerFault>
<ErrorCode>-2147220989</ErrorCode>
<ErrorDetails xmlns:d3p1="schemas.datacontract.org/.../System.Collections.Generic" />
<Message>Expected non-empty string.</Message>
<Timestamp>2015-12-14T18:40:53.5629282Z</Timestamp>
<InnerFault>
<ErrorCode>-2147220970</ErrorCode>
<ErrorDetails xmlns:d4p1="schemas.datacontract.org/.../System.Collections.Generic" />
<Message>System.ArgumentException: Expected non-empty string.
Parameter name: entityName</Message>
<Timestamp>2015-12-14T18:40:53.5629282Z</Timestamp>
<InnerFault i:nil="true" />
<TraceText i:nil="true" />
</InnerFault>
<TraceText i:nil="true" />
</InnerFault>
<TraceText i:nil="true" />
</OrganizationServiceFault>