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())
int reportingNameId = 228
def reportingNameTypeAttributeBean = objectTypeAttributeFacade.loadObjectTypeAttributeBean(reportingNameId);
def reportingNameAttributeBean = objectAttributeBeanFactory.createObjectAttributeBeanForObject(objectID, reportingNameTypeAttributeBean, theDate.toString());
def insightObjectAttributeBean = objectFacade.loadObjectAttributeBean(objectID.getId(), reportingNameTypeAttributeBean.getId());
if (insightObjectAttributeBean != null) {
/* If attribute exist reuse the old id for the new attribute */
/* Store the object attribute into Insight. */
try {
insightObjectAttributeBean = objectFacade.storeObjectAttributeBean(reportingNameAttributeBean);
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: is applicable for argument types: (,, java.util.Date) values: [Тест ке 1 (DSFSF-25), ObjectTypeAttributeBean [id=228, name=Дата начала простоя, type=DEFAULT], ...]
Possible solutions: createObjectAttributeBeanForObject(,, [Ljava.lang.String;), createObjectAttributeBeanForObject(,, 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())

Suggest an answer

Log in or Sign up to answer
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