Java – Product details cannot be added when creating a new quote

Product details cannot be added when creating a new quote… here is a solution to the problem.

Product details cannot be added when creating a new quote

I’m working on an Android app to create a new quote in the vTiger (version 5.4) CRM server.

I

was able to generate a new quote, but the product_id and quantity I sent in the quote details were not added to it. In addition to the product list, quantity, and price, additional details are displayed in the new quote.

I also looked at vTiger webservices tutorial, but it didn’t help in this case.

I found a accepted answer similar question, but it is in PHP , not in Android/JAVA.

This is how I send the details needed to create a new offer in the vTiger server. :-

            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)
                        {

}

The above code helped me generate a quote without product details.

After studying the php answer mentioned above

answer you find seems appropriate, even if it’s a PHP solution. The problem you described:

I have tried this too but unfortunately I am not able to access Inventoryproductrel table.

It may already indicate a lack of proper authentication or missing permissions. So my suggestion is

  1. Find out why the table Inventoryproductrel cannot be accessed. Try to access the table with your authentication permissions (sessionID), check the response to any prompts, and try to resolve the table isn't accessible.
  2. Finally, follow the suggestion of this answer

Just another tip. If you can successfully access the table through a web browser, then I sniff the request and look at the http parameters and their values. Based on these findings, you can modify your request.
Always consider that web browsers can only do the same things as your Android apps.

Related Problems and Solutions