Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Creating customeraddress in c#

Status
Not open for further replies.

manuortiz

Programmer
Apr 4, 2007
2
0
0
ES
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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top