Mashup example providing quick access to a range of Employee related screens. Employee selection filter is at the top. When an employee records is clicked the data is passed to the screens below.
Full source code available here: EmployeeMaintenance
Mashup example providing quick access to a range of Employee related screens. Employee selection filter is at the top. When an employee records is clicked the data is passed to the screens below.
Full source code available here: EmployeeMaintenance
During this past Inforum event we mocked up a number of Mashups with customers interested in Mashup Designer. One of the ideas was figuring out some way to better combine the Item Master (IC11) screen with Item Location (IC12). Based on the quick designs that were tossed around in the Lab the following Mashup was developed using Mashup Designer.
In this Mashup the user is provided a list which can be used to filter and locate a specific item. When clicked, both the Item Master and Item Location screens are populated. Global actions are located in the top left which allow the user to process both forms simultaneously. Additional item information is located in a separate tab which includes some basic analysis for Stock on Hand, Allocatable quantities and Cost Details.
This video provides a high level demonstration. Source for this Mashup is also found below. This Mashup was built in Smart Office version 10.1.
Full source is available here: ItemMasterAndLocation
One of the questions that came up at Inforum last week was how to open a Widget from a Canvas Shortcut. To do so all you need is the Widget Name. For example, I have a widget called LM Leases. Here is what that looks like within Predefined Widgets:
Although in this case all the Names are the same as the Widget ID, we are going to use the name and create a shortcut with a URL like this:
widget://add/?Scheme=LM Leases
Example mashup providing quick access to Employees filtered by Position. A list of Positions is provided at the top which can be filtered. When a position is clicked the corresponding employees are listed in a list below. If a specific employee is clicked their information in HR11 is displayed to the right.
Full source code available here: EmployeesByPosition
The following example utilizes Smart Office scripting to hook into the AfterTransaction event to display the corresponding Vendor balance. Not a very complicated script. Basically a new label added to the header of the form and a custom Data Query function to gather values from the form and fetch the balance, which is then sent to the new label.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 | //----------------------------------------------------------------------------- // JScript Example // Created by: Josh Geving - Innovations Group // // Description: Example script to fetch a vendor balance from APVENBAL // // Notice: VBASET2 is being used as the index which is Vendor Group // and Vendor, depending on yous situation you may choose to // change the code below and use VBASET1 which includes // Company // // // Last Tested on Smart Office Version 10.1.0.38 //----------------------------------------------------------------------------- import System; import System.Windows; import System.Windows.Controls; import S3.Client.Forms; package S3.Client.Forms.JScript { class JjgAp10Balance { var console, form, formGrid; public function Init(element: Object, args: Object, controller: Object, debug: Object) { try { form = controller; formGrid = form.FormGrid; console = debug; // TODO Add your code here // add a lable to display the vendor balance var label = ControlsUtil.AddCustomLabel(form, formGrid, "lblBalance", 1, 60, 10, ""); // hook into the AfterTransaction event form.add_AfterTransaction(OnAfterTransaction); form.add_BeforeUnload(OnBeforeUnload); } catch (e) { console.WriteLine(ScriptUtil.FormatException("Init", e)); } } // event handlers public function OnBeforeUnload(sender: Object, e: FormEventArgs) { // perform cleanup // remove the hook for AfterTransaction form.remove_AfterTransaction(OnAfterTransaction); form.remove_BeforeUnload(OnBeforeUnload); } // AfterTransaction Event public function OnAfterTransaction(sender: Object, e: TransactionEventArgs) { // variable for balance var vBalance = RunDataMine(); // set the value of the custom label to the balance found form.SetCustomElementValue("lblBalance", vBalance); } private function RunDataMine() { //OUT=XML&MAX=100&PROD=APPS901&FILE=APVENBAL&INDEX=VBASET2&KEY=1=1&FIELD=CURRENT-BAL; //gather form variables from the transaction var vVendorGroup = form.GetTransactionValue("VEN-VENDOR-GROUP"); var vVendor = form.GetTransactionValue("VEN-VENDOR").Trim(); // build up the Data Service call var sProd = form.GetUserAttribute("productline"); var sFile = "APVENBAL"; var sField = "CURRENT-BAL"; var sIndex = "VBASET2&KEY="+vVendorGroup+"="+vVendor+""; var sCond = ""; var sSelect = ""; var sMax = ""; // Pass the variables for the API to DataService_Execute var aDataAPI = DataService_Execute(sProd,sFile, sField, sIndex, sCond, sSelect, sMax); console.WriteLine("aDataAPI.length: " + aDataAPI.length); // Did we get anything back from the call? if(aDataAPI.length > 0) { var i = 0; for(i = 0; i < aDataAPI.length; i++) { console.WriteLine(aDataAPI[i]); return aDataAPI[i]; } } else{ console.WriteLine("***No Records***"); return "No Balance"; } } // private functions /** * DataService_Execute - This method returns an array for the api specified * Detail description * This method returns an array of values for for the api details * @param required sProd, PROD, defaults to user profile if not set - required * @param required sFile, FILE * @param required sField, FIELD * @param optional sIndex, INDEX, removed from api if not set * @param optional sCond, COND * @param optional sSelect, SELECT * @param optional sMax, MAX, defaults to 0 if not set * @access private * @return array * * Example: * * private function RunDataMine() { //OUT=XML&MAX=100&PROD=APPS901&FILE=APVENBAL&INDEX=VBASET2&KEY=1=1&FIELD=CURRENT-BAL; //gather form variables from the transaction var vVendorGroup = form.GetTransactionValue("VEN-VENDOR-GROUP"); var vVendor = form.GetTransactionValue("VEN-VENDOR").Trim(); // build up the Data Service call var sProd = form.GetUserAttribute("productline"); var sFile = "APVENBAL"; var sField = "CURRENT-BAL"; var sIndex = "VBASET2&KEY="+vVendorGroup+"="+vVendor+""; var sCond = ""; var sSelect = ""; var sMax = ""; // Pass the variables for the API to DataService_Execute var aDataAPI = DataService_Execute(sProd,sFile, sField, sIndex, sCond, sSelect, sMax); console.WriteLine("aDataAPI.length: " + aDataAPI.length); // Did we get anything back from the call? if(aDataAPI.length > 0) { var i = 0; for(i = 0; i < aDataAPI.length; i++) { console.WriteLine(aDataAPI[i]); return aDataAPI[i]; } } else{ console.WriteLine("***No Records***"); return "No Balance"; } } */ private function DataService_Execute(sProd,sFile, sField, sIndex, sCond, sSelect, sMax) { var a = new Array(); var aFields = new Array(); var i = 0; var s = ""; var oXML; var oRecs; var oRecNum; var oRec; var oFields; // Productline sProd empty, set from profile if(sProd == ""){sProd = form.GetUserAttribute("productline");} // Max sMax empty, set to 0 for all if(sMax == ""){sMax = 0;} // Build the complete Data Service Call s = ScriptConstants.DataMinePath + "?PROD=" + sProd + "&FILE=" + sFile + "&FIELD=" + sField; // If Index we add Index to the call if(sIndex != ""){s += "&INDEX=" + sIndex;} // The rest of the call s += "&COND=" + sCond + "&SELECT=" + sSelect + "&MAX=" + sMax + "&OUT=XML&DELIM="+ new Date().getTime(); // Time used to prevent caching console.WriteLine("s: " + s); // Make the server request, record the time it took var bTime = new Date().getTime(); oXML = ScriptUtil.ServerRequest(s); var eTime = new Date().getTime(); console.WriteLine("API Execution Time: " + (eTime-bTime)/1000 + "seconds"); // Get the Record Count Node oRecs = oXML.SelectSingleNode("//RECORDS"); oRecNum = oRecs != null ? oRecs.ChildNodes.Count : 0; console.WriteLine("oRecNum: " +oRecNum); // Determine if records were returned if(oRecNum == 0) { console.WriteLine("Data Service Call\n\n" + s + "\n\n returned " + oRecNum + " records."); return a; } // Build an array with the results for(oRec in oRecs.ChildNodes) { oFields = oRec.SelectSingleNode("./COLS"); aFields = new Array(); for(i = 0; i < oFields.ChildNodes.Count; i++) { aFields[aFields.length] = oFields.ChildNodes[i].InnerText; } a[a.length] = aFields; } return a; } } } |
//-----------------------------------------------------------------------------
// JScript Example
// Created by: Josh Geving - Innovations Group
//
// Description: Example script to fetch a vendor balance from APVENBAL
//
// Notice: VBASET2 is being used as the index which is Vendor Group
// and Vendor, depending on yous situation you may choose to
// change the code below and use VBASET1 which includes
// Company
//
//
// Last Tested on Smart Office Version 10.1.0.38
//-----------------------------------------------------------------------------
import System;
import System.Windows;
import System.Windows.Controls;
import S3.Client.Forms;
package S3.Client.Forms.JScript {
class JjgAp10Balance
{
var console, form, formGrid;
public function Init(element: Object, args: Object, controller: Object, debug: Object)
{
try {
form = controller;
formGrid = form.FormGrid;
console = debug;
// TODO Add your code here
// add a lable to display the vendor balance
var label = ControlsUtil.AddCustomLabel(form, formGrid, "lblBalance", 1, 60, 10, "");
// hook into the AfterTransaction event
form.add_AfterTransaction(OnAfterTransaction);
form.add_BeforeUnload(OnBeforeUnload);
} catch (e) {
console.WriteLine(ScriptUtil.FormatException("Init", e));
}
}
// event handlers
public function OnBeforeUnload(sender: Object, e: FormEventArgs)
{
// perform cleanup
// remove the hook for AfterTransaction
form.remove_AfterTransaction(OnAfterTransaction);
form.remove_BeforeUnload(OnBeforeUnload);
}
// AfterTransaction Event
public function OnAfterTransaction(sender: Object, e: TransactionEventArgs)
{
// variable for balance
var vBalance = RunDataMine();
// set the value of the custom label to the balance found
form.SetCustomElementValue("lblBalance", vBalance);
}
private function RunDataMine()
{
//OUT=XML&MAX=100&PROD=APPS901&FILE=APVENBAL&INDEX=VBASET2&KEY=1=1&FIELD=CURRENT-BAL;
//gather form variables from the transaction
var vVendorGroup = form.GetTransactionValue("VEN-VENDOR-GROUP");
var vVendor = form.GetTransactionValue("VEN-VENDOR").Trim();
// build up the Data Service call
var sProd = form.GetUserAttribute("productline");
var sFile = "APVENBAL";
var sField = "CURRENT-BAL";
var sIndex = "VBASET2&KEY="+vVendorGroup+"="+vVendor+"";
var sCond = "";
var sSelect = "";
var sMax = "";
// Pass the variables for the API to DataService_Execute
var aDataAPI = DataService_Execute(sProd,sFile, sField, sIndex, sCond, sSelect, sMax);
console.WriteLine("aDataAPI.length: " + aDataAPI.length);
// Did we get anything back from the call?
if(aDataAPI.length > 0)
{
var i = 0;
for(i = 0; i < aDataAPI.length; i++)
{
console.WriteLine(aDataAPI[i]);
return aDataAPI[i];
}
}
else{
console.WriteLine("***No Records***");
return "No Balance";
}
}
// private functions
/**
* DataService_Execute - This method returns an array for the api specified
* Detail description
* This method returns an array of values for for the api details
* @param required sProd, PROD, defaults to user profile if not set - required
* @param required sFile, FILE
* @param required sField, FIELD
* @param optional sIndex, INDEX, removed from api if not set
* @param optional sCond, COND
* @param optional sSelect, SELECT
* @param optional sMax, MAX, defaults to 0 if not set
* @access private
* @return array
*
* Example:
*
*
private function RunDataMine()
{
//OUT=XML&MAX=100&PROD=APPS901&FILE=APVENBAL&INDEX=VBASET2&KEY=1=1&FIELD=CURRENT-BAL;
//gather form variables from the transaction
var vVendorGroup = form.GetTransactionValue("VEN-VENDOR-GROUP");
var vVendor = form.GetTransactionValue("VEN-VENDOR").Trim();
// build up the Data Service call
var sProd = form.GetUserAttribute("productline");
var sFile = "APVENBAL";
var sField = "CURRENT-BAL";
var sIndex = "VBASET2&KEY="+vVendorGroup+"="+vVendor+"";
var sCond = "";
var sSelect = "";
var sMax = "";
// Pass the variables for the API to DataService_Execute
var aDataAPI = DataService_Execute(sProd,sFile, sField, sIndex, sCond, sSelect, sMax);
console.WriteLine("aDataAPI.length: " + aDataAPI.length);
// Did we get anything back from the call?
if(aDataAPI.length > 0)
{
var i = 0;
for(i = 0; i < aDataAPI.length; i++)
{
console.WriteLine(aDataAPI[i]);
return aDataAPI[i];
}
}
else{
console.WriteLine("***No Records***");
return "No Balance";
}
}
*/
private function DataService_Execute(sProd,sFile, sField, sIndex, sCond, sSelect, sMax)
{
var a = new Array();
var aFields = new Array();
var i = 0;
var s = "";
var oXML;
var oRecs;
var oRecNum;
var oRec;
var oFields;
// Productline sProd empty, set from profile
if(sProd == ""){sProd = form.GetUserAttribute("productline");}
// Max sMax empty, set to 0 for all
if(sMax == ""){sMax = 0;}
// Build the complete Data Service Call
s = ScriptConstants.DataMinePath + "?PROD=" + sProd + "&FILE=" + sFile + "&FIELD=" + sField;
// If Index we add Index to the call
if(sIndex != ""){s += "&INDEX=" + sIndex;}
// The rest of the call
s += "&COND=" + sCond + "&SELECT=" + sSelect + "&MAX=" + sMax +
"&OUT=XML&DELIM="+ new Date().getTime(); // Time used to prevent caching
console.WriteLine("s: " + s);
// Make the server request, record the time it took
var bTime = new Date().getTime();
oXML = ScriptUtil.ServerRequest(s);
var eTime = new Date().getTime();
console.WriteLine("API Execution Time: " + (eTime-bTime)/1000 + "seconds");
// Get the Record Count Node
oRecs = oXML.SelectSingleNode("//RECORDS");
oRecNum = oRecs != null ? oRecs.ChildNodes.Count : 0;
console.WriteLine("oRecNum: " +oRecNum);
// Determine if records were returned
if(oRecNum == 0)
{
console.WriteLine("Data Service Call\n\n" + s + "\n\n returned " + oRecNum + " records.");
return a;
}
// Build an array with the results
for(oRec in oRecs.ChildNodes)
{
oFields = oRec.SelectSingleNode("./COLS");
aFields = new Array();
for(i = 0; i < oFields.ChildNodes.Count; i++)
{
aFields[aFields.length] = oFields.ChildNodes[i].InnerText;
}
a[a.length] = aFields;
}
return a;
}
} }I had a few requests within the same week to create a Mashup that employees could use inside Smart Office to access the Self-Service applications which are browser applications.
This can be done various ways, one of the easiest being to provide a set of Favorites. But the Mashup was the preferred route.
Below you will find the completed Xaml code. There are only a few interesting parts to note:
1) Notice the use of the <<HttpServer>> constant. This is a value understood by the Mashup and allows you to move this around from server to server and avoid using a hard-coded value.
1 | <mashup:NavigationTreeMember Level="1" Label="Reg by Course" Uri="<<HttpServer>>/lawson/xhrnet/registrationbycourse.htm" /> |
<mashup:NavigationTreeMember Level="1" Label="Reg by Course" Uri="<<HttpServer>>/lawson/xhrnet/registrationbycourse.htm" />
2) The Column and Row where the NetBrowser control resides are both set to 1* and not Auto. This allows the web page to fit nicely inside the Mashup and take up all of the existing space.
Here is the completed Xaml.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 | <!-- Employee Self-Service example mashup developed by Josh Geving --> <Grid xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:ui="clr-namespace:Mango.UI.Controls;assembly=Mango.UI" xmlns:mashup="clr-namespace:Mango.UI.Services.Mashup;assembly=Mango.UI"> <Grid.Resources> </Grid.Resources> <Grid.ColumnDefinitions> <ColumnDefinition Width="200" /> <ColumnDefinition Width="Auto" /> <ColumnDefinition Width="1*" /> </Grid.ColumnDefinitions> <Grid.RowDefinitions> <RowDefinition Height="40" /> <RowDefinition Height="1*" /> </Grid.RowDefinitions> <!-- An example of an optional menu bar, could be removed if no menu bar will be used --> <!-- <StackPanel Grid.Row="0" Grid.Column="0" Orientation="Horizontal" HorizontalAlignment="Stretch" Height="40" Style="{DynamicResource styleBackgroundApplicationBarMashup}"> <Menu> <MenuItem Header="_File"> <MenuItem Header="_New" /> <Separator /> <MenuItem Header="_Save" /> </MenuItem> </Menu> </StackPanel> --> <mashup:NavigationTree Name="NavTree" Grid.Column="0" Grid.Row="1"> <mashup:NavigationTree.Members> <mashup:NavigationTreeMembers> <mashup:NavigationTreeMember Level="0" Label="Credentials"> <mashup:NavigationTreeMember.Members> <mashup:NavigationTreeMembers> <mashup:NavigationTreeMember Level="1" Label="Career Management" Uri="<<HttpServer>>/lawson/xhrnet/careermanagement/employee/mainWinCheesecake.htm" /> <mashup:NavigationTreeMember Level="1" Label="Competency Profile" Uri="<<HttpServer>>/lawson/xhrnet/credentials/ecpmain.htm" /> <mashup:NavigationTreeMember Level="1" Label="Contract Balances" Uri="<<HttpServer>>/lawson/xhrnet/contractbalances.htm" /> <mashup:NavigationTreeMember Level="1" Label="Professional Profile" Uri="<<HttpServer>>/lawson/xhrnet/credentials/pp.htm" /> </mashup:NavigationTreeMembers> </mashup:NavigationTreeMember.Members> </mashup:NavigationTreeMember> <mashup:NavigationTreeMember Level="0" Label="Employment"> <mashup:NavigationTreeMember.Members> <mashup:NavigationTreeMembers> <mashup:NavigationTreeMember Level="1" Label="Job Postings" Uri="<<HttpServer>>/lawson/xhrnet/pajobreq.htm" /> <mashup:NavigationTreeMember Level="1" Label="Job Profile" Uri="<<HttpServer>>/lawson/xhrnet/jobprofile.htm" /> <mashup:NavigationTreeMember Level="1" Label="Jobs Applied For" Uri="<<HttpServer>>/lawson/xhrnet/pareqapp.htm" /> <mashup:NavigationTreeMember Level="1" Label="Phone Book" Uri="<<HttpServer>>/lawson/xhrnet/phonebook.htm" /> <mashup:NavigationTreeMember Level="1" Label="Policy Manual" Uri="<<HttpServer>>/lawson/xhrnet/policybook.htm" /> <mashup:NavigationTreeMember Level="1" Label="ReviewHistory" Uri="<<HttpServer>>/lawson/xhrnet/reviewhist.htm" /> <mashup:NavigationTreeMember Level="1" Label="Work Phone" Uri="<<HttpServer>>/lawson/xhrnet/empphone.htm" /> </mashup:NavigationTreeMembers> </mashup:NavigationTreeMember.Members> </mashup:NavigationTreeMember> <mashup:NavigationTreeMember Level="0" Label="Life Events"> <mashup:NavigationTreeMember.Members> <mashup:NavigationTreeMembers> <mashup:NavigationTreeMember Level="1" Label="Life Events" Uri="<<HttpServer>>/lawson/xhrnet/lifeevents_splash.htm" /> <mashup:NavigationTreeMember Level="1" Label="Adoption" Uri="<<HttpServer>>/lawson/xhrnet/adoption.htm" /> <mashup:NavigationTreeMember Level="1" Label="Birth" Uri="<<HttpServer>>/lawson/xhrnet/birth.htm" /> <mashup:NavigationTreeMember Level="1" Label="Divorce" Uri="<<HttpServer>>/lawson/xhrnet/divorce.htm" /> <mashup:NavigationTreeMember Level="1" Label="Legal Separation" Uri="<<HttpServer>>/lawson/xhrnet/legalsep.htm" /> <mashup:NavigationTreeMember Level="1" Label="Marriage" Uri="<<HttpServer>>/lawson/xhrnet/marriage.htm" /> <mashup:NavigationTreeMember Level="1" Label="Move" Uri="<<HttpServer>>/lawson/xhrnet/homeaddress.htm?from=lifeevents" /> <mashup:NavigationTreeMember Level="1" Label="Spouse Employment" Uri="<<HttpServer>>/lawson/xhrnet/spouseemployment.htm" /> </mashup:NavigationTreeMembers> </mashup:NavigationTreeMember.Members> </mashup:NavigationTreeMember> <mashup:NavigationTreeMember Level="0" Label="Pay"> <mashup:NavigationTreeMember.Members> <mashup:NavigationTreeMembers> <mashup:NavigationTreeMember Level="1" Label="Direct Deposit" Uri="<<HttpServer>>/lawson/xhrnet/directdeposit/ddmain.htm" /> <mashup:NavigationTreeMember Level="1" Label="Org Chart" Uri="<<HttpServer>>/lawson/xhrnet/orgchart.htm" /> <mashup:NavigationTreeMember Level="1" Label="Pay Checks" Uri="<<HttpServer>>/lawson/xhrnet/paychecks.htm" /> <mashup:NavigationTreeMember Level="1" Label="Pay Rate History" Uri="<<HttpServer>>/lawson/xhrnet/payratehistory.htm" /> <mashup:NavigationTreeMember Level="1" Label="Payment Modeling" Uri="<<HttpServer>>/lawson/xhrnet/paymentmodeling.htm" /> <mashup:NavigationTreeMember Level="1" Label="Tax Withholding" Uri="<<HttpServer>>/lawson/xhrnet/w4/taxwithholding.htm" /> <mashup:NavigationTreeMember Level="1" Label="Year To Date" Uri="<<HttpServer>>/lawson/xhrnet/yeartodate.htm" /> </mashup:NavigationTreeMembers> </mashup:NavigationTreeMember.Members> </mashup:NavigationTreeMember> <mashup:NavigationTreeMember Level="0" Label="Personal Info"> <mashup:NavigationTreeMember.Members> <mashup:NavigationTreeMembers> <mashup:NavigationTreeMember Level="1" Label="Certifications" Uri="<<HttpServer>>/lawson/xhrnet/qualifications.htm?type=crt" /> <mashup:NavigationTreeMember Level="1" Label="Competencies" Uri="<<HttpServer>>/lawson/xhrnet/qualifications.htm?type=cmp" /> <mashup:NavigationTreeMember Level="1" Label="Dependents" Uri="<<HttpServer>>/lawson/xhrnet/dependentsmain.htm" /> <mashup:NavigationTreeMember Level="1" Label="Education" Uri="<<HttpServer>>/lawson/xhrnet/qualifications.htm?type=edu" /> <mashup:NavigationTreeMember Level="1" Label="Emergency" Uri="<<HttpServer>>/lawson/xhrnet/emergencycontacts.htm" /> <mashup:NavigationTreeMember Level="1" Label="Ethnicity" Uri="<<HttpServer>>/lawson/xhrnet/ethnicity.htm" /> <mashup:NavigationTreeMember Level="1" Label="Leave Balances" Uri="<<HttpServer>>/lawson/xhrnet/leavebalancebegin.htm" /> <mashup:NavigationTreeMember Level="1" Label="Marital Status" Uri="<<HttpServer>>/lawson/xhrnet/maritalstatus.htm" /> <mashup:NavigationTreeMember Level="1" Label="Military Status" Uri="<<HttpServer>>/lawson/xhrnet/military.htm" /> <mashup:NavigationTreeMember Level="1" Label="Nickname" Uri="<<HttpServer>>/lawson/xhrnet/nickname.htm" /> <mashup:NavigationTreeMember Level="1" Label="Personal Profile" Uri="<<HttpServer>>/lawson/xhrnet/emppersonal.htm" /> <mashup:NavigationTreeMember Level="1" Label="Veteran Status" Uri="<<HttpServer>>/lawson/xhrnet/veteran.htm" /> </mashup:NavigationTreeMembers> </mashup:NavigationTreeMember.Members> </mashup:NavigationTreeMember> <mashup:NavigationTreeMember Level="0" Label="Time Entry"> <mashup:NavigationTreeMember.Members> <mashup:NavigationTreeMembers> <mashup:NavigationTreeMember Level="1" Label="Daily" Uri="<<HttpServer>>/lawson/xhrnet/timeentry/employee/timeentry.htm?type=daily" /> <mashup:NavigationTreeMember Level="1" Label="Exception Entry" Uri="<<HttpServer>>/lawson/xhrnet/timeentry/exception/exception.htm" /> <mashup:NavigationTreeMember Level="1" Label="Period Entry" Uri="<<HttpServer>>/lawson/xhrnet/timeentry/employee/timeentry.htm" /> <mashup:NavigationTreeMember Level="1" Label="Print Time Entry" Uri="<<HttpServer>>/lawson/xhrnet/timeentry/employee/printtime.htm" /> </mashup:NavigationTreeMembers> </mashup:NavigationTreeMember.Members> </mashup:NavigationTreeMember> <mashup:NavigationTreeMember Level="0" Label="Training"> <mashup:NavigationTreeMember.Members> <mashup:NavigationTreeMembers> <mashup:NavigationTreeMember Level="1" Label="Reg by Category" Uri="<<HttpServer>>/lawson/xhrnet/registrationbycategory.htm" /> <mashup:NavigationTreeMember Level="1" Label="Reg by Course" Uri="<<HttpServer>>/lawson/xhrnet/registrationbycourse.htm" /> <mashup:NavigationTreeMember Level="1" Label="Reg by Tracks" Uri="<<HttpServer>>/lawson/xhrnet/registrationbytrack.htm" /> <mashup:NavigationTreeMember Level="1" Label="Required Training" Uri="<<HttpServer>>/lawson/xhrnet/patrnreq.htm" /> <mashup:NavigationTreeMember Level="1" Label="Scheduled Training" Uri="<<HttpServer>>/lawson/xhrnet/paregister.htm" /> <mashup:NavigationTreeMember Level="1" Label="Training History" Uri="<<HttpServer>>/lawson/xhrnet/patrnhist.htm" /> </mashup:NavigationTreeMembers> </mashup:NavigationTreeMember.Members> </mashup:NavigationTreeMember> <mashup:NavigationTreeMember Level="0" Label="Retirement"> <mashup:NavigationTreeMember.Members> <mashup:NavigationTreeMembers> <mashup:NavigationTreeMember Level="1" Label="Stock Options" Uri="<<HttpServer>>/lawson/xhrnet/stockoptions/employee/shr064.htm" /> <mashup:NavigationTreeMember Level="1" Label="Savings Modeling" Uri="<<HttpServer>>/lawson/xhrnet/401k/401k.htm" /> <mashup:NavigationTreeMember Level="1" Label="Goal View" Uri="<<HttpServer>>/lawson/xhrnet/goalmanagementemployee.html" /> </mashup:NavigationTreeMembers> </mashup:NavigationTreeMember.Members> </mashup:NavigationTreeMember> </mashup:NavigationTreeMembers> </mashup:NavigationTree.Members> </mashup:NavigationTree> <mashup:NetBrowser Name="NetBrowser" Grid.Column="2" StartUri="http://go2.infor.com/brand/images/logo_animation.gif" Margin="5" Grid.Row="1"> <mashup:NetBrowser.Events> <mashup:Events> <mashup:Event SourceName="NavTree" TargetName="NetBrowser" SourceEventName="CurrentItemChanged" TargetEventName="Navigate" Activate="NetBrowser"> <mashup:Parameter SourceKey="Uri" TargetKey="Uri" /> </mashup:Event> </mashup:Events> </mashup:NetBrowser.Events> </mashup:NetBrowser> <GridSplitter Name="Splitter" Style="{DynamicResource styleGridSplitterVerticalMashup}" Grid.Column="1" Grid.Row="1" /> <Label Name="TitleLabel" Content="Employee Self-Service" Style="{DynamicResource styleGroupBoxHeaderMashup}" Margin="5" /> </Grid> |
<!--
Employee Self-Service example mashup developed by Josh Geving
-->
<Grid xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:ui="clr-namespace:Mango.UI.Controls;assembly=Mango.UI" xmlns:mashup="clr-namespace:Mango.UI.Services.Mashup;assembly=Mango.UI">
<Grid.Resources>
</Grid.Resources>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="200" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="1*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="40" />
<RowDefinition Height="1*" />
</Grid.RowDefinitions>
<!-- An example of an optional menu bar, could be removed if no menu bar will be used -->
<!--
<StackPanel Grid.Row="0" Grid.Column="0" Orientation="Horizontal" HorizontalAlignment="Stretch" Height="40"
Style="{DynamicResource styleBackgroundApplicationBarMashup}">
<Menu>
<MenuItem Header="_File">
<MenuItem Header="_New" />
<Separator />
<MenuItem Header="_Save" />
</MenuItem>
</Menu>
</StackPanel>
-->
<mashup:NavigationTree Name="NavTree" Grid.Column="0" Grid.Row="1">
<mashup:NavigationTree.Members>
<mashup:NavigationTreeMembers>
<mashup:NavigationTreeMember Level="0" Label="Credentials">
<mashup:NavigationTreeMember.Members>
<mashup:NavigationTreeMembers>
<mashup:NavigationTreeMember Level="1" Label="Career Management" Uri="<<HttpServer>>/lawson/xhrnet/careermanagement/employee/mainWinCheesecake.htm" />
<mashup:NavigationTreeMember Level="1" Label="Competency Profile" Uri="<<HttpServer>>/lawson/xhrnet/credentials/ecpmain.htm" />
<mashup:NavigationTreeMember Level="1" Label="Contract Balances" Uri="<<HttpServer>>/lawson/xhrnet/contractbalances.htm" />
<mashup:NavigationTreeMember Level="1" Label="Professional Profile" Uri="<<HttpServer>>/lawson/xhrnet/credentials/pp.htm" />
</mashup:NavigationTreeMembers>
</mashup:NavigationTreeMember.Members>
</mashup:NavigationTreeMember>
<mashup:NavigationTreeMember Level="0" Label="Employment">
<mashup:NavigationTreeMember.Members>
<mashup:NavigationTreeMembers>
<mashup:NavigationTreeMember Level="1" Label="Job Postings" Uri="<<HttpServer>>/lawson/xhrnet/pajobreq.htm" />
<mashup:NavigationTreeMember Level="1" Label="Job Profile" Uri="<<HttpServer>>/lawson/xhrnet/jobprofile.htm" />
<mashup:NavigationTreeMember Level="1" Label="Jobs Applied For" Uri="<<HttpServer>>/lawson/xhrnet/pareqapp.htm" />
<mashup:NavigationTreeMember Level="1" Label="Phone Book" Uri="<<HttpServer>>/lawson/xhrnet/phonebook.htm" />
<mashup:NavigationTreeMember Level="1" Label="Policy Manual" Uri="<<HttpServer>>/lawson/xhrnet/policybook.htm" />
<mashup:NavigationTreeMember Level="1" Label="ReviewHistory" Uri="<<HttpServer>>/lawson/xhrnet/reviewhist.htm" />
<mashup:NavigationTreeMember Level="1" Label="Work Phone" Uri="<<HttpServer>>/lawson/xhrnet/empphone.htm" />
</mashup:NavigationTreeMembers>
</mashup:NavigationTreeMember.Members>
</mashup:NavigationTreeMember>
<mashup:NavigationTreeMember Level="0" Label="Life Events">
<mashup:NavigationTreeMember.Members>
<mashup:NavigationTreeMembers>
<mashup:NavigationTreeMember Level="1" Label="Life Events" Uri="<<HttpServer>>/lawson/xhrnet/lifeevents_splash.htm" />
<mashup:NavigationTreeMember Level="1" Label="Adoption" Uri="<<HttpServer>>/lawson/xhrnet/adoption.htm" />
<mashup:NavigationTreeMember Level="1" Label="Birth" Uri="<<HttpServer>>/lawson/xhrnet/birth.htm" />
<mashup:NavigationTreeMember Level="1" Label="Divorce" Uri="<<HttpServer>>/lawson/xhrnet/divorce.htm" />
<mashup:NavigationTreeMember Level="1" Label="Legal Separation" Uri="<<HttpServer>>/lawson/xhrnet/legalsep.htm" />
<mashup:NavigationTreeMember Level="1" Label="Marriage" Uri="<<HttpServer>>/lawson/xhrnet/marriage.htm" />
<mashup:NavigationTreeMember Level="1" Label="Move" Uri="<<HttpServer>>/lawson/xhrnet/homeaddress.htm?from=lifeevents" />
<mashup:NavigationTreeMember Level="1" Label="Spouse Employment" Uri="<<HttpServer>>/lawson/xhrnet/spouseemployment.htm" />
</mashup:NavigationTreeMembers>
</mashup:NavigationTreeMember.Members>
</mashup:NavigationTreeMember>
<mashup:NavigationTreeMember Level="0" Label="Pay">
<mashup:NavigationTreeMember.Members>
<mashup:NavigationTreeMembers>
<mashup:NavigationTreeMember Level="1" Label="Direct Deposit" Uri="<<HttpServer>>/lawson/xhrnet/directdeposit/ddmain.htm" />
<mashup:NavigationTreeMember Level="1" Label="Org Chart" Uri="<<HttpServer>>/lawson/xhrnet/orgchart.htm" />
<mashup:NavigationTreeMember Level="1" Label="Pay Checks" Uri="<<HttpServer>>/lawson/xhrnet/paychecks.htm" />
<mashup:NavigationTreeMember Level="1" Label="Pay Rate History" Uri="<<HttpServer>>/lawson/xhrnet/payratehistory.htm" />
<mashup:NavigationTreeMember Level="1" Label="Payment Modeling" Uri="<<HttpServer>>/lawson/xhrnet/paymentmodeling.htm" />
<mashup:NavigationTreeMember Level="1" Label="Tax Withholding" Uri="<<HttpServer>>/lawson/xhrnet/w4/taxwithholding.htm" />
<mashup:NavigationTreeMember Level="1" Label="Year To Date" Uri="<<HttpServer>>/lawson/xhrnet/yeartodate.htm" />
</mashup:NavigationTreeMembers>
</mashup:NavigationTreeMember.Members>
</mashup:NavigationTreeMember>
<mashup:NavigationTreeMember Level="0" Label="Personal Info">
<mashup:NavigationTreeMember.Members>
<mashup:NavigationTreeMembers>
<mashup:NavigationTreeMember Level="1" Label="Certifications" Uri="<<HttpServer>>/lawson/xhrnet/qualifications.htm?type=crt" />
<mashup:NavigationTreeMember Level="1" Label="Competencies" Uri="<<HttpServer>>/lawson/xhrnet/qualifications.htm?type=cmp" />
<mashup:NavigationTreeMember Level="1" Label="Dependents" Uri="<<HttpServer>>/lawson/xhrnet/dependentsmain.htm" />
<mashup:NavigationTreeMember Level="1" Label="Education" Uri="<<HttpServer>>/lawson/xhrnet/qualifications.htm?type=edu" />
<mashup:NavigationTreeMember Level="1" Label="Emergency" Uri="<<HttpServer>>/lawson/xhrnet/emergencycontacts.htm" />
<mashup:NavigationTreeMember Level="1" Label="Ethnicity" Uri="<<HttpServer>>/lawson/xhrnet/ethnicity.htm" />
<mashup:NavigationTreeMember Level="1" Label="Leave Balances" Uri="<<HttpServer>>/lawson/xhrnet/leavebalancebegin.htm" />
<mashup:NavigationTreeMember Level="1" Label="Marital Status" Uri="<<HttpServer>>/lawson/xhrnet/maritalstatus.htm" />
<mashup:NavigationTreeMember Level="1" Label="Military Status" Uri="<<HttpServer>>/lawson/xhrnet/military.htm" />
<mashup:NavigationTreeMember Level="1" Label="Nickname" Uri="<<HttpServer>>/lawson/xhrnet/nickname.htm" />
<mashup:NavigationTreeMember Level="1" Label="Personal Profile" Uri="<<HttpServer>>/lawson/xhrnet/emppersonal.htm" />
<mashup:NavigationTreeMember Level="1" Label="Veteran Status" Uri="<<HttpServer>>/lawson/xhrnet/veteran.htm" />
</mashup:NavigationTreeMembers>
</mashup:NavigationTreeMember.Members>
</mashup:NavigationTreeMember>
<mashup:NavigationTreeMember Level="0" Label="Time Entry">
<mashup:NavigationTreeMember.Members>
<mashup:NavigationTreeMembers>
<mashup:NavigationTreeMember Level="1" Label="Daily" Uri="<<HttpServer>>/lawson/xhrnet/timeentry/employee/timeentry.htm?type=daily" />
<mashup:NavigationTreeMember Level="1" Label="Exception Entry" Uri="<<HttpServer>>/lawson/xhrnet/timeentry/exception/exception.htm" />
<mashup:NavigationTreeMember Level="1" Label="Period Entry" Uri="<<HttpServer>>/lawson/xhrnet/timeentry/employee/timeentry.htm" />
<mashup:NavigationTreeMember Level="1" Label="Print Time Entry" Uri="<<HttpServer>>/lawson/xhrnet/timeentry/employee/printtime.htm" />
</mashup:NavigationTreeMembers>
</mashup:NavigationTreeMember.Members>
</mashup:NavigationTreeMember>
<mashup:NavigationTreeMember Level="0" Label="Training">
<mashup:NavigationTreeMember.Members>
<mashup:NavigationTreeMembers>
<mashup:NavigationTreeMember Level="1" Label="Reg by Category" Uri="<<HttpServer>>/lawson/xhrnet/registrationbycategory.htm" />
<mashup:NavigationTreeMember Level="1" Label="Reg by Course" Uri="<<HttpServer>>/lawson/xhrnet/registrationbycourse.htm" />
<mashup:NavigationTreeMember Level="1" Label="Reg by Tracks" Uri="<<HttpServer>>/lawson/xhrnet/registrationbytrack.htm" />
<mashup:NavigationTreeMember Level="1" Label="Required Training" Uri="<<HttpServer>>/lawson/xhrnet/patrnreq.htm" />
<mashup:NavigationTreeMember Level="1" Label="Scheduled Training" Uri="<<HttpServer>>/lawson/xhrnet/paregister.htm" />
<mashup:NavigationTreeMember Level="1" Label="Training History" Uri="<<HttpServer>>/lawson/xhrnet/patrnhist.htm" />
</mashup:NavigationTreeMembers>
</mashup:NavigationTreeMember.Members>
</mashup:NavigationTreeMember>
<mashup:NavigationTreeMember Level="0" Label="Retirement">
<mashup:NavigationTreeMember.Members>
<mashup:NavigationTreeMembers>
<mashup:NavigationTreeMember Level="1" Label="Stock Options" Uri="<<HttpServer>>/lawson/xhrnet/stockoptions/employee/shr064.htm" />
<mashup:NavigationTreeMember Level="1" Label="Savings Modeling" Uri="<<HttpServer>>/lawson/xhrnet/401k/401k.htm" />
<mashup:NavigationTreeMember Level="1" Label="Goal View" Uri="<<HttpServer>>/lawson/xhrnet/goalmanagementemployee.html" />
</mashup:NavigationTreeMembers>
</mashup:NavigationTreeMember.Members>
</mashup:NavigationTreeMember>
</mashup:NavigationTreeMembers>
</mashup:NavigationTree.Members>
</mashup:NavigationTree>
<mashup:NetBrowser Name="NetBrowser" Grid.Column="2" StartUri="http://go2.infor.com/brand/images/logo_animation.gif" Margin="5" Grid.Row="1">
<mashup:NetBrowser.Events>
<mashup:Events>
<mashup:Event SourceName="NavTree" TargetName="NetBrowser" SourceEventName="CurrentItemChanged" TargetEventName="Navigate" Activate="NetBrowser">
<mashup:Parameter SourceKey="Uri" TargetKey="Uri" />
</mashup:Event>
</mashup:Events>
</mashup:NetBrowser.Events>
</mashup:NetBrowser>
<GridSplitter Name="Splitter" Style="{DynamicResource styleGridSplitterVerticalMashup}" Grid.Column="1" Grid.Row="1" />
<Label Name="TitleLabel" Content="Employee Self-Service" Style="{DynamicResource styleGroupBoxHeaderMashup}" Margin="5" />
</Grid>
Beginning in Smart Office version 10.0.4.1 you have the ability to place Mashups inside form tabs (Browser Tabs). Of course, to make them contextual you also have the ability to pass data from the form to the mashup. This capability opens up a whole world of exciting possibilities. Think about it. Mashups allow you to bring together various parts of the ecosystem and bring them together to form a new application for the user. With this feature, you are bringing the Mashup to the form, where the user is already working, rather than bringing the form to the Mashup. In the end it is another tool you can use to help the user do their job more efficiently.
The following are the basic details to embed a Mashup inside a form tab and pass data from the form to the Mashup. Specific details may be refined in future versions of Smart Office, but the functionality is here to stay.
In this simple example we are going to create a List View for AP10.2 and embed it inside a tab on AP10.1. The List View has two keys we are intersted in VENDOR-GROUP and VENDOR. We will use these to filter the List View based on the form data. We call the List Panel “Locations” which we will reference later on when we add the Brower Tab to the form. The last step in the Designer is to create one empty event for the List Panel against the Global > Startup which looks like this:
Future versions of LSO should no longer require this
Next we create the Browser tab on AP10, we are calling this Locations. The url we are going to enter is as follows:
mashup:///?BaseUri=Tab.mashup&RelativeUri=tab.xaml&Locations=VENDOR-GROUP:<VEN-VENDOR-GROUP>;VENDOR:<VEN-VENDOR>
I always let the system create the initial shortcut for me by dragging the Mashup from the Navigation Panel out to the Canvas, then check the Settings. The system will give you something like this:
mashup:///?BaseUri=Tab.mashup&RelativeUri=tab.xaml
We are adding the following to pass the values:
&Locations=VENDOR-GROUP:<VEN-VENDOR-GROUP>;VENDOR:<VEN-VENDOR>
Locations is the name of the List View control in the Mashup. The remaining are sets of name/value pairs telling it what to pass over to the Mashup.
In the end you should have something that looks like this:
As the user proceeds through the records the values from the form are passed into the Mashup and the List View is filtered accordingly.
Although it is not condoned, at least with regards to accessing S3 application data, sometimes it is required to access a SQL database directly. At least when you are accessing third party data that you want to integrate into an S3 form. Here is an example of reading vendor names from the APVENMAST table directly from SQL. I do not take credit for all of this code. Most of it was available online already in some form, I merely put it all together to work inside an LSO script. Be careful.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 | import System; import System.Windows; import System.Windows.Controls; import S3.Client.Forms; import System.Data; //imported for example import System.Data.SqlClient; //imported for example package S3.Client.Forms.JScript { class JjgSql { var console, form, formGrid; public function Init(element: Object, args: Object, controller: Object, debug: Object) { try { form = controller; formGrid = form.FormGrid; console = debug; // TODO Add your code here //begin sql example try { //connection string to database including server, database, userid and password var connectionString : String = "Integrated Security=False;database=apps;server=lsfserver;User ID=lawson;Password=Lawson1975;"; //the sql query var commandText : String = "SELECT VENDOR_VNAME FROM apps.APVENMAST"; //the connection var connection : SqlConnection = new SqlConnection(connectionString); var command : SqlCommand = new SqlCommand(commandText,connection); //command.CommandType = CommandType.StoredProcedure; //if stored command.CommandTimeout = 60; //default = 30 //set Stored Procedure Parameters if needed //command.Parameters.AddWithValue(); //open a connection connection.Open(); //set up the reader var reader : SqlDataReader; reader = command.ExecuteReader(); //if successful read we loop over the response if (reader != null) { var i : int = 0; while (reader.Read()) { i++; // ********************************************************* // Access the record in the recordset returned and // perform the operation required: // ********************************************************* // Column values accessed like so: // reader["ColumnName1"].ToString(); OR reader[0].ToString(); //this will write out the first column //console.WriteLine(reader.GetString(0)); // this works too console.WriteLine(reader["VENDOR_VNAME"].ToString()); } reader.Close(); } connection.Close(); } catch (ex) { console.WriteLine(ScriptUtil.FormatException("Sql", ex)); } //end sql example form.add_BeforeUnload(OnBeforeUnload); } catch (e) { console.WriteLine(ScriptUtil.FormatException("Init", e)); } } // event handlers public function OnBeforeUnload(sender: Object, e: FormEventArgs) { // perform cleanup form.remove_BeforeUnload(OnBeforeUnload); } // private functions } } |
import System;
import System.Windows;
import System.Windows.Controls;
import S3.Client.Forms;
import System.Data; //imported for example
import System.Data.SqlClient; //imported for example
package S3.Client.Forms.JScript {
class JjgSql
{
var console, form, formGrid;
public function Init(element: Object, args: Object, controller: Object, debug: Object)
{
try {
form = controller;
formGrid = form.FormGrid;
console = debug;
// TODO Add your code here
//begin sql example
try {
//connection string to database including server, database, userid and password
var connectionString : String = "Integrated Security=False;database=apps;server=lsfserver;User ID=lawson;Password=Lawson1975;";
//the sql query
var commandText : String = "SELECT VENDOR_VNAME FROM apps.APVENMAST";
//the connection
var connection : SqlConnection = new SqlConnection(connectionString);
var command : SqlCommand = new SqlCommand(commandText,connection);
//command.CommandType = CommandType.StoredProcedure; //if stored
command.CommandTimeout = 60; //default = 30
//set Stored Procedure Parameters if needed
//command.Parameters.AddWithValue();
//open a connection
connection.Open();
//set up the reader
var reader : SqlDataReader;
reader = command.ExecuteReader();
//if successful read we loop over the response
if (reader != null)
{
var i : int = 0;
while (reader.Read())
{
i++;
// *********************************************************
// Access the record in the recordset returned and
// perform the operation required:
// *********************************************************
// Column values accessed like so:
// reader["ColumnName1"].ToString(); OR reader[0].ToString();
//this will write out the first column
//console.WriteLine(reader.GetString(0)); // this works too
console.WriteLine(reader["VENDOR_VNAME"].ToString());
}
reader.Close();
}
connection.Close();
}
catch (ex)
{
console.WriteLine(ScriptUtil.FormatException("Sql", ex));
}
//end sql example
form.add_BeforeUnload(OnBeforeUnload);
} catch (e) {
console.WriteLine(ScriptUtil.FormatException("Init", e));
}
}
// event handlers
public function OnBeforeUnload(sender: Object, e: FormEventArgs)
{
// perform cleanup
form.remove_BeforeUnload(OnBeforeUnload);
}
// private functions
} }Display the Line Unit Cost in each line next to the item description.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 | //----------------------------------------------------------------------------- // JScript Example // Created by: Josh Geving - Solutions Group // // Description: Display the Line Unit cost oin each line - PO30 // // // Last Tested on Smart Office Version 10.0.1.5 //----------------------------------------------------------------------------- import System; import System.Windows; import System.Windows.Controls; import S3.Client.Forms; package S3.Client.Forms.JScript { class JjgPO30LineCost { var console, form, formGrid; public function Init(element: Object, args: Object, controller: Object, debug: Object) { try { form = controller; formGrid = form.FormGrid; console = debug; // TODO Add your code here form.add_AfterTransaction(OnAfterTransaction); form.add_BeforeUnload(OnBeforeUnload); } catch (e) { console.WriteLine(ScriptUtil.FormatException("Init", e)); } } // event handlers public function OnBeforeUnload(sender: Object, e: FormEventArgs) { // perform cleanup form.remove_AfterTransaction(OnAfterTransaction); form.remove_BeforeUnload(OnBeforeUnload); } public function OnAfterTransaction(sender: Object, e: TransactionEventArgs) { // test for good transaction if (e.TransactionError) return; // no action on delete if (e.FunctionCode == "D") return; // Loop through the lines var row = 0; var vCompany = form.GetTransactionValue("POR-COMPANY"); var vPurchaseOrder = form.GetTransactionValue("POR-PO-NUMBER").Trim(); var vRelease = form.GetTransactionValue("POR-PO-RELEASE"); var vPOCode = form.GetTransactionValue("POR-PO-CODE"); for(row = 0; row <= 4; row++) { var vItem = form.GetTransactionValue("ITEM-DETAILr" + row); var vLine = form.GetTransactionValue("PRL-PO-LINE-NBRr" + row); // build up the Data Service call var sProd = form.GetUserAttribute("productline"); var sFile = "POLINE"; var sField = "ENT-UNIT-CST"; var sIndex = "PLISET1&KEY=" + vCompany + "=" + vPurchaseOrder + "=" + vRelease + "=" + vPOCode + "=" + vLine; var sCond = ""; var sSelect = ""; var sMax = ""; // Pass the variables for the API to DataService_Execute if(vItem != "") { var aDataAPI = DataService_Execute(sProd,sFile, sField, sIndex, sCond, sSelect, sMax); console.WriteLine("aDataAPI.length: " + aDataAPI.length); // Did we get anything back from the call? if(aDataAPI.length > 0) { var i = 0; for(i = 0; i < aDataAPI.length; i++) { console.WriteLine(aDataAPI[i]); form.SetTransactionValue("ITEM-DETAILr" + row, vItem + " - Unit Cost: " + aDataAPI[i]); } } else{ console.WriteLine("***No Records***"); } } } } // private functions /** * DataService_Execute - This method returns an array for the api specified * Detail description * This method returns an array of values for for the api details * @param required sProd, PROD, defaults to user profile if not set - required * @param required sFile, FILE * @param required sField, FIELD * @param optional sIndex, INDEX, removed from api if not set * @param optional sCond, COND * @param optional sSelect, SELECT * @param optional sMax, MAX, defaults to 0 if not set * @access private * @return array */ private function DataService_Execute(sProd,sFile, sField, sIndex, sCond, sSelect, sMax) { var a = new Array(); var aFields = new Array(); var i = 0; var s = ""; var oXML; var oRecs; var oRecNum; var oRec; var oFields; // Productline sProd empty, set from profile if(sProd == ""){sProd = form.GetUserAttribute("productline");} // Max sMax empty, set to 0 for all if(sMax == ""){sMax = 0;} // Build the complete Data Service Call s = ScriptConstants.DataMinePath + "?PROD=" + sProd + "&FILE=" + sFile + "&FIELD=" + sField; // If Index we add Index to the call if(sIndex != ""){s += "&INDEX=" + sIndex;} // The rest of the call s += "&COND=" + sCond + "&SELECT=" + sSelect + "&MAX=" + sMax + "&OUT=XML&DELIM="+ new Date().getTime(); // Time used to prevent caching console.WriteLine("s: " + s); // Make the server request, record the time it took var bTime = new Date().getTime(); oXML = ScriptUtil.ServerRequest(s); var eTime = new Date().getTime(); console.WriteLine("API Execution Time: " + (eTime-bTime)/1000 + "seconds"); // Get the Record Count Node oRecs = oXML.SelectSingleNode("//RECORDS"); oRecNum = oRecs != null ? oRecs.ChildNodes.Count : 0; console.WriteLine("oRecNum: " +oRecNum); // Determine if records were returned if(oRecNum == 0) { console.WriteLine("Data Service Call\n\n" + s + "\n\n returned " + oRecNum + " records."); return a; } // Build an array with the results for(oRec in oRecs.ChildNodes) { oFields = oRec.SelectSingleNode("./COLS"); aFields = new Array(); for(i = 0; i < oFields.ChildNodes.Count; i++) { aFields[aFields.length] = oFields.ChildNodes[i].InnerText; } a[a.length] = aFields; } return a; } } } |
//-----------------------------------------------------------------------------
// JScript Example
// Created by: Josh Geving - Solutions Group
//
// Description: Display the Line Unit cost oin each line - PO30
//
//
// Last Tested on Smart Office Version 10.0.1.5
//-----------------------------------------------------------------------------
import System;
import System.Windows;
import System.Windows.Controls;
import S3.Client.Forms;
package S3.Client.Forms.JScript {
class JjgPO30LineCost
{
var console, form, formGrid;
public function Init(element: Object, args: Object, controller: Object, debug: Object)
{
try {
form = controller;
formGrid = form.FormGrid;
console = debug;
// TODO Add your code here
form.add_AfterTransaction(OnAfterTransaction);
form.add_BeforeUnload(OnBeforeUnload);
} catch (e) {
console.WriteLine(ScriptUtil.FormatException("Init", e));
}
}
// event handlers
public function OnBeforeUnload(sender: Object, e: FormEventArgs)
{
// perform cleanup
form.remove_AfterTransaction(OnAfterTransaction);
form.remove_BeforeUnload(OnBeforeUnload);
}
public function OnAfterTransaction(sender: Object, e: TransactionEventArgs)
{
// test for good transaction
if (e.TransactionError)
return;
// no action on delete
if (e.FunctionCode == "D")
return;
// Loop through the lines
var row = 0;
var vCompany = form.GetTransactionValue("POR-COMPANY");
var vPurchaseOrder = form.GetTransactionValue("POR-PO-NUMBER").Trim();
var vRelease = form.GetTransactionValue("POR-PO-RELEASE");
var vPOCode = form.GetTransactionValue("POR-PO-CODE");
for(row = 0; row <= 4; row++)
{
var vItem = form.GetTransactionValue("ITEM-DETAILr" + row);
var vLine = form.GetTransactionValue("PRL-PO-LINE-NBRr" + row);
// build up the Data Service call
var sProd = form.GetUserAttribute("productline");
var sFile = "POLINE";
var sField = "ENT-UNIT-CST";
var sIndex = "PLISET1&KEY=" + vCompany + "=" + vPurchaseOrder + "=" + vRelease + "=" + vPOCode + "=" + vLine;
var sCond = "";
var sSelect = "";
var sMax = "";
// Pass the variables for the API to DataService_Execute
if(vItem != "")
{
var aDataAPI = DataService_Execute(sProd,sFile, sField, sIndex, sCond, sSelect, sMax);
console.WriteLine("aDataAPI.length: " + aDataAPI.length);
// Did we get anything back from the call?
if(aDataAPI.length > 0)
{
var i = 0;
for(i = 0; i < aDataAPI.length; i++)
{
console.WriteLine(aDataAPI[i]);
form.SetTransactionValue("ITEM-DETAILr" + row, vItem + " - Unit Cost: " + aDataAPI[i]);
}
}
else{
console.WriteLine("***No Records***");
}
}
}
}
// private functions
/**
* DataService_Execute - This method returns an array for the api specified
* Detail description
* This method returns an array of values for for the api details
* @param required sProd, PROD, defaults to user profile if not set - required
* @param required sFile, FILE
* @param required sField, FIELD
* @param optional sIndex, INDEX, removed from api if not set
* @param optional sCond, COND
* @param optional sSelect, SELECT
* @param optional sMax, MAX, defaults to 0 if not set
* @access private
* @return array
*/
private function DataService_Execute(sProd,sFile, sField, sIndex, sCond, sSelect, sMax)
{
var a = new Array();
var aFields = new Array();
var i = 0;
var s = "";
var oXML;
var oRecs;
var oRecNum;
var oRec;
var oFields;
// Productline sProd empty, set from profile
if(sProd == ""){sProd = form.GetUserAttribute("productline");}
// Max sMax empty, set to 0 for all
if(sMax == ""){sMax = 0;}
// Build the complete Data Service Call
s = ScriptConstants.DataMinePath + "?PROD=" + sProd + "&FILE=" + sFile + "&FIELD=" + sField;
// If Index we add Index to the call
if(sIndex != ""){s += "&INDEX=" + sIndex;}
// The rest of the call
s += "&COND=" + sCond + "&SELECT=" + sSelect + "&MAX=" + sMax +
"&OUT=XML&DELIM="+ new Date().getTime(); // Time used to prevent caching
console.WriteLine("s: " + s);
// Make the server request, record the time it took
var bTime = new Date().getTime();
oXML = ScriptUtil.ServerRequest(s);
var eTime = new Date().getTime();
console.WriteLine("API Execution Time: " + (eTime-bTime)/1000 + "seconds");
// Get the Record Count Node
oRecs = oXML.SelectSingleNode("//RECORDS");
oRecNum = oRecs != null ? oRecs.ChildNodes.Count : 0;
console.WriteLine("oRecNum: " +oRecNum);
// Determine if records were returned
if(oRecNum == 0)
{
console.WriteLine("Data Service Call\n\n" + s + "\n\n returned " + oRecNum + " records.");
return a;
}
// Build an array with the results
for(oRec in oRecs.ChildNodes)
{
oFields = oRec.SelectSingleNode("./COLS");
aFields = new Array();
for(i = 0; i < oFields.ChildNodes.Count; i++)
{
aFields[aFields.length] = oFields.ChildNodes[i].InnerText;
}
a[a.length] = aFields;
}
return a;
}
} }
Gather additional fields from the vendor record and dipslay them in the header as new labels.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 | //----------------------------------------------------------------------------- // JScript Example // Created by: Josh Geving - Solutions Group // // Description: PO20 - Gather additional fields from the vendor record and // dipslay them in the header as new labels // // Optional: form.GetUserAttribute("vendor_group"); // // Last Tested on Smart Office Version 10.0.1.5 //----------------------------------------------------------------------------- import System; import System.Windows; import System.Windows.Controls; import S3.Client.Forms; // New import to support StyleManager import Mango.UI.Core; package S3.Client.Forms.JScript { class JjgPO20VendorInfo { var console, form, formGrid; public function Init(element: Object, args: Object, controller: Object, debug: Object) { try { form = controller; formGrid = form.FormGrid; console = debug; // TODO Add your code here // Add additional fields AddFields(); // Capture AfterTransaction form.add_AfterTransaction(OnAfterTransaction); // Support user leaving Vendor Field form.GetElement("PCR-VENDOR").add_LostFocus(OnLostFocus); form.add_BeforeUnload(OnBeforeUnload); } catch (e) { console.WriteLine(ScriptUtil.FormatException("Init", e)); } } // event handlers public function OnBeforeUnload(sender: Object, e: FormEventArgs) { // perform cleanup form.remove_AfterTransaction(OnAfterTransaction); form.GetElement("PCR-VENDOR").remove_LostFocus(OnLostFocus); form.remove_BeforeUnload(OnBeforeUnload); } public function OnLostFocus(sender: Object, e: RoutedEventArgs) { // Write out to console the selected vendor console.WriteLine("Vendor: "+ sender.Text); // If there is something there we proceed if(sender.Text != "") { // Fetch value for the vendor var vVendorGroup = form.GetUserAttribute("vendor_group"); // If no Vendor we default 1 for example purposes, normally we would fetch from Procure Group path if(vVendorGroup == "") { vVendorGroup = 1; } var vVendor = sender.Text; // Write out our key values console.WriteLine("vVendorGroup: " + vVendorGroup); console.WriteLine("vVendor: " + vVendor); // Build the Transaction API var sCall = "&VEN-VENDOR-GROUP="+ vVendorGroup +"&VEN-VENDOR="+ vVendor; // Transaction API values var sForm = "AP10.1"; var sProd = form.GetUserAttribute("productline"); var sFunction = "I"; var sDesc = "Vendor Inquire"; // Issue the Transaction API var TransXml = TransactionService_Execute(sForm, sProd, sFunction, sCall, sDesc); // Do we want to see the xml that came back? console.WriteLine(TransXml.OuterXml); // Fetch a node by name and write out the contents console.WriteLine("Contact: " + Transaction_GetFieldValue(TransXml, "VEN-VENDOR-CONTCT")); console.WriteLine("Phone: " + Transaction_GetFieldValue(TransXml, "VEN-PHONE-NUM")); console.WriteLine("Account: " + Transaction_GetFieldValue(TransXml, "VEN-VEND-ACCT")); // Set the values to our custom elements form.SetCustomElementValue("CustContact", Transaction_GetFieldValue(TransXml, "VEN-VENDOR-CONTCT")); form.SetCustomElementValue("CustPhone", Transaction_GetFieldValue(TransXml, "VEN-PHONE-NUM")); form.SetCustomElementValue("CustAccount", Transaction_GetFieldValue(TransXml, "VEN-VEND-ACCT")); } } // private functions private function AddFields() { AddLabel("CustContact","","Left",4,50,20,"blue",formGrid) AddLabel("CustPhone","","Left",5,50,20,"blue",formGrid) AddLabel("CustAccount","","Left",6,50,20,"blue",formGrid) } public function OnAfterTransaction(sender: Object, e: TransactionEventArgs) { // test for good transaction if (e.TransactionError) return; // no action on delete if (e.FunctionCode == "D") return; // Fetch value for the vendor var vVendorGroup = form.GetUserAttribute("vendor_group"); // If no Vendor we default 1 for example purposes, normally we would fetch from Procure Group path if(vVendorGroup == "") { vVendorGroup = 1; } var vVendor = form.GetTransactionValue("PCR-VENDOR"); console.WriteLine("vVendorGroup: " + vVendorGroup); console.WriteLine("vVendor: " + vVendor); // Build the Transaction API var sCall = "&VEN-VENDOR-GROUP="+ vVendorGroup +"&VEN-VENDOR="+ vVendor; // Transaction API values var sForm = "AP10.1"; var sProd = form.GetUserAttribute("productline"); var sFunction = "I"; var sDesc = "Vendor Inquire"; // Issue the Transaction API var TransXml = TransactionService_Execute(sForm, sProd, sFunction, sCall, sDesc); // Do we want to see the xml that came back? console.WriteLine(TransXml.OuterXml); // Fetch a node by name and write out the contents console.WriteLine("Contact: " + Transaction_GetFieldValue(TransXml, "VEN-VENDOR-CONTCT")); console.WriteLine("Phone: " + Transaction_GetFieldValue(TransXml, "VEN-PHONE-NUM")); console.WriteLine("Account: " + Transaction_GetFieldValue(TransXml, "VEN-VEND-ACCT")); form.SetCustomElementValue("CustContact", Transaction_GetFieldValue(TransXml, "VEN-VENDOR-CONTCT")); form.SetCustomElementValue("CustPhone", Transaction_GetFieldValue(TransXml, "VEN-PHONE-NUM")); form.SetCustomElementValue("CustAccount", Transaction_GetFieldValue(TransXml, "VEN-VEND-ACCT")); } /** * AddLabel - Creates a label on the form * Parameters * sName required The unique label name * sCaption required The label text * sAlign required Alignment Right, Left or Center * nRow required Numeric row to place the label * nColumn required Numeric column to place the label * nColumnSpan required Numeric column span * bType optional Type, empty (for normal), bold or blue * oAddTo required Where to place label * * Example: AddLabel("UniqueName","My new label","Right",1,50,12,"bold",formGrid) */ private function AddLabel(sName,sCaption,sAlign,nRow,nColumn,nColumnSpan,bType,oAddTo) { // Define label var label = new Label(); // New label created label.Name = sName; // Assign a name label.Content = sCaption; // Assign a caption label.Padding = new Thickness(1); // Add padding label.VerticalContentAlignment = VerticalAlignment.Center; // Center the alignment if(bType == "blue") { label.Style = StyleManager.StyleAdditionalInfo; // import Mango.UI.Core; //blue label } if(bType == "bold") { label.Style = StyleManager.StyleEmphasized; // import Mango.UI.Core; // bold label } if(sAlign == "Right") // Set the alignment of the caption within the label {label.HorizontalContentAlignment = HorizontalAlignment.Right} else if(sAlign == "Center") {label.HorizontalContentAlignment = HorizontalAlignment.Center} else {label.HorizontalContentAlignment = HorizontalAlignment.Left} Grid.SetRow(label, nRow); //Indicate the row for the label Grid.SetColumn(label, nColumn); //Indicate the starting column for the label Grid.SetColumnSpan(label, nColumnSpan); //Indicate the column width of the label form.AddCustomElement(oAddTo, label); //Add the label to the form } /** * TransactionService_Execute - This method returns xml from a transaction service call * Detail description * This method returns xml for the api details * @param required sForm, _TKN * @param required sProd, _PDL * @param required sFunction, FC * @param required sCall * @param optional sDesc * @access private * @return xml */ private function TransactionService_Execute(sForm, sProd, sFunction, sCall, sDesc) { var s = ""; var oXML; // Build the complete Transaction Service Call s = ScriptConstants.TransactionPath s += "?_PDL=" + sProd; s += "&_TKN=" + sForm if(sFunction == "Add" || sFunction == "A") {s += "&_EVT=ADD"} else {s += "&_EVT=CHG"} s += "&FC=" + sFunction; s += sCall; s += "&_LFN=ALL&_TDS=IGNORE&_OUT=XML&_EOT=TRUE"; console.WriteLine("s: " + s); // Make the server request oXML = form.ServerRequest(s); // Determine if the Transaction Service Call processed if(!oXML) { console.WriteLine("The Transaction Service Call \n\n" + sDesc + "\n\nfailed to process.") } else if(Transaction_GetFieldValue(oXML, "MsgNbr") != "000") // Determine if the Transaction Service Call worked { console.WriteLine(sForm + " MsgNbr: " + Transaction_GetFieldValue(oXML, "Message")); } return oXML; } private function Transaction_GetFieldValue(oData, sFind) { return oData.SelectSingleNode("//" + sFind).InnerText; } } } |
//-----------------------------------------------------------------------------
// JScript Example
// Created by: Josh Geving - Solutions Group
//
// Description: PO20 - Gather additional fields from the vendor record and
// dipslay them in the header as new labels
//
// Optional: form.GetUserAttribute("vendor_group");
//
// Last Tested on Smart Office Version 10.0.1.5
//-----------------------------------------------------------------------------
import System;
import System.Windows;
import System.Windows.Controls;
import S3.Client.Forms;
// New import to support StyleManager
import Mango.UI.Core;
package S3.Client.Forms.JScript {
class JjgPO20VendorInfo
{
var console, form, formGrid;
public function Init(element: Object, args: Object, controller: Object, debug: Object)
{
try {
form = controller;
formGrid = form.FormGrid;
console = debug;
// TODO Add your code here
// Add additional fields
AddFields();
// Capture AfterTransaction
form.add_AfterTransaction(OnAfterTransaction);
// Support user leaving Vendor Field
form.GetElement("PCR-VENDOR").add_LostFocus(OnLostFocus);
form.add_BeforeUnload(OnBeforeUnload);
} catch (e) {
console.WriteLine(ScriptUtil.FormatException("Init", e));
}
}
// event handlers
public function OnBeforeUnload(sender: Object, e: FormEventArgs)
{
// perform cleanup
form.remove_AfterTransaction(OnAfterTransaction);
form.GetElement("PCR-VENDOR").remove_LostFocus(OnLostFocus);
form.remove_BeforeUnload(OnBeforeUnload);
}
public function OnLostFocus(sender: Object, e: RoutedEventArgs)
{
// Write out to console the selected vendor
console.WriteLine("Vendor: "+ sender.Text);
// If there is something there we proceed
if(sender.Text != "")
{
// Fetch value for the vendor
var vVendorGroup = form.GetUserAttribute("vendor_group");
// If no Vendor we default 1 for example purposes, normally we would fetch from Procure Group path
if(vVendorGroup == "")
{
vVendorGroup = 1;
}
var vVendor = sender.Text;
// Write out our key values
console.WriteLine("vVendorGroup: " + vVendorGroup);
console.WriteLine("vVendor: " + vVendor);
// Build the Transaction API
var sCall = "&VEN-VENDOR-GROUP="+ vVendorGroup +"&VEN-VENDOR="+ vVendor;
// Transaction API values
var sForm = "AP10.1";
var sProd = form.GetUserAttribute("productline");
var sFunction = "I";
var sDesc = "Vendor Inquire";
// Issue the Transaction API
var TransXml = TransactionService_Execute(sForm, sProd, sFunction, sCall, sDesc);
// Do we want to see the xml that came back?
console.WriteLine(TransXml.OuterXml);
// Fetch a node by name and write out the contents
console.WriteLine("Contact: " + Transaction_GetFieldValue(TransXml, "VEN-VENDOR-CONTCT"));
console.WriteLine("Phone: " + Transaction_GetFieldValue(TransXml, "VEN-PHONE-NUM"));
console.WriteLine("Account: " + Transaction_GetFieldValue(TransXml, "VEN-VEND-ACCT"));
// Set the values to our custom elements
form.SetCustomElementValue("CustContact", Transaction_GetFieldValue(TransXml, "VEN-VENDOR-CONTCT"));
form.SetCustomElementValue("CustPhone", Transaction_GetFieldValue(TransXml, "VEN-PHONE-NUM"));
form.SetCustomElementValue("CustAccount", Transaction_GetFieldValue(TransXml, "VEN-VEND-ACCT"));
}
}
// private functions
private function AddFields()
{
AddLabel("CustContact","","Left",4,50,20,"blue",formGrid)
AddLabel("CustPhone","","Left",5,50,20,"blue",formGrid)
AddLabel("CustAccount","","Left",6,50,20,"blue",formGrid)
}
public function OnAfterTransaction(sender: Object, e: TransactionEventArgs)
{
// test for good transaction
if (e.TransactionError)
return;
// no action on delete
if (e.FunctionCode == "D")
return;
// Fetch value for the vendor
var vVendorGroup = form.GetUserAttribute("vendor_group");
// If no Vendor we default 1 for example purposes, normally we would fetch from Procure Group path
if(vVendorGroup == "")
{
vVendorGroup = 1;
}
var vVendor = form.GetTransactionValue("PCR-VENDOR");
console.WriteLine("vVendorGroup: " + vVendorGroup);
console.WriteLine("vVendor: " + vVendor);
// Build the Transaction API
var sCall = "&VEN-VENDOR-GROUP="+ vVendorGroup +"&VEN-VENDOR="+ vVendor;
// Transaction API values
var sForm = "AP10.1";
var sProd = form.GetUserAttribute("productline");
var sFunction = "I";
var sDesc = "Vendor Inquire";
// Issue the Transaction API
var TransXml = TransactionService_Execute(sForm, sProd, sFunction, sCall, sDesc);
// Do we want to see the xml that came back?
console.WriteLine(TransXml.OuterXml);
// Fetch a node by name and write out the contents
console.WriteLine("Contact: " + Transaction_GetFieldValue(TransXml, "VEN-VENDOR-CONTCT"));
console.WriteLine("Phone: " + Transaction_GetFieldValue(TransXml, "VEN-PHONE-NUM"));
console.WriteLine("Account: " + Transaction_GetFieldValue(TransXml, "VEN-VEND-ACCT"));
form.SetCustomElementValue("CustContact", Transaction_GetFieldValue(TransXml, "VEN-VENDOR-CONTCT"));
form.SetCustomElementValue("CustPhone", Transaction_GetFieldValue(TransXml, "VEN-PHONE-NUM"));
form.SetCustomElementValue("CustAccount", Transaction_GetFieldValue(TransXml, "VEN-VEND-ACCT"));
}
/**
* AddLabel - Creates a label on the form
* Parameters
* sName required The unique label name
* sCaption required The label text
* sAlign required Alignment Right, Left or Center
* nRow required Numeric row to place the label
* nColumn required Numeric column to place the label
* nColumnSpan required Numeric column span
* bType optional Type, empty (for normal), bold or blue
* oAddTo required Where to place label
*
* Example: AddLabel("UniqueName","My new label","Right",1,50,12,"bold",formGrid)
*/
private function AddLabel(sName,sCaption,sAlign,nRow,nColumn,nColumnSpan,bType,oAddTo)
{
// Define label
var label = new Label(); // New label created
label.Name = sName; // Assign a name
label.Content = sCaption; // Assign a caption
label.Padding = new Thickness(1); // Add padding
label.VerticalContentAlignment = VerticalAlignment.Center; // Center the alignment
if(bType == "blue")
{
label.Style = StyleManager.StyleAdditionalInfo; // import Mango.UI.Core; //blue label
}
if(bType == "bold")
{
label.Style = StyleManager.StyleEmphasized; // import Mango.UI.Core; // bold label
}
if(sAlign == "Right") // Set the alignment of the caption within the label
{label.HorizontalContentAlignment = HorizontalAlignment.Right}
else if(sAlign == "Center")
{label.HorizontalContentAlignment = HorizontalAlignment.Center}
else
{label.HorizontalContentAlignment = HorizontalAlignment.Left}
Grid.SetRow(label, nRow); //Indicate the row for the label
Grid.SetColumn(label, nColumn); //Indicate the starting column for the label
Grid.SetColumnSpan(label, nColumnSpan); //Indicate the column width of the label
form.AddCustomElement(oAddTo, label); //Add the label to the form
}
/**
* TransactionService_Execute - This method returns xml from a transaction service call
* Detail description
* This method returns xml for the api details
* @param required sForm, _TKN
* @param required sProd, _PDL
* @param required sFunction, FC
* @param required sCall
* @param optional sDesc
* @access private
* @return xml
*/
private function TransactionService_Execute(sForm, sProd, sFunction, sCall, sDesc)
{
var s = "";
var oXML;
// Build the complete Transaction Service Call
s = ScriptConstants.TransactionPath
s += "?_PDL=" + sProd;
s += "&_TKN=" + sForm
if(sFunction == "Add" || sFunction == "A")
{s += "&_EVT=ADD"}
else
{s += "&_EVT=CHG"}
s += "&FC=" + sFunction;
s += sCall;
s += "&_LFN=ALL&_TDS=IGNORE&_OUT=XML&_EOT=TRUE";
console.WriteLine("s: " + s);
// Make the server request
oXML = form.ServerRequest(s);
// Determine if the Transaction Service Call processed
if(!oXML)
{
console.WriteLine("The Transaction Service Call \n\n" + sDesc + "\n\nfailed to process.")
}
else if(Transaction_GetFieldValue(oXML, "MsgNbr") != "000") // Determine if the Transaction Service Call worked
{
console.WriteLine(sForm + " MsgNbr: " + Transaction_GetFieldValue(oXML, "Message"));
}
return oXML;
}
private function Transaction_GetFieldValue(oData, sFind)
{
return oData.SelectSingleNode("//" + sFind).InnerText;
}
} }