14

1

It would be nice to have a url custom field. The idea would be to let people enter a url and turn it into an anchor tag.

The Edit/Resolve/Close views would let the use edit the url they want to use, and the Case view and List view would display a link.

Thanks

Fog Creek Case FC1905899

flag
We have added a custom text field like this and use javascript to get it the way we want. Great idea to have it built in though +1 – cdeszaq Jul 23 2010 at 15:20
1 
I'd be interested to see your javascript actually. I wanted to add some to turn my text field containing a url into a link but could not find events to listen to when the case switched from/out of edit mode. – Rodrigue Jul 28 2010 at 9:10

1 Answer

1

We have a case open to consider this feature for a future release. Please up-vote this question to show your support for adding this feature.


For the time being, I created this BugMonkey script to auto-link text-type custom fields in the left side of the case:

name:        Linkify a Custom Field URL
description: turns a specified custom field's value which starts with http:// and https:// into links
author:      Adam Wishneusky
version:     2.0.0.0
minApi:      1.0

js:
    $(function(){
        // if we're not on the case page, don't do anything
        if (!$('#bugviewContainer').length) return;

        // set the name of your url field here
        var fieldName = "My URL Field";
        var regex = /(http(s)?\:\/\/\w*(\.[a-zA-Z0-9\/\$\-_\@\!\*\""\'\(\)\,\=\;\#\?\:\+\%\~]*)*[a-zA-Z0-9\/])/igm;

        var myFunction = function(sCommand) {
            if (sCommand == 'view' || sCommand == 'load' || sCommand == 'email' || sCommand == 'reply' || sCommand == 'forward' )
            {
                // sometimes things are slow
                setTimeout(LinkTheField, 100);
            }
        };

        var LinkTheField = function() {
            var fields = $('div.dialog-item label:contains("' + fieldName + '")');
            if (fields.length > 0)
            {
                fields.each(
                    function(index) {
                        if ($(this).text() == fieldName)
                        {
                            var fieldValueDiv = $(this).parent().find('div.content');
                            fieldValueDiv.html(fieldValueDiv.html().replace(regex, "<a href=\"$1\" target=\"_blank\">$1</a>"));
                        }
                    }
                );
            }
        }

        if ($('#sEventEdit').length > 0)
        {
          myFunction('new');
        }
        else
        {
          myFunction('load');
        }

        // run it when the view changes and pass in the new view:
        $(window).on('BugViewChange', function(e, data) {
            myFunction(data.sCommand); 
        });
    });

Related: you can make a specific text field into a link. e.g. you can link to a case in another system. See this post.

link|flag
I can’t get the script to work. Any ideas? – Webhode Oct 24 at 19:05
@Webhode send me an email and I'll help get it working for you: customer-service@fogcreek.com – adambox Oct 26 at 14:05

Your Answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.