1

I'm in the process of learning basic programming (now reading through SICP now) for the purpose of writing Groovy scripts to deploy in Oracle Agile PLM. I've gone through a couple Java tutorials online, and I'm reading through the Groovy Recipes book as well. I'm trying to deploy some basic scripts as I go, and I've run into some issues with an if else statement. I'm hoping someone can point me in the right direction. In this case 1272 and 1332 are attribute IDs. When attribute 1272 equals 'Stock' (an attribute populated by a list), then attribute 1332 (a text field) should equal 'AWESOME'. For all other values of attribute 1272, attribute 1332 should equal 'NOT AWESOME'. Here's what I have right now:

import com.agile.agileDSL.ScriptObj.IBaseScriptObj
// add other import statements here
void invokeScript(IBaseScriptObj obj) {
//script body starts here.

     def session = obj.getAgileSDKSession()
     def objectClassId = obj.getObjectClassId()
     def objectNumber = obj.getObjectNumber()

     def dataObject = session.getObject(objectClassId, objectNumber) {
         if ((dataObject.getValue(1272)) ==  'Stock') {
              dataObject.setValue(1332, 'AWESOME')
         }  else {
                  dataObject.setValue(1332, 'NOT AWESOME') }
     }
}

With this and other variations I've tried I keep getting the "groovy.lang.MissingMethodException: No signature of method" error.

4

1 回答 1

1

不确定您正在使用的库,但您是否应该在 getObject() 之后使用花括号?也许可以尝试...

def dataObject = session.getObject(objectClassId, objectNumber) 
if ((dataObject.getValue(1272)) ==  'Stock') {
    dataObject.setValue(1332, 'AWESOME')
} 
else {
       dataObject.setValue(1332, 'NOT AWESOME') 
}
于 2017-03-02T07:47:14.877 回答