Method PostCreatePOLineItem

Summary

Create PO Line Item AssetWorks version

Remarks

AssetWorks version

Requires

Input Parameters

NameTypeLengthDescription
action System.String 1 [Required] Line item action: A = create new PO line item, U = Update existing PO line item, C = Cancel existing PO line item
poNumber System.String 6 [Required] PO number: Numeric right justified zero filled
buildingCode System.String 2 [Required] Building location code
poLineNumber System.String 3 PO line number: Blanks or zeros when creating a new line item, returns the PO line number that was created, Required for PO line update and cancel, Numeric right justified zero filled
commodityCode System.String 3 [Required] Commodity code
subCommodityCode System.String 3 [Required] Sub-commodity code
itemQuantity System.String 9 [Required] Order quantity: Numeric right justified zero filled, 2 decimal positions assumed, 000056789 = 567.89
itemUnitOfMeasure System.String 3 [Required] Order unit of measure code
itemCost System.String 11 [Required] Order unit cost: Numeric right justified zero filled, 4 decimal positions assumed, 00000632951 = 63.2951
returnCredit System.String 1 Ignored for action code ā€œCā€, Y = indicates a return or credit line item, Blanks = indicates a regular positive line item, Any other value = indicates a regular positive line item
itemNumber System.String 5 [Required] Item number: Required for inventory items
itemDesc System.String 50 [Required] Item description: Required for non-inventory items
accountNumber System.String 50 Account number
projectNumber System.String 6 Project number
fleetCostCode System.String 1 [Required]
fleetEquipNum System.String 5 Fleet equipment number: Numeric right justified zero filled
fleetJobNum System.String 7 Fleet job number: Numeric right justified zero filled
fleetJobRepairNum System.String 5 Fleet repair number: Numeric right justified zero filled
fleetWorkOrderNum System.String 9 Work order number
fleetWorkOrderJobNum System.String 3 Work order job number: Numeric right justified zero filled

Example

POST http://localhost/FusionServices/v3/Naviline/ProductInventory/CreatePOLineItem

Return Values

NameDescription
ErrorCode 0000
ErrorDescription Success
LineNumber 002

Sample Responses

Sample Code

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

public void MethodName(parms)
{
   string uri = "http://localhost/FusionServices/v3/Naviline/ProductInventory/CreatePOLineItem";
   System.Collections.Specialized.NameValueCollection postParms = 
     new System.Collections.Specialized.NameValueCollection(); 
   // Set paramater values
   postParms.Add("action",System.Web.HttpUtility.UrlEncode("A"));
   postParms.Add("poNumber",System.Web.HttpUtility.UrlEncode("021837"));
   postParms.Add("buildingCode",System.Web.HttpUtility.UrlEncode("FB"));
   postParms.Add("poLineNumber",System.Web.HttpUtility.UrlEncode("001"));
   postParms.Add("commodityCode",System.Web.HttpUtility.UrlEncode("CLO"));
   postParms.Add("subCommodityCode",System.Web.HttpUtility.UrlEncode("CLO"));
   postParms.Add("itemQuantity",System.Web.HttpUtility.UrlEncode("000020000"));
   postParms.Add("itemUnitOfMeasure",System.Web.HttpUtility.UrlEncode("EA"));
   postParms.Add("itemCost",System.Web.HttpUtility.UrlEncode("000020000"));
   postParms.Add("returnCredit",System.Web.HttpUtility.UrlEncode("N"));
   postParms.Add("itemNumber",System.Web.HttpUtility.UrlEncode("     "));
   postParms.Add("itemDesc",System.Web.HttpUtility.UrlEncode("ITEM 1 DESC"));
   postParms.Add("accountNumber",System.Web.HttpUtility.UrlEncode("00101014116004"));
   postParms.Add("projectNumber",System.Web.HttpUtility.UrlEncode("    "));
   postParms.Add("fleetCostCode",System.Web.HttpUtility.UrlEncode("  "));
   postParms.Add("fleetEquipNum",System.Web.HttpUtility.UrlEncode("00000"));
   postParms.Add("fleetJobNum",System.Web.HttpUtility.UrlEncode("000000"));
   postParms.Add("fleetJobRepairNum",System.Web.HttpUtility.UrlEncode("00000"));
   postParms.Add("fleetWorkOrderNum",System.Web.HttpUtility.UrlEncode("         "));
   postParms.Add("fleetWorkOrderJobNum",System.Web.HttpUtility.UrlEncode("000"));

   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");

   byte[] responseBytes = wc.UploadValues(new Uri(uri), "POST", postParms);
   string stringResult = Encoding.UTF8.GetString(responseBytes); 
   JObject response = JObject.Parse(stringResult);
   string error = response["OutputParms"]["ErrorCode"].ToString();
   if (error == "0000")
   {
         // 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 PostCreatePOLineItem
   {
       // 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;}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

       public PostCreatePOLineItem()
       {
           //Set any defaults here
       }
   }
}
@* NOTE: Use Add->View to add the View. *@
@* NOTE: Check the 'Create strongly-typed view checkbox, and select the PostCreatePOLineItem 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.PostCreatePOLineItem

@{
   ViewBag.Title = "PostCreatePOLineItem";
}

<h2>PostCreatePOLineItem</h2>
@using (Html.BeginForm()) {
   @Html.AntiForgeryToken()
   @Html.ValidationSummary(true)
   <fieldset>
   <legend>PostCreatePOLineItem</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>
       <div class="editor-label">
           @Html.LabelFor(model => model.buildingCode)
       </div>
       <div class="editor-field">
           @Html.EditorFor(model => model.buildingCode)
           @Html.ValidationMessageFor(model => model.buildingCode)
       </div>
       <div class="editor-label">
           @Html.LabelFor(model => model.poLineNumber)
       </div>
       <div class="editor-field">
           @Html.EditorFor(model => model.poLineNumber)
           @Html.ValidationMessageFor(model => model.poLineNumber)
       </div>
       <div class="editor-label">
           @Html.LabelFor(model => model.commodityCode)
       </div>
       <div class="editor-field">
           @Html.EditorFor(model => model.commodityCode)
           @Html.ValidationMessageFor(model => model.commodityCode)
       </div>
       <div class="editor-label">
           @Html.LabelFor(model => model.subCommodityCode)
       </div>
       <div class="editor-field">
           @Html.EditorFor(model => model.subCommodityCode)
           @Html.ValidationMessageFor(model => model.subCommodityCode)
       </div>
       <div class="editor-label">
           @Html.LabelFor(model => model.itemQuantity)
       </div>
       <div class="editor-field">
           @Html.EditorFor(model => model.itemQuantity)
           @Html.ValidationMessageFor(model => model.itemQuantity)
       </div>
       <div class="editor-label">
           @Html.LabelFor(model => model.itemUnitOfMeasure)
       </div>
       <div class="editor-field">
           @Html.EditorFor(model => model.itemUnitOfMeasure)
           @Html.ValidationMessageFor(model => model.itemUnitOfMeasure)
       </div>
       <div class="editor-label">
           @Html.LabelFor(model => model.itemCost)
       </div>
       <div class="editor-field">
           @Html.EditorFor(model => model.itemCost)
           @Html.ValidationMessageFor(model => model.itemCost)
       </div>
       <div class="editor-label">
           @Html.LabelFor(model => model.returnCredit)
       </div>
       <div class="editor-field">
           @Html.EditorFor(model => model.returnCredit)
           @Html.ValidationMessageFor(model => model.returnCredit)
       </div>
       <div class="editor-label">
           @Html.LabelFor(model => model.itemNumber)
       </div>
       <div class="editor-field">
           @Html.EditorFor(model => model.itemNumber)
           @Html.ValidationMessageFor(model => model.itemNumber)
       </div>
       <div class="editor-label">
           @Html.LabelFor(model => model.itemDesc)
       </div>
       <div class="editor-field">
           @Html.EditorFor(model => model.itemDesc)
           @Html.ValidationMessageFor(model => model.itemDesc)
       </div>
       <div class="editor-label">
           @Html.LabelFor(model => model.accountNumber)
       </div>
       <div class="editor-field">
           @Html.EditorFor(model => model.accountNumber)
           @Html.ValidationMessageFor(model => model.accountNumber)
       </div>
       <div class="editor-label">
           @Html.LabelFor(model => model.projectNumber)
       </div>
       <div class="editor-field">
           @Html.EditorFor(model => model.projectNumber)
           @Html.ValidationMessageFor(model => model.projectNumber)
       </div>
       <div class="editor-label">
           @Html.LabelFor(model => model.fleetCostCode)
       </div>
       <div class="editor-field">
           @Html.EditorFor(model => model.fleetCostCode)
           @Html.ValidationMessageFor(model => model.fleetCostCode)
       </div>
       <div class="editor-label">
           @Html.LabelFor(model => model.fleetEquipNum)
       </div>
       <div class="editor-field">
           @Html.EditorFor(model => model.fleetEquipNum)
           @Html.ValidationMessageFor(model => model.fleetEquipNum)
       </div>
       <div class="editor-label">
           @Html.LabelFor(model => model.fleetJobNum)
       </div>
       <div class="editor-field">
           @Html.EditorFor(model => model.fleetJobNum)
           @Html.ValidationMessageFor(model => model.fleetJobNum)
       </div>
       <div class="editor-label">
           @Html.LabelFor(model => model.fleetJobRepairNum)
       </div>
       <div class="editor-field">
           @Html.EditorFor(model => model.fleetJobRepairNum)
           @Html.ValidationMessageFor(model => model.fleetJobRepairNum)
       </div>
       <div class="editor-label">
           @Html.LabelFor(model => model.fleetWorkOrderNum)
       </div>
       <div class="editor-field">
           @Html.EditorFor(model => model.fleetWorkOrderNum)
           @Html.ValidationMessageFor(model => model.fleetWorkOrderNum)
       </div>
       <div class="editor-label">
           @Html.LabelFor(model => model.fleetWorkOrderJobNum)
       </div>
       <div class="editor-field">
           @Html.EditorFor(model => model.fleetWorkOrderJobNum)
           @Html.ValidationMessageFor(model => model.fleetWorkOrderJobNum)
       </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/PostCreatePOLineItem
public ActionResult PostCreatePOLineItem()
{
   // Create a new instance of the model to pick up any default values.
   PostCreatePOLineItem model =  new PostCreatePOLineItem();

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

// 
// POST: /MyController/PostCreatePOLineItem
[HttpPost]
public ActionResult PostCreatePOLineItem(FormCollection collection)
{
   string url = "v3/Naviline/ProductInventory/CreatePOLineItem";
   // Get the value from each input field
   NameValueCollection inputParms = new NameValueCollection();
   inputParms.Add("action", collection["action"]);
   inputParms.Add("poNumber", collection["poNumber"]);
   inputParms.Add("buildingCode", collection["buildingCode"]);
   inputParms.Add("poLineNumber", collection["poLineNumber"]);
   inputParms.Add("commodityCode", collection["commodityCode"]);
   inputParms.Add("subCommodityCode", collection["subCommodityCode"]);
   inputParms.Add("itemQuantity", collection["itemQuantity"]);
   inputParms.Add("itemUnitOfMeasure", collection["itemUnitOfMeasure"]);
   inputParms.Add("itemCost", collection["itemCost"]);
   inputParms.Add("returnCredit", collection["returnCredit"]);
   inputParms.Add("itemNumber", collection["itemNumber"]);
   inputParms.Add("itemDesc", collection["itemDesc"]);
   inputParms.Add("accountNumber", collection["accountNumber"]);
   inputParms.Add("projectNumber", collection["projectNumber"]);
   inputParms.Add("fleetCostCode", collection["fleetCostCode"]);
   inputParms.Add("fleetEquipNum", collection["fleetEquipNum"]);
   inputParms.Add("fleetJobNum", collection["fleetJobNum"]);
   inputParms.Add("fleetJobRepairNum", collection["fleetJobRepairNum"]);
   inputParms.Add("fleetWorkOrderNum", collection["fleetWorkOrderNum"]);
   inputParms.Add("fleetWorkOrderJobNum", collection["fleetWorkOrderJobNum"]);

   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", "PostCreatePOLineItem");
       return View("Error", info);
   }
}