2016-10-13 6 views
0

これは本当に新しいですが、このコードを使用しようとしていて、カスタムフィールド値を更新していません。JIRAでGroovyでcustomFieldの値を設定するJAVA

何か考えてみませんか?私は私の終わりにその光景を推測しています。

Caught: groovy.lang.MissingMethodException: No signature of method: Custom.getTime() is applicable for argument types:() values: []

あそこgetTime()が起動されていないこと:すべてのヘルプは非常にそれが次のエラーで私に失敗し、スタンドとして

def rush = getCustomFieldValue("Rush?") 
if (rush=="Yes") { 
    def cal = new java.util.GregorianCalendar(); 
    cal.setTimeInMillis(customField.setCustomFieldValue("Rush Date", getTime())); 
    return new java.sql.Timestamp(cal.getTimeInMillis()); 
} 
else { 
    return null 
} 

は、あなたのスニペット

import com.atlassian.jira.ComponentManager 
import com.atlassian.jira.issue.customfields.manager.OptionsManager 

def componentManager = ComponentManager.instance 
def optionsManager = ComponentManager.getComponentInstanceOfType(OptionsManager.class) 
def customFieldManager = componentManager.getCustomFieldManager() 

def cf = customFieldManager.getCustomFieldObjectByName("Rush?") 
def rush = issue.getCustomFieldValue(cf) 
def paymentDate = new Date() 

if (rush?.value=="Yes"){ 
if (paymentDate){ 
    def cal = new java.util.GregorianCalendar(); 

    cal.setTimeInMillis(paymentDate.getTime()); 
    cal.add(java.util.Calendar.DAY_OF_MONTH, 0); 

    return new java.sql.Timestamp(cal.getTimeInMillis()); 
} 
else { 
    return null 
}} 

答えて

1

を解決高く評価されどんなオブジェクトからでも。

def customField 
customField = [ 
    'Rush?':'Yes', 
    setCustomFieldValue : { field, value -> customField[field] = value } 
] 

getCustomFieldValue = { customField[it] } 

def rush = getCustomFieldValue("Rush?") 
def cal = new java.util.GregorianCalendar() 

def parseRush = { 
    if (rush=="Yes") { 
     customField.setCustomFieldValue("Rush Date", cal.getTime()) 
     return new java.sql.Timestamp(cal.getTimeInMillis()) 
    } 
    else { 
     return null 
    } 
} 

assert parseRush() == new java.sql.Timestamp(cal.timeInMillis) 
assert customField['Rush Date'] == cal.time 
+0

は正しい方法でカスタムフィールドの値を参照し、私の問題府の鼻水が判明:私はこのように、cal.setTimeInMillis()¹が必要とされていない、あなただけのcustomFieldsetCustomFieldValueにしたいと思います。私もコードを変更しました。 –

関連する問題