Usuario
Creación y cierre de un caso desde SDK

Pregunta
-
Muy tardes estimados,
Tengo un problema, estoy desarrollando un formulario externo donde creo un caso son sdk con un método y después a este mismo caso ya creado lo cierro también desde SDK pero me salta un error:
"Object reference not set to an instance of an object.Detail"
Muchas Gracias...
Vive la Vida y no dejes que ella Viva de ti...
Todas las respuestas
-
-
Buenos días Atilio,
Aqui te anexo el código, para la creación del caso tengo el siguiente método:
public string CrearCaso(string idsubject, string nombrecaso, string tipocliente, string idcliente, bool casoautomatico, string tipocaso,
string producto, string numproducto, string region, string ciudad, string canal, string usuario, string eventocreacion, string etiqueta, string idasuntoextension, string descripcion){
Entity incident = new Entity("incident");
incident["title"] = nombrecaso;
incident["subjectid"] = new EntityReference("subject", new Guid(idsubject));
incident["bg_su_region"] = new OptionSetValue(Convert.ToInt32(region));
if (!String.IsNullOrEmpty(ciudad))
incident["bg_su_ciudad"] = new OptionSetValue(Convert.ToInt32(ciudad));
if (!String.IsNullOrEmpty(canal))
incident["bg_su_canal"] = new OptionSetValue(Convert.ToInt32(canal));
if (!String.IsNullOrEmpty(producto))
incident["productid"] = new EntityReference("product", new Guid(producto));
if (!String.IsNullOrEmpty(idasuntoextension))
incident["bg_asuntosextensionid"] = new EntityReference("bg_asuntosextension", new Guid(idasuntoextension));
if (!String.IsNullOrEmpty(eventocreacion))
incident["bg_evento_creacion"] = eventocreacion;
if (!String.IsNullOrEmpty(numproducto))
incident["productserialnumber"] = numproducto;
incident["bg_fecha_vencimiento"] = DateTime.Now;
incident["CFBCaso_Automatico"] = casoautomatico;
if (!String.IsNullOrEmpty(canal))
incident["caseorigincode"] = new OptionSetValue(Convert.ToInt32(canal));
incident["casetypecode"] = new OptionSetValue(Convert.ToInt32(tipocaso));
incident["ownerid"] = new EntityReference("systemuser", new Guid(usuario));
switch (tipocliente)
{
case "1": incident["customerid"] = new EntityReference("account", new Guid(idcliente));
break;
case "2": incident["customerid"] = new EntityReference("contact", new Guid(idcliente));
break;
}
try
{
asu = servicio.Create(incident);CerrarCaso(asu.ToString());
}
}
catch (Exception ex)
{
mensajerror = "Error: " + ex;
}
finally
{
}
return asu.ToString();}
Y el método para cerrar e caso es el siguiente:
public void CerrarCaso(string casoid)
{
CrmConnection con = new CrmConnection("CRMOnline");
OrganizationService servicio = new OrganizationService(con);
try
{
Entity ir = new Entity("incidentresolution");
ir["incidentid"] = new Guid(casoid);
ir["subject"] = "Información entregada";
ir["description"] = "Información entregada a través de generación de Caso Automático";
ir["timespent"] = 0;
ir["incidentid"] = new EntityReference("incident", new Guid(casoid));
ir["statecode"] = new OptionSetValue(1);
servicio.Create(ir);
CloseIncidentRequest req = new CloseIncidentRequest();
req.IncidentResolution = ir;
req.Status = new OptionSetValue(7);
CloseIncidentResponse resp = (CloseIncidentResponse)servicio.Execute(req);
}
catch (System.Web.Services.Protocols.SoapException ex)
{
mensajerror = "Error: " + ex;
}
finally
{
}
}En el catch de cerrar caso donde esta el soap exception no entra se va por el exception general del crear caso, y el mensaje es este:
"Object reference not set to an instance of an object."
Vive la Vida y no dejes que ella Viva de ti...
-
Hola Jose,
Vamos a intentar algo,
public void CerrarCaso(string casoid) { CrmConnection con = new CrmConnection("CRMOnline"); OrganizationService servicio = new OrganizationService(con); try { Entity ir = new Entity("incidentresolution"); ir["subject"] = "Información entregada"; ir["incidentid"] = new EntityReference("incident", new Guid(casoid)); //servicio.Create(ir); CloseIncidentRequest req = new CloseIncidentRequest(); req.IncidentResolution = ir; req.Status = new OptionSetValue(7); req.RequestName = "Cerrando incidencia"; CloseIncidentResponse resp = (CloseIncidentResponse)servicio.Execute(req); } catch (System.Web.Services.Protocols.SoapException ex) { mensajerror = "Error: " + ex.Detail.InnerText; } finally { } }
Avísame como va,
Salu2 Atilin | http://atiliorosas.blogspot.com.es/
-
-
-
Volvio el mismo error principal:
"Object reference not set to an instance of an object."
Lo raro es que si creo un caso desde CRM 2011 si me permite cerrarlo con el SDK, en cambio cuando lo creo por SDK no me deja.
Un saludo...
Vive la Vida y no dejes que ella Viva de ti...
-
-
Si siempre devuelve al momento de crearlo, Atilio sera que podremos agregarnos por algún correo para chat y tener mejor tiempo de respuesta?
Vive la Vida y no dejes que ella Viva de ti...
-