UXDE dot Net Wordpress Themes

Mashup – Item Master and Location Information

in Smart Office, Smart Office Mashups / No Comments

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

 

Open Smart Office Widgets from a Shortcut

in Smart Office, Smart Office Widget / No Comments

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:

smart_office_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

 

 

 

Mashup – Employees By Position

in Smart Office, Smart Office Mashups / No Comments

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.

mashup_employees_by_position

 

 

Full source code available here: EmployeesByPosition

Display Vendor Balance in AP10 using Smart Office Scripting

in Smart Office, Smart Office Scripting / No Comments

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.

ScriptAP10VendorBalance

 

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;
	}

} }

Data Mining Engine (DME) Code for Design Studio Scripting

in Design Studio, Lawson / No Comments

I am always asked by developers new to Design Studio how to perform a DME call to retrieve data within Lawson S3 applications.  I came across this code years ago and it has proven invaluable for this task. You can attach directly to a form as is or use it as an Include file but it facilitates the processing of a DME API into Lawson for use with an S3 form.  Below the code I have attached a simple example where this code is used.

DME Code (Updated on April 16, 2013, now compatible with 10.0.3 and 10.1 Portal)

 

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
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
/************************************************************
********************* DME OBJECT CODE ***********************
***************** SIMPLIFIES PERFORMING A DME ***************
***************** UPDATED APRIL 2013 for 10.0.3 *************
*************************************************************
*************************************************************   
************************************************************/
 
/************************************************************
    Function: exampleDme()
 
    Purpose:  Simple example usign the dme code
************************************************************/
function exampleDme()
{
    //fetch the effective date used so we can send a change action
    var vCo     = portalWnd.oUserProfile.getAttribute("company");
    var vJobCode    = "110";
 
    //set object and table/prodline
    var empDMEObj   = new DMEObject("JOBCODE", strPDL);
 
    //set an index
    empDMEObj.setIndex("JBCSET1&KEY=" + vCo + "=" + vJobCode);
 
    //tell it what fields to fetch
    empDMEObj.addField("EFFECTIVE-DATE");
 
    //prompt("obj",empDMEObj.toString());
    empDMEObj.execute();
 
    //grab a field from the dme result
    var vEffectDateHR06 = empDMEObj.getField("EFFECTIVE-DATE"); 
 
    alert(vEffectDateHR06);
}
 
/************************************************************
    Function: getVarFromString
 
    Purpose:  get the variables from the search string
 
    Example:  var vCompany = getVarFromString("Company",parent.location.search);
************************************************************/
function getVarFromString(varName,str)
{
    str+='&'
    reStr="(?:\\&|\\?|^)" + varName + "=(.*?)(?:\\&|$)"
    var re=new RegExp(reStr,"gi")
    if(re.test(str))
        return RegExp.$1
    else
        return ""
}
 
/************************************************************
    Function: getDMEColumnIndex(pColumns)
 
    Purpose:  Helper Method used assist in getting DME record data as seen on pg 114 of 
          Design Studio User Guide
************************************************************/
function getDMEColumnIndex(pColumns)
{
    var vIndex = new Array();
    for (var i=0; i<pColumns.length; i++)
    {
        var vLabel = pColumns[i].getAttribute("header").toUpperCase().split("_").join("-");
        vIndex[vLabel] = i;
    }
    return vIndex;
}
 
/************************************************************
    Function: getNodeValue(pNode)
 
    Purpose:  Helper Method used assist in getting DME field data as seen on pg 114 of
          Design Studio User Guide
************************************************************/
function getNodeValue(pNode)
{
    for (var i=0; i<pNode.childNodes.length; i++)
    {
        if (pNode.childNodes[i].nodeType == 4)
        {
            return pNode.childNodes[i].nodeValue;
        }
    }
}
 
/************************************************************
    Function: DMEObject
 
    Purpose:  Constructor.  Return a new DMEObject for a file(table) and productline.
          Initialize your instance variables.
************************************************************/
function DMEObject(pFile, pPDL)
{
    this.file = pFile;
    this.pdl = pPDL;
    this.index = "";
    this.conditions = "";
    this.fields = "";
    this.select = "";
    this.optParams= "";
    this.dmeString = "";
    this.records = null;
    this.columns = new Array();
    this.length = 0;
    this.maxRecords = 9999;
    this.success = false;
}
 
/************************************************************
    Function: setIndex(pIndex)
 
    Purpose:  Instance method for DMEObject.  Takes in a predefined index and sets in in 
          the object..
************************************************************/
DMEObject.prototype.setIndex = function(pIndex)
{
    this.index = pIndex;
 
    return true;
}
 
/************************************************************
    Function: setIndex(pIndex)
 
    Purpose:  Instance method for DMEObject.  Takes in a predefined index and sets in in 
          the object..
************************************************************/
DMEObject.prototype.setOptParams = function(pOptParams)
{
    this.optParams = pOptParams;
 
    return true;
}
 
/************************************************************
    Function: setConditions(pConditions)
 
    Purpose:  Instance method for DMEObject.  Takes in a predefined Conditions and sets in in 
          the object..
************************************************************/
DMEObject.prototype.setConditions = function(pConditions)
{
    this.conditions = pConditions;
 
    return true;
}
 
/************************************************************
    Function: setSelect(pSelect)
 
    Purpose:  Instance method for DMEObject.  Takes in a predefined index and sets in in 
          the object..
************************************************************/
DMEObject.prototype.setSelect = function(pSelect)
{
    this.select= pSelect;
 
    return true;
}
 
/************************************************************
    Function: addField(pField, pFieldValue)
 
    Purpose:  Instance method for DMEObject.  Takes in a field name and adds it to the 
          fields portion of the DME string.
************************************************************/
DMEObject.prototype.addField = function(pField)
{
    this.fields += pField+";";
 
    return true;
}
 
/************************************************************
    Function: getField(pField)
 
    Purpose:  Instance method for DMEObject.  Takes in a field name as a parameter and 
          return's it's value from the DME String.  If pRelRecTable is populated, pField
          will be ignored and an array will be passed back.
************************************************************/
DMEObject.prototype.getField = function(pField, pRow, pRelRecTable)
{
    var rFieldValue;
 
    if ((pRow == undefined) ||
        (pRow == null))
    {
        pRow = 0;
    }
    if ((pRelRecTable == undefined) ||
        (pRelRecTable == null))
    {
        pRelRecTable = "";
    }
 
    //if it's not an empty string, we'll return the value from the related record tables
    if (pRelRecTable != "")
    {
        var vNewRelRecsArray = new Array();
        var vRelRecsArray = this.returnRecords[pRow].getElementsByTagName("RELRECS");
//alert(this.returnRecords[0].getElementsByTagName("RELRECS")[0].getElementsByTagName("RELREC")[1].getElementsByTagName("COL")[1].childNodes[0].nodeValue)
        //search each related table record set for one that matches pRelRecTable
        for(var i=0; i < vRelRecsArray.length; i++)
        {
            if (vRelRecsArray[i].getAttribute("name").toUpperCase().split("_").join("-") == pRelRecTable.toUpperCase())
            {
                var vRelRecArray = vRelRecsArray[i].getElementsByTagName("RELREC");
                //search specific related table record set's values
                for(var j=0; j < vRelRecArray.length; j++)
                {
                    var vNewRelRecArray = new Array();
                    var vRelRecColArray = vRelRecArray[j].getElementsByTagName("COL");
 
                    for(var k=0; k < vRelRecColArray.length; k++)
                    {
                        var vRelRecColValue = vRelRecColArray[k].childNodes[0].nodeValue;
                        vNewRelRecArray.push(vRelRecColValue);
                    }
                    vNewRelRecsArray.push(vNewRelRecArray)
                }
 
                break;
            }
        }
        rFieldValue = vNewRelRecsArray;
    }
    else
    {
        var vRecord = this.returnRecords[pRow].getElementsByTagName("COL");
 
        rFieldValue = getNodeValue(vRecord[this.columns[pField]]);
    }
 
    return (rFieldValue);
}
 
/************************************************************
    Function: BuildDMEString()
 
    Purpose:  Helper class method for DMEObject to build an DME string based on an DMEObject 
          passed in.  Could be used stand-alone.
************************************************************/
DMEObject.BuildDMEString = function(vDMEObject)
{
    var vDMEString = portalWnd.DMEPath 
             + "?PROD=" + vDMEObject.pdl
             + "&FILE=" + vDMEObject.file
             + "&INDEX=" + vDMEObject.index
             + "&COND=" + vDMEObject.conditions
             + "&FIELD=" + vDMEObject.fields
             + "&SELECT=" + vDMEObject.select
             + "&MAX=" + vDMEObject.maxRecords
             + vDMEObject.optParams
             +"&OUT=XML&DELIM="+(new Date()).getTime();
 
    //time was added to the unused field "DELIM" so it forces the DME to not used the cached data
 
    return vDMEString;
}
 
/************************************************************
    Function: execute()
 
    Purpose:  Instance method to execute this DME call.  Returns true on success, false on any 
          failure
************************************************************/
DMEObject.prototype.execute = function()
{
    this.dmeString = DMEObject.BuildDMEString(this);
 
    //execute http post
    var vDMEInfo = portalWnd.httpRequest(this.dmeString);
    //if the status exists, there was an error in the system, otherwise proceed to pull data out
    if (vDMEInfo.status)
    {
        this.success = false;
    }
    else
    {
        var xmlObj = new portalWnd.DataStorage(vDMEInfo);
        this.returnRecords = xmlObj.document.getElementsByTagName("RECORD");
        this.columns = getDMEColumnIndex(xmlObj.document.getElementsByTagName("COLUMN"));
        this.length = this.returnRecords.length;
    }
    //return true if it was successful and false if it wasnt    
    return this.success;
}
 
/************************************************************
    Function: toString()
 
    Purpose:  Instance method to aid in debugging.  Returns the current DME string for the
          the fields that have been added to the object so far.
************************************************************/
DMEObject.prototype.toString = function()
{
    this.dmeString = DMEObject.BuildDMEString(this);
    return this.dmeString;
}
/************************************************************
********************* DME OBJECT CODE ***********************
***************** SIMPLIFIES PERFORMING A DME ***************
***************** UPDATED APRIL 2013 for 10.0.3 *************
*************************************************************
*************************************************************	
************************************************************/

/************************************************************
	Function: exampleDme()

	Purpose:  Simple example usign the dme code
************************************************************/
function exampleDme()
{
	//fetch the effective date used so we can send a change action
	var vCo 	= portalWnd.oUserProfile.getAttribute("company");
	var vJobCode 	= "110";

	//set object and table/prodline
	var empDMEObj 	= new DMEObject("JOBCODE", strPDL);

	//set an index
	empDMEObj.setIndex("JBCSET1&KEY=" + vCo + "=" + vJobCode);

	//tell it what fields to fetch
	empDMEObj.addField("EFFECTIVE-DATE");

	//prompt("obj",empDMEObj.toString());
	empDMEObj.execute();

	//grab a field from the dme result
	var vEffectDateHR06 = empDMEObj.getField("EFFECTIVE-DATE");	

	alert(vEffectDateHR06);
}

/************************************************************
	Function: getVarFromString

	Purpose:  get the variables from the search string

	Example:  var vCompany = getVarFromString("Company",parent.location.search);
************************************************************/
function getVarFromString(varName,str)
{
	str+='&'
	reStr="(?:\\&|\\?|^)" + varName + "=(.*?)(?:\\&|$)"
	var re=new RegExp(reStr,"gi")
	if(re.test(str))
		return RegExp.$1
	else
		return ""
}

/************************************************************
	Function: getDMEColumnIndex(pColumns)

	Purpose:  Helper Method used assist in getting DME record data as seen on pg 114 of 
		  Design Studio User Guide
************************************************************/
function getDMEColumnIndex(pColumns)
{
	var vIndex = new Array();
	for (var i=0; i<pColumns.length; i++)
	{
		var vLabel = pColumns[i].getAttribute("header").toUpperCase().split("_").join("-");
		vIndex[vLabel] = i;
	}
	return vIndex;
}

/************************************************************
	Function: getNodeValue(pNode)

	Purpose:  Helper Method used assist in getting DME field data as seen on pg 114 of
		  Design Studio User Guide
************************************************************/
function getNodeValue(pNode)
{
	for (var i=0; i<pNode.childNodes.length; i++)
	{
		if (pNode.childNodes[i].nodeType == 4)
		{
			return pNode.childNodes[i].nodeValue;
		}
	}
}

/************************************************************
	Function: DMEObject

	Purpose:  Constructor.  Return a new DMEObject for a file(table) and productline.
		  Initialize your instance variables.
************************************************************/
function DMEObject(pFile, pPDL)
{
	this.file = pFile;
	this.pdl = pPDL;
	this.index = "";
	this.conditions = "";
	this.fields = "";
	this.select = "";
	this.optParams= "";
	this.dmeString = "";
	this.records = null;
	this.columns = new Array();
	this.length = 0;
	this.maxRecords = 9999;
	this.success = false;
}

/************************************************************
	Function: setIndex(pIndex)

	Purpose:  Instance method for DMEObject.  Takes in a predefined index and sets in in 
		  the object..
************************************************************/
DMEObject.prototype.setIndex = function(pIndex)
{
	this.index = pIndex;

	return true;
}

/************************************************************
	Function: setIndex(pIndex)

	Purpose:  Instance method for DMEObject.  Takes in a predefined index and sets in in 
		  the object..
************************************************************/
DMEObject.prototype.setOptParams = function(pOptParams)
{
	this.optParams = pOptParams;

	return true;
}

/************************************************************
	Function: setConditions(pConditions)

	Purpose:  Instance method for DMEObject.  Takes in a predefined Conditions and sets in in 
		  the object..
************************************************************/
DMEObject.prototype.setConditions = function(pConditions)
{
	this.conditions = pConditions;

	return true;
}

/************************************************************
	Function: setSelect(pSelect)

	Purpose:  Instance method for DMEObject.  Takes in a predefined index and sets in in 
		  the object..
************************************************************/
DMEObject.prototype.setSelect = function(pSelect)
{
	this.select= pSelect;

	return true;
}

/************************************************************
	Function: addField(pField, pFieldValue)

	Purpose:  Instance method for DMEObject.  Takes in a field name and adds it to the 
		  fields portion of the DME string.
************************************************************/
DMEObject.prototype.addField = function(pField)
{
	this.fields += pField+";";

	return true;
}

/************************************************************
	Function: getField(pField)

	Purpose:  Instance method for DMEObject.  Takes in a field name as a parameter and 
		  return's it's value from the DME String.  If pRelRecTable is populated, pField
		  will be ignored and an array will be passed back.
************************************************************/
DMEObject.prototype.getField = function(pField, pRow, pRelRecTable)
{
	var rFieldValue;

	if ((pRow == undefined) ||
	    (pRow == null))
	{
		pRow = 0;
	}
	if ((pRelRecTable == undefined) ||
	    (pRelRecTable == null))
	{
		pRelRecTable = "";
	}

	//if it's not an empty string, we'll return the value from the related record tables
	if (pRelRecTable != "")
	{
		var vNewRelRecsArray = new Array();
		var vRelRecsArray = this.returnRecords[pRow].getElementsByTagName("RELRECS");
//alert(this.returnRecords[0].getElementsByTagName("RELRECS")[0].getElementsByTagName("RELREC")[1].getElementsByTagName("COL")[1].childNodes[0].nodeValue)
		//search each related table record set for one that matches pRelRecTable
		for(var i=0; i < vRelRecsArray.length; i++)
		{
			if (vRelRecsArray[i].getAttribute("name").toUpperCase().split("_").join("-") == pRelRecTable.toUpperCase())
			{
				var vRelRecArray = vRelRecsArray[i].getElementsByTagName("RELREC");
				//search specific related table record set's values
				for(var j=0; j < vRelRecArray.length; j++)
				{
					var vNewRelRecArray = new Array();
					var vRelRecColArray = vRelRecArray[j].getElementsByTagName("COL");

					for(var k=0; k < vRelRecColArray.length; k++)
					{
						var vRelRecColValue = vRelRecColArray[k].childNodes[0].nodeValue;
						vNewRelRecArray.push(vRelRecColValue);
					}
					vNewRelRecsArray.push(vNewRelRecArray)
				}

				break;
			}
		}
		rFieldValue = vNewRelRecsArray;
	}
	else
	{
		var vRecord = this.returnRecords[pRow].getElementsByTagName("COL");

		rFieldValue = getNodeValue(vRecord[this.columns[pField]]);
	}

	return (rFieldValue);
}

/************************************************************
	Function: BuildDMEString()

	Purpose:  Helper class method for DMEObject to build an DME string based on an DMEObject 
		  passed in.  Could be used stand-alone.
************************************************************/
DMEObject.BuildDMEString = function(vDMEObject)
{
	var vDMEString = portalWnd.DMEPath 
			 + "?PROD=" + vDMEObject.pdl
			 + "&FILE=" + vDMEObject.file
			 + "&INDEX=" + vDMEObject.index
			 + "&COND=" + vDMEObject.conditions
			 + "&FIELD=" + vDMEObject.fields
			 + "&SELECT=" + vDMEObject.select
			 + "&MAX=" + vDMEObject.maxRecords
			 + vDMEObject.optParams
			 +"&OUT=XML&DELIM="+(new Date()).getTime();

	//time was added to the unused field "DELIM" so it forces the DME to not used the cached data

	return vDMEString;
}

/************************************************************
	Function: execute()

	Purpose:  Instance method to execute this DME call.  Returns true on success, false on any 
		  failure
************************************************************/
DMEObject.prototype.execute = function()
{
	this.dmeString = DMEObject.BuildDMEString(this);

	//execute http post
	var vDMEInfo = portalWnd.httpRequest(this.dmeString);
	//if the status exists, there was an error in the system, otherwise proceed to pull data out
	if (vDMEInfo.status)
	{
		this.success = false;
	}
	else
	{
		var xmlObj = new portalWnd.DataStorage(vDMEInfo);
		this.returnRecords = xmlObj.document.getElementsByTagName("RECORD");
		this.columns = getDMEColumnIndex(xmlObj.document.getElementsByTagName("COLUMN"));
		this.length = this.returnRecords.length;
	}
	//return true if it was successful and false if it wasnt	
	return this.success;
}

/************************************************************
	Function: toString()

	Purpose:  Instance method to aid in debugging.  Returns the current DME string for the
		  the fields that have been added to the object so far.
************************************************************/
DMEObject.prototype.toString = function()
{
	this.dmeString = DMEObject.BuildDMEString(this);
	return this.dmeString;
}

 

Employee Self-Service Mashup Example

in Smart Office, Smart Office Mashups / No Comments

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="&lt;&lt;HttpServer&gt;&gt;/lawson/xhrnet/registrationbycourse.htm" />
<mashup:NavigationTreeMember Level="1" Label="Reg by Course" Uri="&lt;&lt;HttpServer&gt;&gt;/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="&lt;&lt;HttpServer&gt;&gt;/lawson/xhrnet/careermanagement/employee/mainWinCheesecake.htm" />
                            <mashup:NavigationTreeMember Level="1" Label="Competency Profile" Uri="&lt;&lt;HttpServer&gt;&gt;/lawson/xhrnet/credentials/ecpmain.htm" />
                            <mashup:NavigationTreeMember Level="1" Label="Contract Balances" Uri="&lt;&lt;HttpServer&gt;&gt;/lawson/xhrnet/contractbalances.htm" />
                            <mashup:NavigationTreeMember Level="1" Label="Professional Profile" Uri="&lt;&lt;HttpServer&gt;&gt;/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="&lt;&lt;HttpServer&gt;&gt;/lawson/xhrnet/pajobreq.htm" />
                            <mashup:NavigationTreeMember Level="1" Label="Job Profile" Uri="&lt;&lt;HttpServer&gt;&gt;/lawson/xhrnet/jobprofile.htm" />
                            <mashup:NavigationTreeMember Level="1" Label="Jobs Applied For" Uri="&lt;&lt;HttpServer&gt;&gt;/lawson/xhrnet/pareqapp.htm" />
                            <mashup:NavigationTreeMember Level="1" Label="Phone Book" Uri="&lt;&lt;HttpServer&gt;&gt;/lawson/xhrnet/phonebook.htm" />
                            <mashup:NavigationTreeMember Level="1" Label="Policy Manual" Uri="&lt;&lt;HttpServer&gt;&gt;/lawson/xhrnet/policybook.htm" />
                            <mashup:NavigationTreeMember Level="1" Label="ReviewHistory" Uri="&lt;&lt;HttpServer&gt;&gt;/lawson/xhrnet/reviewhist.htm" />
                            <mashup:NavigationTreeMember Level="1" Label="Work Phone" Uri="&lt;&lt;HttpServer&gt;&gt;/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="&lt;&lt;HttpServer&gt;&gt;/lawson/xhrnet/lifeevents_splash.htm" />
                            <mashup:NavigationTreeMember Level="1" Label="Adoption" Uri="&lt;&lt;HttpServer&gt;&gt;/lawson/xhrnet/adoption.htm" />
                            <mashup:NavigationTreeMember Level="1" Label="Birth" Uri="&lt;&lt;HttpServer&gt;&gt;/lawson/xhrnet/birth.htm" />
                            <mashup:NavigationTreeMember Level="1" Label="Divorce" Uri="&lt;&lt;HttpServer&gt;&gt;/lawson/xhrnet/divorce.htm" />
                            <mashup:NavigationTreeMember Level="1" Label="Legal Separation" Uri="&lt;&lt;HttpServer&gt;&gt;/lawson/xhrnet/legalsep.htm" />
                            <mashup:NavigationTreeMember Level="1" Label="Marriage" Uri="&lt;&lt;HttpServer&gt;&gt;/lawson/xhrnet/marriage.htm" />
                            <mashup:NavigationTreeMember Level="1" Label="Move" Uri="&lt;&lt;HttpServer&gt;&gt;/lawson/xhrnet/homeaddress.htm?from=lifeevents" />
                            <mashup:NavigationTreeMember Level="1" Label="Spouse Employment" Uri="&lt;&lt;HttpServer&gt;&gt;/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="&lt;&lt;HttpServer&gt;&gt;/lawson/xhrnet/directdeposit/ddmain.htm" />
                            <mashup:NavigationTreeMember Level="1" Label="Org Chart" Uri="&lt;&lt;HttpServer&gt;&gt;/lawson/xhrnet/orgchart.htm" />
                            <mashup:NavigationTreeMember Level="1" Label="Pay Checks" Uri="&lt;&lt;HttpServer&gt;&gt;/lawson/xhrnet/paychecks.htm" />
                            <mashup:NavigationTreeMember Level="1" Label="Pay Rate History" Uri="&lt;&lt;HttpServer&gt;&gt;/lawson/xhrnet/payratehistory.htm" />
                            <mashup:NavigationTreeMember Level="1" Label="Payment Modeling" Uri="&lt;&lt;HttpServer&gt;&gt;/lawson/xhrnet/paymentmodeling.htm" />
                            <mashup:NavigationTreeMember Level="1" Label="Tax Withholding" Uri="&lt;&lt;HttpServer&gt;&gt;/lawson/xhrnet/w4/taxwithholding.htm" />
                            <mashup:NavigationTreeMember Level="1" Label="Year To Date" Uri="&lt;&lt;HttpServer&gt;&gt;/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="&lt;&lt;HttpServer&gt;&gt;/lawson/xhrnet/qualifications.htm?type=crt" />
                            <mashup:NavigationTreeMember Level="1" Label="Competencies" Uri="&lt;&lt;HttpServer&gt;&gt;/lawson/xhrnet/qualifications.htm?type=cmp" />
                            <mashup:NavigationTreeMember Level="1" Label="Dependents" Uri="&lt;&lt;HttpServer&gt;&gt;/lawson/xhrnet/dependentsmain.htm" />
                            <mashup:NavigationTreeMember Level="1" Label="Education" Uri="&lt;&lt;HttpServer&gt;&gt;/lawson/xhrnet/qualifications.htm?type=edu" />
                            <mashup:NavigationTreeMember Level="1" Label="Emergency" Uri="&lt;&lt;HttpServer&gt;&gt;/lawson/xhrnet/emergencycontacts.htm" />
                            <mashup:NavigationTreeMember Level="1" Label="Ethnicity" Uri="&lt;&lt;HttpServer&gt;&gt;/lawson/xhrnet/ethnicity.htm" />
                            <mashup:NavigationTreeMember Level="1" Label="Leave Balances" Uri="&lt;&lt;HttpServer&gt;&gt;/lawson/xhrnet/leavebalancebegin.htm" />
                            <mashup:NavigationTreeMember Level="1" Label="Marital Status" Uri="&lt;&lt;HttpServer&gt;&gt;/lawson/xhrnet/maritalstatus.htm" />
                            <mashup:NavigationTreeMember Level="1" Label="Military Status" Uri="&lt;&lt;HttpServer&gt;&gt;/lawson/xhrnet/military.htm" />
                            <mashup:NavigationTreeMember Level="1" Label="Nickname" Uri="&lt;&lt;HttpServer&gt;&gt;/lawson/xhrnet/nickname.htm" />
                            <mashup:NavigationTreeMember Level="1" Label="Personal Profile" Uri="&lt;&lt;HttpServer&gt;&gt;/lawson/xhrnet/emppersonal.htm" />
                            <mashup:NavigationTreeMember Level="1" Label="Veteran Status" Uri="&lt;&lt;HttpServer&gt;&gt;/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="&lt;&lt;HttpServer&gt;&gt;/lawson/xhrnet/timeentry/employee/timeentry.htm?type=daily" />
                            <mashup:NavigationTreeMember Level="1" Label="Exception Entry" Uri="&lt;&lt;HttpServer&gt;&gt;/lawson/xhrnet/timeentry/exception/exception.htm" />
                            <mashup:NavigationTreeMember Level="1" Label="Period Entry" Uri="&lt;&lt;HttpServer&gt;&gt;/lawson/xhrnet/timeentry/employee/timeentry.htm" />
                            <mashup:NavigationTreeMember Level="1" Label="Print Time Entry" Uri="&lt;&lt;HttpServer&gt;&gt;/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="&lt;&lt;HttpServer&gt;&gt;/lawson/xhrnet/registrationbycategory.htm" />
                            <mashup:NavigationTreeMember Level="1" Label="Reg by Course" Uri="&lt;&lt;HttpServer&gt;&gt;/lawson/xhrnet/registrationbycourse.htm" />
                            <mashup:NavigationTreeMember Level="1" Label="Reg by Tracks" Uri="&lt;&lt;HttpServer&gt;&gt;/lawson/xhrnet/registrationbytrack.htm" />
                            <mashup:NavigationTreeMember Level="1" Label="Required Training" Uri="&lt;&lt;HttpServer&gt;&gt;/lawson/xhrnet/patrnreq.htm" />
                            <mashup:NavigationTreeMember Level="1" Label="Scheduled Training" Uri="&lt;&lt;HttpServer&gt;&gt;/lawson/xhrnet/paregister.htm" />
                            <mashup:NavigationTreeMember Level="1" Label="Training History" Uri="&lt;&lt;HttpServer&gt;&gt;/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="&lt;&lt;HttpServer&gt;&gt;/lawson/xhrnet/stockoptions/employee/shr064.htm" />
                            <mashup:NavigationTreeMember Level="1" Label="Savings Modeling" Uri="&lt;&lt;HttpServer&gt;&gt;/lawson/xhrnet/401k/401k.htm" />
                            <mashup:NavigationTreeMember Level="1" Label="Goal View" Uri="&lt;&lt;HttpServer&gt;&gt;/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="&lt;&lt;HttpServer&gt;&gt;/lawson/xhrnet/careermanagement/employee/mainWinCheesecake.htm" />
							<mashup:NavigationTreeMember Level="1" Label="Competency Profile" Uri="&lt;&lt;HttpServer&gt;&gt;/lawson/xhrnet/credentials/ecpmain.htm" />
							<mashup:NavigationTreeMember Level="1" Label="Contract Balances" Uri="&lt;&lt;HttpServer&gt;&gt;/lawson/xhrnet/contractbalances.htm" />
							<mashup:NavigationTreeMember Level="1" Label="Professional Profile" Uri="&lt;&lt;HttpServer&gt;&gt;/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="&lt;&lt;HttpServer&gt;&gt;/lawson/xhrnet/pajobreq.htm" />
							<mashup:NavigationTreeMember Level="1" Label="Job Profile" Uri="&lt;&lt;HttpServer&gt;&gt;/lawson/xhrnet/jobprofile.htm" />
							<mashup:NavigationTreeMember Level="1" Label="Jobs Applied For" Uri="&lt;&lt;HttpServer&gt;&gt;/lawson/xhrnet/pareqapp.htm" />
							<mashup:NavigationTreeMember Level="1" Label="Phone Book" Uri="&lt;&lt;HttpServer&gt;&gt;/lawson/xhrnet/phonebook.htm" />
							<mashup:NavigationTreeMember Level="1" Label="Policy Manual" Uri="&lt;&lt;HttpServer&gt;&gt;/lawson/xhrnet/policybook.htm" />
							<mashup:NavigationTreeMember Level="1" Label="ReviewHistory" Uri="&lt;&lt;HttpServer&gt;&gt;/lawson/xhrnet/reviewhist.htm" />
							<mashup:NavigationTreeMember Level="1" Label="Work Phone" Uri="&lt;&lt;HttpServer&gt;&gt;/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="&lt;&lt;HttpServer&gt;&gt;/lawson/xhrnet/lifeevents_splash.htm" />
							<mashup:NavigationTreeMember Level="1" Label="Adoption" Uri="&lt;&lt;HttpServer&gt;&gt;/lawson/xhrnet/adoption.htm" />
							<mashup:NavigationTreeMember Level="1" Label="Birth" Uri="&lt;&lt;HttpServer&gt;&gt;/lawson/xhrnet/birth.htm" />
							<mashup:NavigationTreeMember Level="1" Label="Divorce" Uri="&lt;&lt;HttpServer&gt;&gt;/lawson/xhrnet/divorce.htm" />
							<mashup:NavigationTreeMember Level="1" Label="Legal Separation" Uri="&lt;&lt;HttpServer&gt;&gt;/lawson/xhrnet/legalsep.htm" />
							<mashup:NavigationTreeMember Level="1" Label="Marriage" Uri="&lt;&lt;HttpServer&gt;&gt;/lawson/xhrnet/marriage.htm" />
							<mashup:NavigationTreeMember Level="1" Label="Move" Uri="&lt;&lt;HttpServer&gt;&gt;/lawson/xhrnet/homeaddress.htm?from=lifeevents" />
							<mashup:NavigationTreeMember Level="1" Label="Spouse Employment" Uri="&lt;&lt;HttpServer&gt;&gt;/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="&lt;&lt;HttpServer&gt;&gt;/lawson/xhrnet/directdeposit/ddmain.htm" />
							<mashup:NavigationTreeMember Level="1" Label="Org Chart" Uri="&lt;&lt;HttpServer&gt;&gt;/lawson/xhrnet/orgchart.htm" />
							<mashup:NavigationTreeMember Level="1" Label="Pay Checks" Uri="&lt;&lt;HttpServer&gt;&gt;/lawson/xhrnet/paychecks.htm" />
							<mashup:NavigationTreeMember Level="1" Label="Pay Rate History" Uri="&lt;&lt;HttpServer&gt;&gt;/lawson/xhrnet/payratehistory.htm" />
							<mashup:NavigationTreeMember Level="1" Label="Payment Modeling" Uri="&lt;&lt;HttpServer&gt;&gt;/lawson/xhrnet/paymentmodeling.htm" />
							<mashup:NavigationTreeMember Level="1" Label="Tax Withholding" Uri="&lt;&lt;HttpServer&gt;&gt;/lawson/xhrnet/w4/taxwithholding.htm" />
							<mashup:NavigationTreeMember Level="1" Label="Year To Date" Uri="&lt;&lt;HttpServer&gt;&gt;/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="&lt;&lt;HttpServer&gt;&gt;/lawson/xhrnet/qualifications.htm?type=crt" />
							<mashup:NavigationTreeMember Level="1" Label="Competencies" Uri="&lt;&lt;HttpServer&gt;&gt;/lawson/xhrnet/qualifications.htm?type=cmp" />
							<mashup:NavigationTreeMember Level="1" Label="Dependents" Uri="&lt;&lt;HttpServer&gt;&gt;/lawson/xhrnet/dependentsmain.htm" />
							<mashup:NavigationTreeMember Level="1" Label="Education" Uri="&lt;&lt;HttpServer&gt;&gt;/lawson/xhrnet/qualifications.htm?type=edu" />
							<mashup:NavigationTreeMember Level="1" Label="Emergency" Uri="&lt;&lt;HttpServer&gt;&gt;/lawson/xhrnet/emergencycontacts.htm" />
							<mashup:NavigationTreeMember Level="1" Label="Ethnicity" Uri="&lt;&lt;HttpServer&gt;&gt;/lawson/xhrnet/ethnicity.htm" />
							<mashup:NavigationTreeMember Level="1" Label="Leave Balances" Uri="&lt;&lt;HttpServer&gt;&gt;/lawson/xhrnet/leavebalancebegin.htm" />
							<mashup:NavigationTreeMember Level="1" Label="Marital Status" Uri="&lt;&lt;HttpServer&gt;&gt;/lawson/xhrnet/maritalstatus.htm" />
							<mashup:NavigationTreeMember Level="1" Label="Military Status" Uri="&lt;&lt;HttpServer&gt;&gt;/lawson/xhrnet/military.htm" />
							<mashup:NavigationTreeMember Level="1" Label="Nickname" Uri="&lt;&lt;HttpServer&gt;&gt;/lawson/xhrnet/nickname.htm" />
							<mashup:NavigationTreeMember Level="1" Label="Personal Profile" Uri="&lt;&lt;HttpServer&gt;&gt;/lawson/xhrnet/emppersonal.htm" />
							<mashup:NavigationTreeMember Level="1" Label="Veteran Status" Uri="&lt;&lt;HttpServer&gt;&gt;/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="&lt;&lt;HttpServer&gt;&gt;/lawson/xhrnet/timeentry/employee/timeentry.htm?type=daily" />
							<mashup:NavigationTreeMember Level="1" Label="Exception Entry" Uri="&lt;&lt;HttpServer&gt;&gt;/lawson/xhrnet/timeentry/exception/exception.htm" />
							<mashup:NavigationTreeMember Level="1" Label="Period Entry" Uri="&lt;&lt;HttpServer&gt;&gt;/lawson/xhrnet/timeentry/employee/timeentry.htm" />
							<mashup:NavigationTreeMember Level="1" Label="Print Time Entry" Uri="&lt;&lt;HttpServer&gt;&gt;/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="&lt;&lt;HttpServer&gt;&gt;/lawson/xhrnet/registrationbycategory.htm" />
							<mashup:NavigationTreeMember Level="1" Label="Reg by Course" Uri="&lt;&lt;HttpServer&gt;&gt;/lawson/xhrnet/registrationbycourse.htm" />
							<mashup:NavigationTreeMember Level="1" Label="Reg by Tracks" Uri="&lt;&lt;HttpServer&gt;&gt;/lawson/xhrnet/registrationbytrack.htm" />
							<mashup:NavigationTreeMember Level="1" Label="Required Training" Uri="&lt;&lt;HttpServer&gt;&gt;/lawson/xhrnet/patrnreq.htm" />
							<mashup:NavigationTreeMember Level="1" Label="Scheduled Training" Uri="&lt;&lt;HttpServer&gt;&gt;/lawson/xhrnet/paregister.htm" />
							<mashup:NavigationTreeMember Level="1" Label="Training History" Uri="&lt;&lt;HttpServer&gt;&gt;/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="&lt;&lt;HttpServer&gt;&gt;/lawson/xhrnet/stockoptions/employee/shr064.htm" />
							<mashup:NavigationTreeMember Level="1" Label="Savings Modeling" Uri="&lt;&lt;HttpServer&gt;&gt;/lawson/xhrnet/401k/401k.htm" />
							<mashup:NavigationTreeMember Level="1" Label="Goal View" Uri="&lt;&lt;HttpServer&gt;&gt;/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>

 

 

Mashups Inside Form Tabs, and the Ability to Pass Data to Them

in Smart Office, Smart Office Mashups / No Comments

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.

 

 

Using LSO Scripting to Access SQL Database Directly

in Smart Office, Smart Office Scripting / No Comments

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

} }

PO30 Display the Line Unit Cost on Each Line – Smart Office Scripting

in Lawson, Smart Office, Smart Office Scripting / No Comments

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;
	}

} }