Archive

Posts Tagged ‘WinStudio’

Obtaining Username in form script

October 24th, 2011 5 comments

In syteline 7 it was SessionManager.BaseUserName.
In Syteline 8

  • Create form component ‘UserEdit’ and bind it to variable ‘User’ with initial value ‘USERNAME()’
  • Get the value on form script by ‘ThisForm.Variables(“User”).Value’
    This will return the UserID who login to Syteline.
  • Use System.Environment.UserName to get the UserID login to Windows.

Here is a sample screen shot

ScreenHunter_04 Mar. 21 10.29

AUTONUMBER

October 15th, 2011 No comments

In Syteline form grid, if you have line# and you want it to be auto populated, you may use the AUTONUMBER function, just set the component default value property to AUTONUMBER.

Syntax

AUTONUMBER( [ STEP( ) ] [ FILTER( ) ] )

Remarks

During processing of the New standard operation, AUTONUMBER sets the value of the component to the highest value of a property, determined from both the collection and the application database, plus the increment specified by the argument of STEP.

If STEP( ) is omitted, AUTONUMBER uses a default increment of 1, setting the value of the component to one greater than the highest value in the collection and in the application database.

If FILTER is omitted, WinStudio attempts to construct filter criteria to retrieve the current maximum value from the application database.

Example

AUTONUMBER(STEP(1) FILTER(OrderNo=FP(OrderNo)))

Return value of a Method Call Validator

May 18th, 2010 No comments

I have been trapped on this more than one time.  In order for a method call validator to work, the return value has to be bigger than 5.  This is clearly state in the WinStudio document: “If the method returns a value less than 5, WinStudio passes the validation. Otherwise, WinStudio fails the validation. The values 1 through 4 are used for warnings.”

All the standard Syteline Validators are using return value 1, so you would naturally copy that logic, and have it kept pumping on your face.  The value 1 through 4 are reserved for system use.  For customization developer like you and me, we have to be taller than 5.

Today I have waste two hours on this.  I knew it can not be 1, because I was trapped on this about a year ago.  But I forgot what the exact value benchmark is.  I was putting a value 4 on it.  And keep searching other area for error.  Finally I checked back into the document and found out again the magic number 5.  What a fool. 

Change sorting of a pull down list

April 28th, 2010 No comments

From out of box Syteline, the pull down list of customer# field is sorted by customer#.  The same thing happens to the vendor# field.  Many Syteline users would prefer that the pull down list is sorted by customer name / vendor name in alphanumeric order, especially when you have hundreds customers/vendors.

Syteline Application Case

Change the sorting of Customer#/Vendor# pull down list, from Customer#/Vendor# to Customer Name/Vendor Name.

Syteline Technical Components

Component class, List Source

Customization Solution

The pull down list of a field is usually controlled by the component class that the field inheritance.

Get into the design mod of the form, example like RMA form.  Click the Customer field, then, in component property sheet, locate the Inheritance, Component Class.  Open the component class “RMACustomerZero”

Syteline Component Class

Open the List Sources

Syteline List Source

Click the “Filter etc.” button

Syteline List Source

Enter “Name” in OrderBy field.

Then click OK all the way back.  Save the form.  Now, try the pull down list, it is now sorted by name in alphanumeric order.

Change the sorting in primary collection grid

April 1st, 2010 No comments

The out of box Syteline missed some of the detail carelessly.  For example, the Grid view for RMA is sorted by RMA date ascending.  So it shows the oldest RMA up front and you are seeing those years old closed RMAs.

Syteline Application Case

Change the sorting of Grid view in RMA form, to show the latest RMA up front.

Syteline Technical Component

Form, Primary Collection, Collection Property

Customization Solution

This is pretty easy to change.  Go to Edit mod, in the form collection property, change the Order by to “RmaNum Desc”.  Done.

Syteline RMA

Set default ship via code based on customer type

March 23rd, 2010 1 comment

In Syteline, there are many ways to default field value.  The most simple way is to use the default value property of the field component.  But if you need to set the default value based on some other field value, that simple property value would not cut it.

Syteline Application Case

We want to default ship via code in Customer Ship To form based on customer type.

Syteline Technical Components

Event Handler, Inline Script, SQL Store Procedure.

Customization Solution

Since the customer type is in Customer form, but not in Ship To form, we need to get that in.

1) Create a simple SP: nGetCustType

ALTER PROCEDURE [dbo].[navGetCustType]
(@CustNum [CustNumType],
@CustType [CustTypeType] output)

as

select @CustType = cust_type
from customer
where cust_num = @CustNum and cust_seq = 0

2) Add a new event handler to event:StdObjectNewCompleted, to call the following Inline Script:

Option Explicit On
Option Strict On

Imports System
Imports Microsoft.VisualBasic
Imports Mongoose.IDO.Protocol
Imports Mongoose.Scripting

Namespace SyteLine.GlobalScripts
Public Class EvHandler_StdObjectNewCompleted_5
Inherits GlobalScript

Sub Main()

Dim nRetVal As InvokeResponseData
Dim nRequest As New InvokeRequestData()

nRequest.IDOName = “SP!”
nRequest.MethodName = “nGetCustType”

nRequest.Parameters.Add(ThisForm.PrimaryIDOCollection.GetCurrentObjectProperty(“CustNum”))
nRequest.Parameters.Add(“”)

nRetVal = IDOClient.Invoke(nRequest)

ThisForm.Variables(“vCustType”).Value = nRetVal.Parameters(1).ToString

if ThisForm.Variables(“vCustType”).Value = “AAA” or _
ThisForm.Variables(“vCustType”).Value = “BBB”  then
ThisForm.PrimaryIDOCollection.SetCurrentObjectPropertyPlusModifyRefresh _
(“ShipCode”, “UPRP”)
else
ThisForm.PrimaryIDOCollection.SetCurrentObjectPropertyPlusModifyRefresh _
(“ShipCode”, “UP7A”)
end if
ReturnValue = “0”
End Sub
End Class
End Namespace

Within this script, we call the SP, get the Customer Type, then based on the customer type to set the ShipCode value.