In this blog, I will explain how to send a purchase order from .NET MVC web application using SDK.
Before using any Quickbooks online API we need access token, if you don’t know how to get access token then you can find it here.
A purchase order will be sent to the email. if the email address already set in purchase order Email or it already exists in purchase order’s “PurchaseOrder.POEmail.Address” then it will be sent to that email else we have to give a particular email on which we have to send a purchase order.
Below are a few steps to send a purchase order,
public ActionResult SendPurchaseOrderById(string PurchaseOrderID) { try { OAuth2RequestValidator oauthValidator = new OAuth2RequestValidator(Access_token); // Create a ServiceContext with Auth tokens and realmId ServiceContext serviceContext = new ServiceContext(RealmId, IntuitServicesType.QBO, oauthValidator); serviceContext.IppConfiguration.MinorVersion.Qbo = "23"; serviceContext.IppConfiguration.BaseUrl.Qbo = QboBaseUrl; string EXISTING_PURCHASEORDER_QUERYBYID = string.Format("select * from PurchaseOrder where id = '{0}'", PurchaseOrderID); var queryService = new QueryService<PurchaseOrder>(serviceContext); PurchaseOrder objPurchaseOrderFound = queryService.ExecuteIdsQuery(EXISTING_PURCHASEORDER_QUERYBYID).FirstOrDefault<PurchaseOrder>(); //If Purchase Order found on Quickbooks online if (objPurchaseOrderFound != null) { DataService dataService = new DataService(serviceContext); if (objPurchaseOrderFound.POEmail != null && !string.IsNullOrEmpty(objPurchaseOrderFound.POEmail.Address)) { var SentPDF = dataService.SendEmail<PurchaseOrder>(objPurchaseOrderFound); ViewBag.IsSuccess = true; } else { //if you want to then, you can set ToEmail from database or somewhere else String ToEmail = "tabishzrangrej.vision@gmail.com"; var SentPDF = dataService.SendEmail<PurchaseOrder>(objPurchaseOrderFound, ToEmail); ViewBag.IsSuccess = true; } } return View(); } catch (IdsException ex) { return View(); } catch (Exception ex) { return View(); } }
@{ ViewBag.Title = "SendPurchaseOrderById"; } <h2>Send Purchase Order By Id</h2> @if (ViewBag.IsSuccess != null && ViewBag.IsSuccess == true) { <div class="row"> <label class="label label-success"> Purchase Order Sent Successfully </label> </div> }
You can also set a send email link in the list view of the purchase order. if you don’t know how to get purchase order from Quickbooks Online you can find it here.
@model List<Intuit.Ipp.Data.PurchaseOrder> @using Intuit.Ipp.Data; @{ ViewBag.Title = "GetAllPurchaseOrder"; } <h2>Quickbooks online Purchase Order List</h2> <div> <table class="table table-bordered"> @foreach (var item in Model) { <tr style="border: 2px solid black;border-bottom: none;background-color:#a9a9a9"> <th>QBO Purchase Order ID</th> <th>Purchase Order Number</th> <th>Purchase Order Date</th> <th>Vendor</th> <th>Total Amount</th> <th style="text-align:center;">Download</th> <th style="text-align:center;">Send Email</th> </tr> <tr style="border: 2px solid black;border-bottom: none;border-top: none;"> <td>@item.Id</td> <td>@item.DocNumber</td> <td>@item.TxnDate.ToString("MM/dd/yyyy")</td> <td>@item.VendorRef.name</td> <td>@item.TotalAmt</td> <td style="text-align:center;"><a href="@Url.Action("GetPurchaseOrderPdfById", "Home", new { PurchaseOrderID = item.Id })" target="_blank"><img src="~/Content/Images/downloadICON.png" height="25" width="25" /></a></td> <td style="text-align:center;"><a href="@Url.Action("SendPurchaseOrderById", "Home", new { PurchaseOrderID = item.Id })" target="_blank"><img src="~/Content/Images/SendImageICON.png" height="25" width="25" /></a></td> </tr> <tr style="border: 2px solid black;border-top: none;"> <td colspan="7"> <table class="table table-bordered"> <tr> <td colspan="5" style="text-align:center;"><label>Items Details</label></td> </tr> <tr> <th>Line Id</th> <th>Item Name</th> <th>Qty</th> <th>Total Amount</th> <th>Description</th> </tr> @foreach (var LineItem in item.Line) { <tr> <td>@LineItem.Id</td> @{ ItemBasedExpenseLineDetail Expenseitem = (ItemBasedExpenseLineDetail)LineItem.AnyIntuitObject; } <td>@Expenseitem.ItemRef.name</td> <td> @if (Expenseitem.QtySpecified) { @Expenseitem.Qty } </td> <td> @if (LineItem.AmountSpecified) { @LineItem.Amount } </td> <td>@LineItem.Description</td> </tr> } </table> </td> </tr> } </table> </div>
OUTPUT:
In this article, we have to show Create and Used PIPE in angular
In this article, we have to show Create and Used PIPE in angular
In this article, we have to show Create and Used PIPE in angular