During the time of maintenance/backend changes, we want a dialogbox to pop up when a user logs in, Something that displays a msg saying "During this particular time , maintenance is going to be happening"
We were able to achieve this using script Fragment
My question is, is it possible to schedule timing for this pop up , instead of going and enabling each time, & is there anyway a user can modify the msg for this pop up without touching the code (We want a different team apart from the Jira admins to handle this)
Hi @AisM
I've written a community article how to configure a project banner in Jira Data Center using the global announcement banners. You can check out the code over there and modify it according to your needs.
You may want to do these modifications:
var myFlag = AJS.flag({
type: 'info',
body: 'The next downtime is scheduled for 3pm.',
});
You still need Jira admin rights for accessing the global announcement banners though, unless you add some more code that the text loads from another location.
Maybe that helps leading you into some solution.
Cheers,
Matthias.
@Matthias Gaiser _K15t_ Thank you for the comment :):)
We are looking for a way to have a dialog box pop up, not a banner. For now we are able to achieve that using script fragments. But, trying to find a way to update the dates for this script fragment to work through a service desk form. Basically, we do want a different user group to have control over when the dialog box should pop up.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @AisM
I hope you're well. I would suggest configuring announcement banners but it needs admin privilege and I don't think there is a way for team members to achieve that.
@Matthias Gaiser _K15t_'s article seems very helpful, but as he mentioned it still needs Jira admin and you need to improve the code if you want team members to modify it (like getting the information from a DB table which those team members will have access to update).
Thanks!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Tuncay Senturk _Snapbytes_ Thank you for the comment. Sadly, the org does not want a banner
We were able to create that dialog box using Script fragments. But updating the dates & msg for this box through the UI is the challenge :(
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Tuncay Senturk _Snapbytes_ - We were able to somehow update the dates through a hardcoded issue key in the fragment. Updating the date in the key enabled the fragment.
Can you PLEASE PLEASE help with one question. The fragment only pops up ONCE per user. Is there any way that could be fixed ? Not sure why that happens
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I'm not entirely sure if I can assist with this, but let me begin by asking where you placed this code. How do you run this code?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Sure, Any help is better than nothing. Been searching all day to understand if similar use case exists :)
I have the below code in the SCRIPT FRAGMENT as a "Show a web Panel". The time period for when to show this panel is controlled through the issuekey (TEST-2)
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.user.UserPropertyManager
import com.opensymphony.module.propertyset.PropertySet
import java.time.*
import java.time.temporal.*
import com.atlassian.jira.dateTime.*
import com.atlassian.jira.dateTime.*
import org.apache.log4j.Logger
import org.apache.log4j.Level
def log1 = Logger.getLogger("Shackles");
log1.setLevel(Level.DEBUG);
def key = "TEST-2" //This is the service ticket from where its picking the date
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def startdate = customFieldManager.getCustomFieldObjectByName("Announcement Start") // name of custom field
def enddate = customFieldManager.getCustomFieldObjectByName("Announcement End") // name of custom field
def issueManager = ComponentAccessor.getIssueManager()
def issu = issueManager.getIssueObject(key)
def start =(Date) issu.getCustomFieldValue(startdate)
def end = (Date) issu.getCustomFieldValue(enddate)
def today = new Date();
log1.info("today:"+today)
log1.info("start:"+start)
log1.info("end:"+end)
String newInfoTag = "Message Update"
def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser();
def userPropertyManager = ComponentAccessor.getOSGiComponentInstanceOfType(UserPropertyManager.class);
def userProperty = userPropertyManager.getPropertySet(user)?.getString("Outage Box2");
log1.info("userProperty:"+userProperty)
log1.info("newInfoTag:"+newInfoTag)
if ((userProperty != newInfoTag) && (today>=start && today<=end)) {
log1.info("Success:")
return true
}
return false
This does make the dialog box show up with a OKAY button, when a user logs into Jira. But, it only comes once per user. Once, the user clicks OKAY. It doesn't show up again. Can't seem to figure out what we are missing.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I am sorry, I am unable to find out why it only shows once per user. In my opinion, there is nothing wrong with the code, but I am unfamiliar with SR's fragments and how to use them.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Tuncay Senturk _Snapbytes_ Actually, I referred some of the previous code you had helped with & was able to somehow fix that problem. But, now it shows the pop up box, each time the URL is refreshed. So frustrating :( The updated code is as below,
import com.atlassian.jira.web.bean.PagerFilter
import com.atlassian.jira.bc.issue.search.SearchService
def log1 = Logger.getLogger("Shackles");
log1.setLevel(Level.DEBUG);
//def key = "TEST-2"
def jqlQueryParser = ComponentAccessor.getComponent(JqlQueryParser)
def searchService = ComponentAccessor.getComponent(SearchService)
def issueManager = ComponentAccessor.getIssueManager()
def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def searchRequestManager = ComponentAccessor.getComponent(SearchRequestManager)
def filter = searchRequestManager.getSearchRequestById(88201)
def query = filter.query
def search = searchService.search(user, query, PagerFilter.getUnlimitedFilter())
int counter = 0
search.results.each { documentIssue ->
if (++counter > 1) return
def issu = issueManager.getIssueObject(documentIssue.id)
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def startdate = customFieldManager.getCustomFieldObjectByName("Announcement Start")
def enddate = customFieldManager.getCustomFieldObjectByName("Announcement End")
//def issu = issueManager.getIssueObject(key)
def start =(Date) issu.getCustomFieldValue(startdate)
def end = (Date) issu.getCustomFieldValue(enddate)
def today = new Date();
log1.info("today:"+today)
log1.info("start:"+start)
log1.info("end:"+end)
String newInfoTag = "Message to Update"
//def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser();
def userPropertyManager = ComponentAccessor.getOSGiComponentInstanceOfType(UserPropertyManager.class);
def userProperty = userPropertyManager.getPropertySet(user)?.getString("Outage Box2");
log1.info("userProperty:"+userProperty)
log1.info("newInfoTag:"+newInfoTag)
if ((userProperty != newInfoTag) && (today>=start && today<=end)) {
log1.info("Success:")
return true
}
return false
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
As far as I know, this is normal behavior. It's a web fragment and it is supposed to show up every time the url is hit. You have to store session in order not to show that per user which will make your code uglier :(
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Oh, is that, then I'm fine wit it :) . . Also, don't understand why the org wants to go the hard route.. Another thing is, they want to update this pop up message through a custom field. Can't even imagine how that is possible. *scared at the outcome of that*
Just one question, currently, I have a filter in place, the code works when there is atleast one active issue under the filter. But, it completely ignores the start and end date in this issue. As long as, there is an issue showing up for the filter, the pop works.
But, before, it worked only if the start & end date criteria was met. Not sure, why its skipping the dates now.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Tuncay Senturk _Snapbytes_ Hellooooo, Hope you are good :):) Can I please know your thoughts on this :)
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.