Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Dynamics CRM - Expected Identifier Error in Javascript Code

Posted on 2009-06-28
1
Medium Priority
?
722 Views
Last Modified: 2012-05-07
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

0
Comment
Question by:logicsolutions
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 11

Accepted Solution

by:
rakeshAgarwal earned 2000 total points
ID: 24733564
you might not have put all the fields on the form .

My logic will be

if (crmForm.all.description != null)
{
 if(crmForm.all.description.DataValue  != null)
 {

  if(crmForm.all.new_service_description != null && crmForm.all.new_service_tasklist != null)
 {
crmForm.all.description.DataValue  += crmForm.all.new_service_description.DataValue + crmForm.all.new_service_tasklist.SelectedText
 }
 }
  else
 {
 if(crmForm.all.new_service_description != null && crmForm.all.new_service_tasklist != null)
 {
crmForm.all.description.DataValue  = crmForm.all.new_service_description.DataValue + crmForm.all.new_service_tasklist.SelectedText
}
}

}


regards
Rakesh
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Having trouble getting your hands on Dynamics 365 Field Service or Project Service trial? Worry No More!!!
Desired Skill Set for Microsoft Dynamics CRM Technical Resources – Part II
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question