c# - How to query customer list detailed with sales rep and price level in Quickbook SDK -


my goal basic: try customers details, including sales rep , price level.

i create new customer class this.

public class customer {     public string name { get; set; }     public string fullname { get; set; }     public bool isactive { get; set; }     public string salesrep { get; set; }     public string pricelevel { get; set; } } 

and main code

https://gist.github.com/anonymous/3968904d2d0fc492ed176c40465313b6#file-gistfile1-txt

private void button1_click(object sender, eventargs e)     {          qbsessionmanager sessionmanager = null;         try         {             sessionmanager = new qbsessionmanager();             imsgsetrequest requestmsgset = sessionmanager.createmsgsetrequest("us", 13, 0);             requestmsgset.attributes.onerror = enrqonerror.roecontinue;              sessionmanager.openconnection("", "quickbooks sdk demo test");             sessionmanager.beginsession("", enopenmode.omdontcare);              icustomerquery customerqueryrq = requestmsgset.appendcustomerqueryrq();              customerqueryrq.orcustomerlistquery.customerlistfilter.activestatus.setvalue(enactivestatus.asall);              imsgsetresponse responsemsgset = sessionmanager.dorequests(requestmsgset);              sessionmanager.endsession();             sessionmanager.closeconnection();              iresponse response = responsemsgset.responselist.getat(0);             icustomerretlist customerretlist = (icustomerretlist)response.detail;               list<customer> customers = new list<customer>();               if (customerretlist != null)             {                 (int = 0; < customerretlist.count; i++)                 {                     icustomerret customerret = customerretlist.getat(i);                      customer customer = new customer();                     {                         customer.name = customerret.name.getvalue();                         customer.fullname = customerret.fullname.getvalue();                         customer.isactive = customerret.isactive.getvalue();                         customer.pricelevel = customerret.pricelevelref.fullname.getvalue();                         customer.salesrep = customerret.salesrepref.fullname.getvalue();                     }                     customers.add(customer);                 }             }              datagridview1.datasource = customers;          }         catch (exception ex)         {             messagebox.show(ex.message);         }                  {             sessionmanager.endsession();             sessionmanager.closeconnection();         }     } 

when run program, got error: "object reference not set instance of object" know wrong salesrep , pricelevel these object references have no idea how fix it.

please help.

thanks

these fields:

customer.pricelevel = customerret.pricelevelref.fullname.getvalue(); customer.salesrep = customerret.salesrepref.fullname.getvalue(); 

won't exist. can't assume salesrepref or pricelevelref exists every customer. customers won't have sales rep, or won't have custom price level.

so, test make sure these aren't null or otherwise unset in way prior trying value.


Comments

Popular posts from this blog

scala - 'wrong top statement declaration' when using slick in IntelliJ -

c# - DevExpress.Wpf.Grid.InfiniteGridSizeException was unhandled -

PySide and Qt Properties: Connecting signals from Python to QML -