我正在开发一个 Android 应用程序以在 vTiger(5.4 版)CRM 服务器中创建新报价。
我能够生成新报价,但我在报价详细信息中发送的 product_id 和数量没有添加到其中。除产品 list 、数量和价格外,新报价中显示了其他详细信息。
我也研究了vTiger webservices tutorial但在这种情况下没有帮助。
我找到了一个 accepted answer相似的 question但它在 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
answer ,我将我在代码中使用的 URL 更改为:- http://vtiger_url/webservice.php?total=23000&operation=create
。这有助于我将总金额添加到新创建的报价中,但我未能成功使用此方法添加其余详细信息。
最佳答案
answer你发现似乎是合适的,即使它是一个 php 解决方案。您描述的问题:
I have tried this too but unfortunately I am not able to access Inventoryproductrel table.
可能已经表明缺少适当的身份验证或缺少权限。所以我的建议是
- 找出无法访问表
Inventoryproductrel
的原因。尝试使用您的身份验证权限 (sessionID) 访问该表,检查任何提示的响应并尝试解决table isn't accessible
问题。 - 最后按照这个 answer 的建议进行操作.
只是另一个提示。如果您可以通过网络浏览器成功访问该表,那么我会嗅探请求并查看 http 参数及其值。根据这些发现,您可以修改您的请求。 始终考虑,Web 浏览器只能执行与您的 Android 应用程序相同的操作。
关于java - 创建新报价时无法添加产品详细信息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24955063/