this and that

SBM AppScript Use Cases - 02. Calculate Work Effort Difference 본문

SBM

SBM AppScript Use Cases - 02. Calculate Work Effort Difference

미스터림 2011. 10. 28. 15:15
이번 스크립트는 예상 작업 시간과 실제 작업 시간의 값의 차이를 계산하여 경우에 따라 해당되는 필드에 값을 입력하는 시나리오이다. 프로세스가 종료될 때 예상 시간보다 실제 시간이 초과했을 경우 Work Effort Over에 차이값을 입력을 하고, 초과하지 않았을 경우 Work Effort Under에 차이값을 입력을 한다.


' Name: calcWorkEffort
' Function: Find the difference between Est. Work Effort and
'    Act. Work Effort and set the proper field value:
'    Work Effort Over or Work Effort Under
' Context: Post-transition on Complete transition
'
' 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, nActWorkEffort, nDifference

' 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 and value
  Set objField = objFields.FindField( "EST_WORK_EFFORT" )
  objField.GetValue nEstWorkEffort
  
  ' Get the Act Work Effort objField's object and value
  Set objField = objFields.FindField( "ACT_WORK_EFFORT" )
  objField.GetValue nActWorkEffort
  
  ' Calculate the difference
  nDifference = nActWorkEffort - nEstWorkEffort
'  Shell.redoMessage = nActWorkEffort & " - " & nEstWorkEffort & " = " & nDifference
  
  ' Determine which field to set.
  If nDifference < 0 Then
    ' Get the Work Effort Under objField's object and set its value
    Set objField = objFields.FindField( "WORK_EFFORT_UNDER" )
    Call objField.SetValue(Abs(nDifference))
  Else
    ' Get the Work Effort Over objField's object and set its value
    Set objField = objFields.FindField( "WORK_EFFORT_OVER" )
    Call objField.SetValue(nDifference)
  End If

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

Comments