Hello everybody
I'm trying tu create a customeraddress using the code below. I create the parent account first and want to create the adress for this account.
public void RellenarDatos()
{
account Cuenta= new account();
//give value to the account
Guid idCuenta=CrearObjeto(Cuenta, "account");;
customeraddress NuevaDireccion = new customeraddress();
NuevaDireccion.name = miCliente.direcciones.nombre_direccion;
NuevaDireccion.addresstypecode = new Picklist();
NuevaDireccion.addresstypecode.Value = Convert.ToInt32(Gws.ObtenerValoresPicklist("account", "address2_addresstypecode", miCliente.direcciones.tipo_direccion.ToString()));
NuevaDireccion.line1 = miCliente.direcciones.calle;
NuevaDireccion.postalcode = miCliente.direcciones.codigo_postal;
NuevaDireccion.stateorprovince = miCliente.direcciones.provincia;
NuevaDireccion.city = miCliente.direcciones.localidad;
NuevaDireccion.country = miCliente.direcciones.pais;
NuevaDireccion.parentid = new Lookup();
NuevaDireccion.parentid.type = EntityName.account.ToString();
NuevaDireccion.parentid.Value = idCuenta;
Guid Id=CrearObjeto(direccion, "customeraddress");
}
public Guid CrearObjeto(BusinessEntity objeto, string EntityName)
{
#region
Guid Creado = new Guid();
switch (EntityName)
{
case "account":
account accountCreate = (account)objeto;
Creado = ServicioWeb.Create(accountCreate);
break;
case "customeraddress":
customeraddress customeraddressCreate = (customeraddress)objeto;
Creado = ServicioWeb.Create(customeraddressCreate);
break;
default:
throw new Exception();
}
return Creado;
#endregion
}
When i create the addres in the line
Creado = ServicioWeb.Create(customeraddressCreate);
it crashes. The error is the generic error of the webservice so it doesn't help.
Anybody knows what I'm doing wrong?
Thanks
I'm trying tu create a customeraddress using the code below. I create the parent account first and want to create the adress for this account.
public void RellenarDatos()
{
account Cuenta= new account();
//give value to the account
Guid idCuenta=CrearObjeto(Cuenta, "account");;
customeraddress NuevaDireccion = new customeraddress();
NuevaDireccion.name = miCliente.direcciones.nombre_direccion;
NuevaDireccion.addresstypecode = new Picklist();
NuevaDireccion.addresstypecode.Value = Convert.ToInt32(Gws.ObtenerValoresPicklist("account", "address2_addresstypecode", miCliente.direcciones.tipo_direccion.ToString()));
NuevaDireccion.line1 = miCliente.direcciones.calle;
NuevaDireccion.postalcode = miCliente.direcciones.codigo_postal;
NuevaDireccion.stateorprovince = miCliente.direcciones.provincia;
NuevaDireccion.city = miCliente.direcciones.localidad;
NuevaDireccion.country = miCliente.direcciones.pais;
NuevaDireccion.parentid = new Lookup();
NuevaDireccion.parentid.type = EntityName.account.ToString();
NuevaDireccion.parentid.Value = idCuenta;
Guid Id=CrearObjeto(direccion, "customeraddress");
}
public Guid CrearObjeto(BusinessEntity objeto, string EntityName)
{
#region
Guid Creado = new Guid();
switch (EntityName)
{
case "account":
account accountCreate = (account)objeto;
Creado = ServicioWeb.Create(accountCreate);
break;
case "customeraddress":
customeraddress customeraddressCreate = (customeraddress)objeto;
Creado = ServicioWeb.Create(customeraddressCreate);
break;
default:
throw new Exception();
}
return Creado;
#endregion
}
When i create the addres in the line
Creado = ServicioWeb.Create(customeraddressCreate);
it crashes. The error is the generic error of the webservice so it doesn't help.
Anybody knows what I'm doing wrong?
Thanks