Archive

Posts Tagged ‘Inline Script’

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.

Assigning field value in a Syteline Form, based on another field value entered. (1)

February 17th, 2010 No comments

In Syteline form, quite often, you would need to assign some field value, base on another field value entered.

Business case:

Let say in Customer Order, for certain payment terms, you would not allow partial shipment.  So in the CO header form, when user select certain payment term, you want the system automatically uncheck the “Ship Partial” check box.

Syteline Technical Components:

Inline Script, Event Handler

Solution

In Syteline 7 & 8, there is quite a few differ ways to accomplish this.  The first one we are going to discuss here is to use Inline Script.

1)      In Customer Order Form, for form component: TermCodeEdit, add a data change event: TermChange.  And the event handler will call an Inline Script

2)      The 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_TermChange_0

Inherits GlobalScript

Sub Main()

if ThisForm.PrimaryIDOCollection.GetCurrentObjectProperty(“TermsCode”) = “128” then

ThisForm.PrimaryIDOCollection.SetCurrentObjectPropertyPlusModifyRefresh _

(“ShipPartial”, “0”)

end if

ReturnValue = “0”

End Sub

End Class

End Namespace

This script will assign the ShipPartial to 0, when user select TermsCode = 128.