Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Update Insight DateTime value

Gleb Kartashov
Contributor
August 2, 2019

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;)

1 answer

2 votes
PD Sheehan
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 17, 2020

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)
Adam Hraban September 14, 2020

Thanks! :) 

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events