Scriptrunner to append issue id with a URL

Hi ,

Can someone help me figure out if the belowscript is fine. I basically need to append the issue id to the URL “https://tallysolutions.com/tallyweb/modules/pss/crm/css/lm/CSCCaseJiraListWIC.php?strJiraIssueId=

I have created a custom field called “CRM ticket URL” and here i need to have the above URL with the issue key at the end.

import com.atlassian.jira.component.pico.ComponentManager
import com.atlassian.jira.issue.CustomFieldManager;
import com.atlassian.jira.issue.fields.CustomField;
import com.atlassian.jira.issue.IssueManager;
import com.atlassian.jira.issue.Issue;
import com.atlassian.jira.issue.MutableIssue;
import com.atlassian.jira.issue.customfields.option.LazyLoadedOption

Issue issue = issue

final String crm=“CRM Ticket URL”

def customFieldManager = ComponentAccessor.customFieldManager

def issueKey = issue.getKey()
def s = customFieldManager.getCustomFieldObjects(issue).findByName(crm)

def cnt=issue.getCustomFieldValue(s)

log.debug(cnt)

//getCustomFieldValue(s)

if(cnt){
String url = “https://tallysolutions.com/tallyweb/modules/pss/crm/css/lm/CSCCaseJiraListWIC.php?strJiraIssueId=” + issueKey;

return “<a href=”" + url + “”>" + url + “”;
}
else{

return ‘-’;
}

Hi,

If you just only need to add an URL to your scripted custom field “CRM ticket URL”, paste following script into your field

String url = "https://tallysolutions.com/tallyweb/modules/pss/crm/css/lm/CSCCaseJiraListWIC.php?strJiraIssueId=" + issue.getKey();

return "<a href=" + url + ">" + url;

The result of the script is displayed on the issue. It’s not necessary to save the value on issue on your own.

Remember to check if custom field is on issue view screen and in given context.

I hope it will help you.

Kind Regards
Josef Pavelec, MoroSystems s.r.o., Czech Republic

1 Like

Thank you :slight_smile: