From DC to Cloud JMCF

Marc Jason Mutuc
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 18, 2024

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.

1 answer

0 votes
Reshma Begum _Appfire_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 18, 2024

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

Marc Jason Mutuc
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 18, 2024

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.

Marc Jason Mutuc
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 18, 2024

For example, how to I get custom field values in cloud?

Reshma Begum _Appfire_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 18, 2024

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

Suggest an answer

Log in or Sign up to answer