Just a heads up: On March 24, 2025, starting at 4:30pm CDT / 19:30 UTC, the site will be undergoing scheduled maintenance for a few hours. During this time, the site might be unavailable for a short while. Thanks for your patience.
×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.
Atlassian Government Cloud has achieved FedRAMP Authorization at the Moderate level! Join our webinar to learn how you can accelerate mission success and move work forward faster in cloud, all while ensuring your critical data is secure.
Register Now
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.