Cannot add product details when creating a new quote.

I am developing an Android application to create a new quote in the vTiger server (ver. 5.4) CRM.

I managed to create a new quote, but the product_id and the quantity that I sent to add the quote to the details were not added to it. Other details are shown in the new quote, except for the list of products, their quantity and price.

I also studied the vtiger webservices tutorial , but in this case it did not help.

I found the accepted answer of a similar question , but it is phpnot in Android/JAVA.

Here's how I post the details needed to create a new quote on 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 code above helps me generate a quote without product details.

php URL-, : http://vtiger_url/webservice.php?total=23000&operation=create. , .

+4
4

: -

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.

+1

answer, , , php. , :

, , , Inventoryproductrel.

, .

  • , Inventoryproductrel. , (sessionID), table isn't accessible.
  • .

. -, http . , . , - , Android.

+1

- ? . , . API-, API /, , . Quotes item_details, . API, -.

vTiger

String modeleName = "Quotes"; //Use Products if you want a description of the Products module
String data = null;

try {               
    data = URLEncoder.encode("sessionName", "UTF-8")
                + "=" + URLEncoder.encode(sessionId, "UTF-8");
    data += "&" + URLEncoder.encode("elementType", "UTF-8") + "="
                + URLEncoder.encode(moduleName, "UTF-8");
} catch (UnsupportedEncodingException e) {
    e.printStackTrace();
} 

String text = "";
BufferedReader reader=null;
System.out.println(data);
// Send data
try
{                 
    // Defined URL  where to send data
    URL url = new URL("http://vtiger_url/webservice.php?operation=describeobject");

    // Send GET data request
    URLConnection conn = url.openConnection();
    conn.setDoOutput(true);
    OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream());
    wr.write( data );
    wr.flush();   
} catch(Exception ex) {
}

, , , , URL , - GET POST , , , URL

0

@help , , JsonObject , ? , Volley , , . http://arnab.ch/blog/2013/08/asynchronous-http-requests-in-android-using-volley/ http://www.androidhive.info/2014/05/android-working-with-volley-library-1/

Just go through it. It provides the easiest way to perform network operations, and canceling a request is also possible in this library.

Code example:

final String URL = "SERVER_URL";
// Post params to be sent to the server
HashMap<String, String> params = new HashMap<String, String>();
params.put("token", "AbCdEfGh123456");

JsonObjectRequest req = new JsonObjectRequest(URL, new JSONObject(params),
   new Response.Listener<JSONObject>() {
       @Override
       public void onResponse(JSONObject response) {
           try {
               VolleyLog.v("Response:%n %s", response.toString(4));
           } catch (JSONException e) {
               e.printStackTrace();
           }
       }
   }, new Response.ErrorListener() {
       @Override
       public void onErrorResponse(VolleyError error) {
           VolleyLog.e("Error: ", error.getMessage());
       }
   });

// add the request object to the queue to be executed
ApplicationController.getInstance().addToRequestQueue(req);

Using this code, you can send your data to your server and on the server side, you can use the PHP code to get this jsondata and analyze it.

Thank.

0
source

All Articles