Method PostSearchPOByNumber

Summary

Search PO By Number AssetWorks version

Remarks

AssetWorks version

Requires

Input Parameters

NameTypeLengthDescription
action System.String 1 [Required] Requested type of information since last call: N = newly added PO’s and/or PO line items, U = Updated PO’s and/or line items, C = Cancelled PO’s and/or line items
poNumber System.String 6 PO number: Numeric right justified zero filled, Used when requesting a specific PO, Only populate this field when requesting a specific PO

Example

POST http://localhost/FusionServices/v2/Naviline/ProductInventory/SearchPOByNumber

Return Values

NameDescription
ErrorCode 0000 = Success.
ErrorDescription Success if success, otherwise returns a descriptive error message.
Other See fields returned below in sample responses

Sample Responses

Sample Code

using System.Net;
using Newtonsoft.Json.Linq;

public void MethodName(parms)
{
   string uri = "http://localhost/FusionServices/v2/Naviline/ProductInventory/SearchPOByNumber";
   System.Collections.Specialized.NameValueCollection postParms = 
     new System.Collections.Specialized.NameValueCollection(); 
   // Set paramater values
   postParms.Add("poNumber",System.Web.HttpUtility.UrlEncode("021015"));
   postParms.Add("action",System.Web.HttpUtility.UrlEncode("N"));

   WebClient req = new WebClient();
   wc.Headers.Add("Content-Type", "application/x-www-form-urlencoded");
   wc.Headers.Set("X-APPID", "YOURID");
   wc.Headers.Set("X-APPKEY", "YOURKEY");

   JObject response = JObject.Parse(stringResult);
   string error = response["OutputParms"]["ErrorCode"].ToString();
   if (error == "0000")
   {
        JArray jRows = (JArray)response["Rows"];
        foreach (JObject row in jRows)
        {
             string RecordType = row["RecordType"].ToString();
             string Action = row["Action"].ToString();
             string PONumber = row["PONumber"].ToString();
             string POType = row["POType"].ToString();
             string ThirdPartyReqNumber = row["ThirdPartyReqNumber"].ToString();
             string PODate = row["PODate"].ToString();
             string POStatCode = row["POStatCode"].ToString();
             string ContractNumber = row["ContractNumber"].ToString();
             string BuyerCode = row["BuyerCode"].ToString();
             string VendorNumber = row["VendorNumber"].ToString();
             string VendorName = row["VendorName"].ToString();
             string DeliverByDate = row["DeliverByDate"].ToString();
             string ShipToLocCode = row["ShipToLocCode"].ToString();
             string BillToDefault = row["BillToDefault"].ToString();
             string FreightAmount = row["FreightAmount"].ToString();
             string POLineNumber = row["POLineNumber"].ToString();
             string ThirdPartyLineNumber = row["ThirdPartyLineNumber"].ToString();
             string OrderStatus = row["OrderStatus"].ToString();
             string Building = row["Building"].ToString();
             string Commodity = row["Commodity"].ToString();
             string SubCommodity = row["SubCommodity"].ToString();
             string ItemNumber = row["ItemNumber"].ToString();
             string ItemDescription = row["ItemDescription"].ToString();
             string OrderQuantity = row["OrderQuantity"].ToString();
             string OrderUnitCost = row["OrderUnitCost"].ToString();
             string OrderUOM = row["OrderUOM"].ToString();
             string OrderCustCharge = row["OrderCustCharge"].ToString();
             string OrderExpAcctNo = row["OrderExpAcctNo"].ToString();
             string OrderProjNo = row["OrderProjNo"].ToString();
             string FleetEquipNumber = row["FleetEquipNumber"].ToString();
             string FleetJobNumber = row["FleetJobNumber"].ToString();
             string FleetJobRepairNumber = row["FleetJobRepairNumber"].ToString();
             string WorkOrderID = row["WorkOrderID"].ToString();
             string WorkOrderJobNumber = row["WorkOrderJobNumber"].ToString();
             // TODO - YOUR CODE HERE
        }
   }
}

C# Razor MVC Sample Code

using System;
using System.Linq;
using System.Web;
using System.ComponentModel.DataAnnotations;
using System.Collections.Specialized;
using FusionServiceHelper.Models;

// NOTE: Use the namespace generated when you add the class, so that it is correct.
namespace FusionRazor.Models
{
   public class PostSearchPOByNumber
   {
       // Add property for each input param in order to map a field to it
       [Required(ErrorMessage = "Required")]
       [RegularExpression("^(?=.{0,1}$).*", ErrorMessage = "Must be 1 characters or less. ")]
       public string action{get; set;}

       [RegularExpression("^(?=.{0,6}$).*", ErrorMessage = "Must be 6 characters or less. ")]
       public string poNumber{get; set;}

       public PostSearchPOByNumber()
       {
           //Set any defaults here
       }
   }
}
@* NOTE: Use Add->View to add the View. *@
@* NOTE: Check the 'Create strongly-typed view checkbox, and select the PostSearchPOByNumber class. *@
@* NOTE: Select Edit as the Scaffold template. *@
@* NOTE: Use the @model line that is generated at the top.  Replace the rest with the lines below.
@model FusionRazor.Models.PostSearchPOByNumber

@{
   ViewBag.Title = "PostSearchPOByNumber";
}

<h2>PostSearchPOByNumber</h2>
@using (Html.BeginForm()) {
   @Html.AntiForgeryToken()
   @Html.ValidationSummary(true)
   <fieldset>
   <legend>PostSearchPOByNumber</legend>
       <div class="editor-label">
           @Html.LabelFor(model => model.action)
       </div>
       <div class="editor-field">
           @Html.EditorFor(model => model.action)
           @Html.ValidationMessageFor(model => model.action)
       </div>
       <div class="editor-label">
           @Html.LabelFor(model => model.poNumber)
       </div>
       <div class="editor-field">
           @Html.EditorFor(model => model.poNumber)
           @Html.ValidationMessageFor(model => model.poNumber)
       </div>
       <p>
       <input type="submit" value="Submit"/>
       </p>
   </fieldset>

}

@section Scripts {
   @Scripts.Render("~/bundles/jqueryval")
}
using System;
using System.Collections.Specialized;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using FusionServiceHelper.Models;

// NOTE: Replace 'MyController' with the name of your controller.

// 
// GET: /MyController/PostSearchPOByNumber
public ActionResult PostSearchPOByNumber()
{
   // Create a new instance of the model to pick up any default values.
   PostSearchPOByNumber model =  new PostSearchPOByNumber();

   // pass model to set to default values
   // NOTE: Change 'MyFolderPath' to the path to the .cshtml file.
   return View("~/Views/MyFolderPath/PostSearchPOByNumber.cshtml", model);
}

// 
// POST: /MyController/PostSearchPOByNumber
[HttpPost]
public ActionResult PostSearchPOByNumber(FormCollection collection)
{
   string url = "v2/Naviline/ProductInventory/SearchPOByNumber";
   // Get the value from each input field
   NameValueCollection inputParms = new NameValueCollection();
   inputParms.Add("action", collection["action"]);
   inputParms.Add("poNumber", collection["poNumber"]);

   try
   {
       // Send the request
       FusionServiceRequest request = new FusionServiceRequest();
       FusionServiceResult result = request.Post(url, inputParms);

       return View("Result", result);
   }
   catch(Exception e)
   {
       HandleErrorInfo info = new HandleErrorInfo(e, "MyController", "PostSearchPOByNumber");
       return View("Error", info);
   }
}