2

1

Is it possible to use BugMonkey to turn a text custom field into a link?

Use case:

We have a text custom field that we enter our Salesforce Support Case number into to allow us to track which Support tickets relate to what bugs. I would like to make that number a link to Salesforce that grabs that number and inserts it into a URL that searches Salesforce.

flag

2 Answers

4

You definitely can!

  1. Create a text custom field (if you haven't already)
  2. Edit a page and make sure your new custom field is visible
  3. Find the id attribute for the text field for your custom field (i.e., use your browser's developer tools or view the page source).
  4. Use that id for the field_id variable in the BugMonkey script below.
  5. Change the URL that's generated to be correct for Salesforce (I don't use Salesforce, so I don't know what the URL should look like. This example currently links to google.com)

The following BugMonkey customization should do what you're after once you've configured it using the steps outlined above.

name:          Sales force link field
description:   Takes a text custom field and makes it display as a link to the corresponding case in Salesforce
author:        Dane Bertram
version:       1.0.0.0

js:

var field_id= 'ID OF YOUR CUSTOM FIELD GOES HERE';

var linkifyTextField = function() {
  var textDiv = $('label[for="idBugViewDialogItem' + field_id + '"]').next();
  if (textDiv.length > 0) {
    var textVal = textDiv.text();
    textDiv
    .empty()
    .append(
      $('<a>')
        .attr('href', 'http://www.google.com/?q=' + textVal)
        .attr('target', '_blank')
        .text(textVal)
    );
  }
}
$(window).bind("BugViewChange", linkifyTextField);
linkifyTextField();
link|flag
This worked perfectly once I figured out the ID of the custom field wasn't the full API name, but just the part at the end. Thanks! – Chris M Feb 14 2012 at 2:15
Glad it worked, Chris! Can you update my answer with the right URL for salesforce cases (or let me know so I can update it)? – db Feb 14 2012 at 14:56
0

Can you give an example of what the ID looks like? Viewing source shows me something like this: idBugViewDialogItempagexurlm51. I've tried trimming that to pagexurlm51 but that doesn't seem to work.

link|flag
Nevermind...it did work, but just sends to Google. Time for more testing... – Scott May 9 2012 at 22:33

Your Answer

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