Update Change Page Two Date Field Using Groovy (Doc ID 2057372.1)

Last updated on NOVEMBER 19, 2016

Applies to:

Oracle Agile PLM Framework - Version 9.3.3.0 and later
Information in this document applies to any platform.

Symptoms

Can't update date field by using Groovy

Error: Deviation Approved Date:"09/02/2015 03:36:39 PM PDT" is not a valid value for attribute 2004. "
"Deviation Approved Date:groovy.lang.MissingMethodException: No signature of method: com.agile.agileDSL.ScriptObj.ChangeStatusScriptObj.setValueByAttId() is applicable for argument types: (java.lang.Integer, java.util.Date) values: {2004, Wed Sep 02 22:35:36 GMT 2015}"

Steps to reproduce:
1. Create Date type field "Date Approved" field on Deviations Page Two
2. Create script px as Change Status Event with event handler populating "Date Approved" with current date when Deviation moves from one status to another.
3. Script PX throws below errors "Deviation Approved Date:"09/02/2015 03:36:39 PM PDT" is not a valid value for attribute 2004. " or "Deviation Approved Date:groovy.lang.MissingMethodException: No signature of method: com.agile.agileDSL.ScriptObj.ChangeStatusScriptObj.setValueByAttId() is applicable for argument types: (java.lang.Integer, java.util.Date) values: {2004, Wed Sep 02 22:35:36 GMT 2015}"

Sample Groovy

import com.agile.agileDSL.ScriptObj.IBaseScriptObj
import java.util.Date;
import java.text.SimpleDateFormat;
import com.agile.api.ChangeConstants;
import com.agile.api.CommonConstants;
void invokeScript(IBaseScriptObj obj) {
 String changeNumber = obj.getObjectNumber();
 obj.logMonitor("Change Number : "+ changeNumber);
 if(changeNumber != null){
    devAppDate = ChangeConstants.ATT_PAGE_TWO_DATE03;
    Date date = new Date();
    SimpleDateFormat df = new SimpleDateFormat("MM/dd/yyyy hh:mm:ss a z");
    TimeZone timeZone = TimeZone.getTimeZone("America/Los_Angeles");
    df.setTimeZone(timeZone);

    String appDate = df.format(date);
     obj.logMonitor("Updated Date Approved: "+appDate);
     Date newDate = df.parse(appDate);
     obj.logMonitor("newDate : " + newDate);
     //changeNumber.setValue(devAppDate,newDate);
    obj.setValueByAttId(devAppDate,appDate);
 }
}

Cause

Sign In with your My Oracle Support account

Don't have a My Oracle Support account? Click to get started

My Oracle Support provides customers with access to over a
Million Knowledge Articles and hundreds of Community platforms