function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Erich.WeihrauchErich.Weihrauch 

Javascript looping through text in a case field

Good morning everyone.
 
I'm trying to create a javascript for a button I have for a case, that can take in the contents of a field, and open them up via a new hyperlink window for each entry in that field.
 
Essentially the field would be comprised of text signifying external JIRA cases, e.g. SW-12, SW-32, etc.
In the field you could enter in multiple cases, and seperate them with a comma. I want the javascript to loop through the field, pull out each case, and open a seperate window or tab in the browser for those cases.
 
The code I have thus far is:
Code:
{!REQUIRESCRIPT("/soap/ajax/8.0/connection.js")}
var c = new sforce.SObject("Case");
c.JIRA = "Case.JIRA_Case__c";
var mySplit = c.JIRA.split(",");
for(i = 0; i < mySplit.length; i++)
{
window.open('http://server:8080/browse/'.c.JIRA);
}

 
 
I'm not the best when it comes to javascripting these days (I'm a bit rusty :) ), though I figured that should work as a simple array to figure out the field and open the hyperlinks.
 
What am I doing wrong?  Any help would be greatly appreciated :)


Message Edited by Erich.Weihrauch on 04-16-2008 12:43 PM
Erich.WeihrauchErich.Weihrauch

Nevermind I guess, fixed it :)

 

Code:
{!REQUIRESCRIPT("/soap/ajax/8.0/connection.js")}
var c = new sforce.SObject("Case");
c.JIRA = "{!Case.JIRA_Case__c}";
var mySplit = c.JIRA.split(",");
for(i = 0; i < mySplit.length; i++)
{
window.open('http://server:8080/browse/'+mySplit[i]);
}


 

jrotensteinjrotenstein
You might also want to TRIM() the results of your split, in case there are any spaces in the original field, such as after the commas (SW-10, SW-11).

You may also be interested in knowing about this connector written by CustomWare that links JIRA to SFDC:

http://www.customware.net/repository/display/AtlassianPlugins/Salesforce.com+JIRA+Plugin
http://confluence.atlassian.com/display/JIRAEXT/Salesforce.com+JIRA+Integration