Set Custom Calc Values
Combine the CustomCalcScreen, CustomCalcSequence, and the entered value into the fieldValues parameter.
Example:
fieldValues of 010100000273481010200000005200010700000000075 =
Screen 01, Field 01, value $2734.81, Screen 01, Field 02, value 52.00, Screen 01, Field 07, value 0.75
The method then returns the entered and calculated values for all of the custom calc fields by screen and sequence number.
Name | Type | Length | Description |
---|---|---|---|
licenseYear | numeric | 2 | [Required] License Year |
licenseNumber | numeric | 8 | [Required] License Number |
licenseClass | System.String | 7 | [Required] License Classification code |
fieldValues | System.String | 1800 | [Required] Field values. See summary |
POST http://localhost/FusionServices/v3/Naviline/OccupationalLicense/CustomCalc
Name | Description |
---|---|
ErrorCode | 00=Success. Note: This only returns 2 digits for the error code |
ErrorMessage | Message returned with error code |
Description | Field label |
Screen | Field screen number |
Sequence | Field sequence number |
Amount | Field Amount |
TotalDue | Total Due Amount |
using System.Net;
using Newtonsoft.Json.Linq;
public void MethodName(parms)
{
string uri = "http://localhost/FusionServices/v3/Naviline/OccupationalLicense/CustomCalc";
System.Collections.Specialized.NameValueCollection postParms =
new System.Collections.Specialized.NameValueCollection();
// Set paramater values
postParms.Add("licenseYear",System.Web.HttpUtility.UrlEncode("89"));
postParms.Add("licenseNumber",System.Web.HttpUtility.UrlEncode("74"));
postParms.Add("licenseClass",System.Web.HttpUtility.UrlEncode("134"));
postParms.Add("fieldValues",System.Web.HttpUtility.UrlEncode("010100000273481010200000005200010700000000075"));
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")
{
JArray jRows = (JArray)response["Rows"];
foreach (JObject row in jRows)
{
string Description = row["Description"].ToString();
string Screen = row["Screen"].ToString();
string Sequence = row["Sequence"].ToString();
string Amount = row["Amount"].ToString();
// TODO - YOUR CODE HERE
}
}
}
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 PostCustomCalcs
{
// Add property for each input param in order to map a field to it
[Required(ErrorMessage = "Required")]
[RegularExpression("[0-9]{0,2}", ErrorMessage = "Numeric values only. Must be 2 digits or less. ")]
public string licenseYear{get; set;}
[Required(ErrorMessage = "Required")]
[RegularExpression("[0-9]{0,8}", ErrorMessage = "Numeric values only. Must be 8 digits or less. ")]
public string licenseNumber{get; set;}
[Required(ErrorMessage = "Required")]
[RegularExpression("^(?=.{0,7}$).*", ErrorMessage = "Must be 7 characters or less. ")]
public string licenseClass{get; set;}
[Required(ErrorMessage = "Required")]
[RegularExpression("^(?=.{0,1800}$).*", ErrorMessage = "Must be 1800 characters or less. ")]
public string fieldValues{get; set;}
public PostCustomCalcs()
{
//Set any defaults here
}
}
}
@* NOTE: Use Add->View to add the View. *@
@* NOTE: Check the 'Create strongly-typed view checkbox, and select the PostCustomCalcs 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.PostCustomCalcs
@{
ViewBag.Title = "PostCustomCalcs";
}
<h2>PostCustomCalcs</h2>
@using (Html.BeginForm()) {
@Html.AntiForgeryToken()
@Html.ValidationSummary(true)
<fieldset>
<legend>PostCustomCalcs</legend>
<div class="editor-label">
@Html.LabelFor(model => model.licenseYear)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.licenseYear)
@Html.ValidationMessageFor(model => model.licenseYear)
</div>
<div class="editor-label">
@Html.LabelFor(model => model.licenseNumber)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.licenseNumber)
@Html.ValidationMessageFor(model => model.licenseNumber)
</div>
<div class="editor-label">
@Html.LabelFor(model => model.licenseClass)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.licenseClass)
@Html.ValidationMessageFor(model => model.licenseClass)
</div>
<div class="editor-label">
@Html.LabelFor(model => model.fieldValues)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.fieldValues)
@Html.ValidationMessageFor(model => model.fieldValues)
</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/PostCustomCalcs
public ActionResult PostCustomCalcs()
{
// Create a new instance of the model to pick up any default values.
PostCustomCalcs model = new PostCustomCalcs();
// pass model to set to default values
// NOTE: Change 'MyFolderPath' to the path to the .cshtml file.
return View("~/Views/MyFolderPath/PostCustomCalcs.cshtml", model);
}
//
// POST: /MyController/PostCustomCalcs
[HttpPost]
public ActionResult PostCustomCalcs(FormCollection collection)
{
string url = "v3/Naviline/OccupationalLicense/CustomCalc";
// Get the value from each input field
NameValueCollection inputParms = new NameValueCollection();
inputParms.Add("licenseYear", collection["licenseYear"]);
inputParms.Add("licenseNumber", collection["licenseNumber"]);
inputParms.Add("licenseClass", collection["licenseClass"]);
inputParms.Add("fieldValues", collection["fieldValues"]);
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", "PostCustomCalcs");
return View("Error", info);
}
}