Link to home
Start Free TrialLog in
Avatar of logicsolutions
logicsolutionsFlag for Australia

asked on

Dynamics CRM - Expected Identifier Error in Javascript Code

Hi Experts,

I got this script from a site and just replaced the generic fields in the script with the fields on my form. I am receiving a Javascript error saying 'Expected Identifier' Code 0.

This code basically gets two fields and joins the data into an existing field.

Below is my code.

Many Thanks In Advance.
//Declare your world. 
var strings = new Array(); 
var target = crmForm.all.description; 
 
//A function that check whether there is a legitimate value further on. 
function checkNext(a,i) { 
if (i >= a.length) { 
return false; 
} else if (a[i] != null && a[i] != "") { 
return true; 
} 
else { 
return checkNext(a,i+1); 
} 
} 
 
//A function that add a line to an array 
function addLine(l,t) { 
//If lookup field. 
if (t == 1) { 
if (l.DataValue) { 
return l.DataValue[0].name; 
} else { 
return null; 
} 
//If text field. 
} else if (t == 2) { 
return l.DataValue; 
//If picklist field. 
} else if (t == 3) { 
return l.SelectedText; 
} else { 
return null; 
} 
} 
 
//Add each of the values in order to the array. 
//As the second parameter, enter 1 for lookup fields, 2 for any text field and 3 for picklist fields. 
strings[0] = addLine(crmForm.all.new_service_description,2); 
strings[1] = addLine(crmForm.all.new_service_tasklist,3); 
 
//Loop through the array and chain its 
values. 
for (i=0;i<strings.length;i++) { 
if (strings[i] != null && strings[i] != "" && checkNext(strings,i+1)) { 
if (i==0){ 
target.DataValue = strings[i] + " - "; 
} else { 
target.DataValue += strings[i] + " - "; 
} 
} else if (strings[i] != null && strings[i] 
!= "") { 
if (i==0) { 
target.DataValue = strings[i]; 
} else 
{ 
target.DataValue += strings[i]; 
} 
} 
}

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of rakeshAgarwal
rakeshAgarwal
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial