+ Start a Discussion
sfDevelopersfDeveloper 

Wat is the datatype of the amount field (opportunity) ??

Hello,

I'm trying to insert an opportunity via the API. The amount field has a double data type. In my code I have a double variable with the value 1000, just like this:  

double a=1000;

When I excute the insert call with the parameter above, I get this error:

XMLException: helma.xmlrpc.XmlRpcException: Value 1000.0 not of required type double on field amountcode: 1212

I don't why, my parameter "a" has the right data type, so why is my code not working ??

Regards,

sfDeveloper

 

DevAngelDevAngel

Hi sfDeveloper,

Can you post the xml-rpc request?  Need to see how you xml-rpc client is serializing the request.

sfDevelopersfDeveloper

Hi Dave,

Hier is my xmlrpc request:

public void insertOpportunityInSalesforce()

{

  Hashtable param=new Hashtable();

param.put("version",version);

param.put("type","opportunity");

param.put("operation","insert");

Hashtable fields=new Hashtable();

fields.put("name","Super zomeractie 2003");

// 00N30000000cEhN is my own ctreated filed

fields.put("00N30000000cEhN","304.03.1052");

fields.put("accountID","00130000000c4It");

fields.put("stage", "Prospecting");

//fields.put("probability", "50");

java.util.Date datum= new java.util.Date();

fields.put("closeDatecode", datum);

int amount=1000;

fields.put("amount", String.valueOf(amount));

Hashtable insertRecord = new Hashtable();

Enumeration enu = fields.keys();

while(enu.hasMoreElements())

{

String key=(String)enu.nextElement();

insertRecord.put(key, fields.get(key));

}

param.put("record",insertRecord);

Vector params=new Vector();

params.add(param);

Hashtable result = null;

try

{

//Execute the query call using the parameters built above

this.rpcClient.setSessionId(this.sessionId);

result = (Hashtable) this.rpcClient.execute("sfdc.insert", params);

this.setSfInsertSuceed(true);

}

catch (XmlRpcException ex)

{

printMsg("XMLException: " + ex.toString() + "code: " + ex.code);

ex.printStackTrace();

catch (IOException ex)

{

printMsg("Exception: " + ex.toString());

ex.printStackTrace();

}

}// end insertoppertunity

sfDevelopersfDeveloper

Hi Dave,

I just posted the wrong code. The following code is the right one.

Thank you,

sfDeveloper

*****************************************************************************

public void insertOpportunityInSalesforce()

{

 Hashtable param=new Hashtable();

 param.put("version",version);

 param.put("type","opportunity");


 param.put("operation","insert");


 Hashtable fields=new Hashtable();

 fields.put("name","Super zomeractie 2003");

 // 00N30000000cEhN is my own ctreated filed

 fields.put("00N30000000cEhN","304.03.1052");

 fields.put("accountID","00130000000c4It");

 fields.put("stage", "Prospecting");

 //fields.put("probability", "50");

 java.util.Date datum= new java.util.Date();

 fields.put("closeDatecode", datum);

 int amount=1000;

 fields.put("amount", String.valueOf(amount));


 param.put("record",fields);


 Vector params=new Vector();

 params.add(param);


 Hashtable result = null;

 try

 {

  //Execute the query call using the parameters built above

  this.rpcClient.setSessionId(this.sessionId);

  result = (Hashtable) this.rpcClient.execute("sfdc.insert", params);

 }

 catch (XmlRpcException ex)

 {

  printMsg("XMLException: " + ex.toString() + "code: " + ex.code);
 
  ex.printStackTrace();

 }

 catch (IOException ex)

 {

  printMsg("Exception: " + ex.toString());

  ex.printStackTrace();

 }

}// end insertoppertunity

 

DevAngelDevAngel

Hi sfDeveloper,

For the xml-rpc request what I meant was the message that is sent over the wire, not the java function that builds the request. 

Typically, the xml-rpc determines the java type of the value it is going to serialize and builds the xml tag based on that.  So, instead of int amount = 1000; using double x = 1000.0;.  Don't know if this will solve the problem, but it is worth a try.

sfDevelopersfDeveloper

Hello DevAngel,

I tried (double amount=100.0) before, but it still not working. The same error:

XMLException: helma.xmlrpc.XmlRpcException: Value 1000.0 not of required type double on field amountcode: 1212

Is there any other reason why my code doesn't work.

 

sfDeveloper

plpl
You need the object of class java.lang.Double as parameter.
sfDevelopersfDeveloper

Hi pl,

I tried java.lang.Double as type. it's still not working  .. Do any body has other solution ??

 

regards,

sfDeveloper 

DevAngelDevAngel

Hi sfDeveloper,

Please post the xml-rpc message that is failing.

sfDevelopersfDeveloper

Hello Dave,

I've resolved the problem. And by the way I use the helma.xmlrpc.jar. I don't have any source.

So thank you any way.

 

sfDeveloper

DevAngelDevAngel
Care to share your resolution?