我正在开发一个Android应用程序,以便在vTiger(ver 5.4)CRM服务器中创建新报价。
我能够生成新的报价,但是没有发送我要添加的报价详细信息中的product_id和数量。除产品清单,数量和价格外,其他详细信息均显示在新报价中。
我也研究了vTiger网络服务教程,但是在这种情况下它没有帮助。
php
Android/JAVA
这就是我发送在vTiger服务器中创建新报价所需的详细信息的方式。
try {
objectJson.put("subject", subject);
objectJson.put("account_id", accountId);
objectJson.put("bill_street", address);
objectJson.put("assigned_user_id", "19x1");
objectJson.put("conversion_rate", "1.000");
objectJson.put("currency_id", "21x1");
objectJson.put("hdnTaxType", "group");
objectJson.put("productid", productId);
objectJson.put("quantity", quantity);
}
catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
String data = null;
try {
data = URLEncoder.encode("sessionName", "UTF-8")
+ "=" + URLEncoder.encode(sessionId, "UTF-8");
data += "&" + URLEncoder.encode("element", "UTF-8") + "="
+ URLEncoder.encode(objectJson.toString(), "ISO-8859-1");
data += "&" + URLEncoder.encode("elementType", "UTF-8") + "="
+ URLEncoder.encode(moduleName, "UTF-8"); //moduleName='Quotes'
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
String text = "";
BufferedReader reader=null;
// Send data
try
{
// Defined URL where to send data
URL url = new URL("http://vtiger_url/webservice.php?operation=create");
// Send POST data request
URLConnection conn = url.openConnection();
conn.setDoOutput(true);
OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream());
wr.write( data );
wr.flush();
}
catch(Exception ex)
{
}
上面的代码可以帮助我生成没有产品详细信息的报价。
在研究了上述php
答案之后,我将代码中使用的URL更改为:- http://vtiger_url/webservice.php?total=23000&operation=create
。这有助于我将总额添加到新创建的报价中,但是使用这种方法添加其他详细信息并没有成功。
这些行已添加到现有代码中:
JSONArray pdoInformation = new JSONArray();
try{
// Added these lines in try block to send product details
for(int i=0; i<productIds.size(); i++) {
JSONObject obj = new JSONObject();
obj.put("productid", productIds.get(i) );
obj.put("qty", quantities.get(i));
obj.put("listprice", listprices.get(i));
pdoInformation.put(obj);
}
objectJson.put("pdoInformation", pdoInformation);
}
这里需要有产品的详细信息的发送JSONArray
与名称"pdoInformation"
。
for
循环用于发送多个产品详细信息。
这里productIds
,quantities
和listprices
存储三个强制性产品细节ArrayList
。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句