this and that

SBM AppScript Use Cases - 01. Validate Work Effort Fields 본문

SBM

SBM AppScript Use Cases - 01. Validate Work Effort Fields

미스터림 2011. 10. 28. 14:45

Est. Work Effort 라는 필드가 있다고 가정하자. 보통 시간 단위로 입력한다.
프로세스를 진행할 때에 예상 작업 시간이 1보다 작을 경우 에러메시지를 표시하고 진행할 수 없도록 처리하는 스크립트이다.

' Name: validateEstWorkEffort
' Function: Check the Est. Work Effort field for a value larger than 0.
' Context: Pre-state for Approved state
'
' Date: 03/09/2006
' For use in the TeamTrack TeamScript course examples.

' Require all vars to be declared before use (and then declare some)
Option Explicit
Dim objItem, objFields, objField
Dim nEstWorkEffort, bFailure, strErrorMsg

bFailure = false
strErrorMsg = ""

' Get the shell's objItem object (VarRecord/AppRecord)
If Ext.ShellHasProp( "Item" ) Then
  Set objItem = Shell.Item
  
  ' Get the objItem's objobjFields object
  Set objFields = objItem.Fields()
  
  ' Get the Est Work Effort objField's object
  Set objField = objFields.FindField( "EST_WORK_EFFORT" )
  
  ' Get the value of the Est Work Effort field
  objField.GetValue nEstWorkEffort
  
  ' Check for valid field value.
  If nEstWorkEffort < 1 Then
    bFailure = true
    strErrorMsg = strErrorMsg & "The Est. Work Effort field must be greater than 0."
  End If

' No shell objItem, if possible display browser error message
Else
  If Ext.ShellHasProp( "redoMessage" ) Then
    bFailure = true
    strErrorMsg = strErrorMsg & "Error: No current issue."
  End If
End If

' Set the redoMessage shell variable to the message.
' TeamTrack recognizes anything in this variable as an error and will reject the form and display the message.
If bFailure And Ext.ShellHasProp( "redoMessage" ) Then
  Shell.redoMessage = strErrorMsg
End If

Comments