I've found this code below, but it seems like only acceptable value to update is string. I need to update DateTime field.
def theDate = new Date(idleStart.getTime())
//log.info(theDate.toString())
int reportingNameId = 228
def reportingNameTypeAttributeBean = objectTypeAttributeFacade.loadObjectTypeAttributeBean(reportingNameId);
//log.info(reportingNameTypeAttributeBean.toString())
def reportingNameAttributeBean = objectAttributeBeanFactory.createObjectAttributeBeanForObject(objectID, reportingNameTypeAttributeBean, theDate.toString());
//log.info(reportingNameTypeAttributeBean.getId().toString())
//log.info(objectID.getId().toString())
//log.info(objectID.toString())
def insightObjectAttributeBean = objectFacade.loadObjectAttributeBean(objectID.getId(), reportingNameTypeAttributeBean.getId());
//log.info(insightObjectAttributeBean.toString())
if (insightObjectAttributeBean != null) {
/* If attribute exist reuse the old id for the new attribute */
reportingNameAttributeBean.setId(insightObjectAttributeBean.getId());
//log.info(reportingNameAttributeBean.toString())
}
/* Store the object attribute into Insight. */
try {
insightObjectAttributeBean = objectFacade.storeObjectAttributeBean(reportingNameAttributeBean);
//log.info(insightObjectAttributeBean.toString())
}
catch (Exception vie) {
log.warn("Could not update object attribute due to validation exception:" + vie.getMessage());
}
I am gettin the error below when trying to push Date type value into Insight object. String value work perfectly fine though
groovy.lang.MissingMethodException: No signature of method: com.riadalabs.jira.plugins.insight.services.model.factory.ObjectAttributeBeanFactoryImpl.createObjectAttributeBeanForObject() is applicable for argument types: (com.riadalabs.jira.plugins.insight.services.model.MutableObjectBean, com.riadalabs.jira.plugins.insight.services.model.ObjectTypeAttributeBean, java.util.Date) values: [Тест ке 1 (DSFSF-25), ObjectTypeAttributeBean [id=228, name=Дата начала простоя, type=DEFAULT], ...] Possible solutions: createObjectAttributeBeanForObject(com.riadalabs.jira.plugins.insight.services.model.ObjectBean, com.riadalabs.jira.plugins.insight.services.model.ObjectTypeAttributeBean, [Ljava.lang.String;), createObjectAttributeBeanForObject(com.riadalabs.jira.plugins.insight.services.model.ObjectBean, com.riadalabs.jira.plugins.insight.services.model.ObjectTypeAttributeBean, java.text.DateFormat, java.text.DateFormat, [Ljava.lang.String;)
I was looking for the same information ... and after failing to find anything in the community, I figured a way to set the date value.
I could not find how to use the createObjectAttributeBeanForObject(ObjeacBean objectBean, ObjectTypeAttributeBean ota, DateFormat dateFormat, DateFormat dateFormat, String value) signature, but the following worked for me (assumed you already have facades and factories loaded)
def testObjectId = 62410
def dateAttributeId = 198
def object = objectFacade.loadObjectBean(testObjectId)
def objectTypeAttributeBean = objectTypeAttributeFacade.loadObjectTypeAttributeBean(dateAttributeId )
def objectAttributeBean = object.createObjectAttributeBean(objectTypeAttributeBean)
def objectAtrributeValueBean = objectAttributeBean.createObjectAttributeValueBean()
objectAtrributeValueBean.setDateValue(new Date())
objectAttributeBean.setObjectAttributeValueBeans([valBean])
objectFacade.storeObjectAttributeBean(objectAttributeBean)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.