Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Update Insight DateTime value

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

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)

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Apps & Integrations

🍻🍂Apptoberfest Update: Upcoming Virtual Events 🎉

Hello Community! I hope you've been enjoying the 🍂Apptoberfestivities🍂 (I know I have!) The event is heating up next week with a series of virtual events that we're calling the 🍻🍂Partner App ...

682 views 7 23
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you