+ Start a Discussion
Anil DuttAnil Dutt 

Split Comma seperated string in Javascript



I have a situation where i m returing comma seperated string from a function and want to split this string in an array.

Here is what i m doing on Button click javascript but its gives me an error "message.Split is not a function"



var oppId= "{!Opportunity.Id}";

var message= sforce.apex.execute("CreditMemo","CloneOpp",{oppId:oppId });

var result = message.Split(",");
var newOppId ='';

if (result.length > 0)
   newOppId= result[1];



if(result[0]== 'Success')



Any idea?

Best Answer chosen by Admin (Salesforce Developers) 
Anil DuttAnil Dutt

Ok i got the solution


Adding .toString() to


var message = sforce.apex.execute("CreditMemo","CloneOpp",{oppId:oppId }).toString();


make message  as string and split work fine on it