Solved

Dynamics CRM - Expected Identifier Error in Javascript Code

Posted on 2009-06-28
1
703 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
1 Comment
 
LVL 11

Accepted Solution

by:
rakeshAgarwal earned 500 total points
Comment Utility
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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

This is a walkthrough guide I wrote whilst upgrading my on-premise MS Dynamics CRM 3.0 deployment to 4.0. This covers the actual installation of the product to a working level for my system, I ran into a lot of issues that the steps below fixed so h…
On Sep 22nd 2014 Microsoft released Update Rollup 1 for Microsoft Dynamics CRM 2013 Service Pack 1 and back in July Update Rollup 3 was released.  So we now have:   Update Rollup 1Update Rollup 2Update Rollup 3Service Pack 1Update Rollup 1 for S…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

771 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now