I'm working on migrating some fields from DC to Cloud. One of the fields has this script for Calculated (scripted) Number Field.
issue.get("customfield_21408")==null ? null : (issue.get("customfield_21408").getTime() - issue.get("created").getTime()) / 1000 / 60
Can someone teach me the api equivalent of it? I tried looking into the documentations but couldn't really see a good guide.
Hi @Marc Jason Mutuc ,
Thanks for reaching out!
Please use the below script in a JCMF scripted field to get a difference of two datetime fields.
const createdAt = await api.issue.getField(issue, "created")
console.log(createdAt)
const resolvedAt = await api.issue.getField(issue, "resolutiondate")
console.log(resolvedAt)
console.log(resolvedAt - createdAt)
if(resolvedAt != null)
{
return (new Date(resolvedAt).getTime() - new Date(createdAt).getTime())/1000/60
}
Please change the fields in the script above as per your requirement.
BTW I am from Appfire, a vendor of JMCF app.
Hope this helps!
Thanks
Reshma
Thanks Reshma! I'll try it out. Is there any documentation for this? I will be using it more and would like to be able to do it on my own.
This one doesn't show a lot
https://appfire.atlassian.net/wiki/spaces/JMCFC/pages/731676729/Scripted+Field
Very different to the documentation for DC. I am hoping you can provide me some links.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
For example, how to I get custom field values in cloud?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Marc Jason Mutuc ,
You can get the custom field values through the custom field ID, as shown below:
const createdAt = await api.issue.getField(issue, "created")
console.log(createdAt)
const resolvedAt = await api.issue.getField(issue, "customfield_10078")
console.log(resolvedAt)
if(resolvedAt != null)
{
return (new Date(resolvedAt).getTime() - new Date(createdAt).getTime())/1000/60
}
As we have released scripted fields in the JMCF cloud app quite recently, we are still working on improving our documentation.
Thank you for trying out scripted fields!
Thanks,
Reshma
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.