Extract RST hours in javascript advanced import

Hi all,

I’m trying to compare the RST hours of an issue in a if statement but can’t understand how to get the hours:

issue.fields.customfield_13227 = “0h 0m”
or
_.values(issue.fields.customfield_13227).getHour() = 0

Both won’t work and I couldn’t understand the object returned in _.values(issue.fields.customfield_13227).
It seems to have many objects inside the main object (21, ‘RST - Response Time’, Object:object, Object:object, Object:object, Object:object).

Btw, is there a way to print the structure of an object using underscore.js? Even the _.get function isn’t recognized by EazyBI import.

Best,
Danilo

Hi @Danilo,

Please share the structure of the custom field in question. The JavaScript GetHours() method can return the hours from a date - Date.prototype.getHours() - JavaScript | MDN.

You may want to transform the custom field value to date first with new Date(Date.parse(issue.fields.customfield_13227)). You can see such an example for retrieving the hours of issue creation from the creation date here - Generate count of issues created per day and per hour.

You can access the custom field structure in custom JavaScript code in the eazyBI import options. See more details here - JavaScript calculated custom fields.

Best,
Roberts // support@eazybi.com

Hey @roberts.cacus ,

Thank you for the help, I wasn’t tranforming it to Date and it was the issue.
It’s working fine now :slight_smile:

Best Regards,
Danilo

1 Like