JMWE's Live Field

İclal Aslan
Contributor
December 10, 2024

I started using Live Fields by appfire , if you have jmwe you can use it witch I have.

I am trying to perevent people to log work after the 5th a-day of the month for the dates before.

Can you help me with the script?

 

 

const today = new Date();
const currentMonth = today.getMonth() + 1; // Mevcut ay (1 = Ocak, 12 = Aralık)
const currentDay = today.getDate();

if (currentDay > 5) {
    // Önceki ayın son günü
    const lastAllowedDate = new Date(today.getFullYear(), currentMonth - 1, 0); // Geçerli aydan bir önceki ayın son günü

    // Time Spent alanındaki değeri kontrol et
    LiveFields.onFieldChange('timespent', function(field, value) {
        const logDate = new Date(value); // Kullanıcının girdiği zamanı al

        // Eğer log tarihi önceki ay veya daha eskiyse uyarı ver ve değeri temizle
        if (logDate <= lastAllowedDate) {
            logger.warn('Geçerli ayın 5\'inden sonra önceki aylar için zaman girişi yapılamaz.');
            field.setValue(null); // Değeri sıfırlayarak log girişini engelle
        }
    });
}

1 answer

1 vote
Avinash Bhagawati {Appfire}
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
December 10, 2024

Hi @İclal Aslan Good day!

Currently, the timespent field is not supported by Jira’s UiModification API

https://developer.atlassian.com/platform/forge/apis-reference/jira-api-bridge/uiModifications/?_ga=2.193738413.1853332841.1732524211-477394109.1726125732#issue-view--preview-

As a result, LiveField is unable to implement any changes to this field.

Additionally, LiveField on Cloud operates within specific limitations, allowing it to modify only those fields permitted by Jira, rather than utilizing querySelector for broader modifications.

Please let me know if you have any additional questions.

Thanks,
Avinash

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events