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
Mark.MulhollandMark.Mulholland 

identifier starts immediately after numeric literal

Hello,

 

I am trying to create a button that sits on the OpportunityLineItem related list on Opportunities that will create a new Price Plan record for each line item it finds. In theory this doesn't sound too hard but I keep getting an error "identifier starts immediately after numerical literal" and I can't figure out what is causing this error. I don;t see anything wrong with my syntax

 

{!REQUIRESCRIPT("/soap/ajax/24.0/connection.js")}
var records = {!GETRECORDIDS($ObjectType.OpportunityLineItem)};
var newRecords = []; 

if (records[0] == null) 
{ 
    alert("Please select at least one row");
} 
else 
{
    var oppLineItemRec = sforce.connection.query("select Product2,UnitPrice,Quantity from OpportunityLineItem where id in ('"+ records +"')");

    for (var n=0; n < oppLineItemRec.length; n++) { 
        var c = new sforce.SObject("Price_Plan__c");
        c.Product__c = oppLineItemRec[n].Product2; 
        c.List_Price__c = oppLineItemRec[n].UnitPrice;
        c.Quantity__c = oppLineItemRec[n].Quantity; 
        c.Account__c = {!Opportunity.AccountId};
        c.Opportunity__c = {!Opportunity.Id};
        newRecords.push(c);
    }
}

var result = sforce.connection.create(newRecords); 

window.location.reload();

 Does anyone know what this error could be caused by?

Thanks

Mark

Best Answer chosen by Admin (Salesforce Developers) 
b-Forceb-Force

Basically It should not,

PLease mail me screenshot of error and Javascript code on gmail  at balasahebwani@gmail.com

 

We will fixed this.

 

Thanks,

bForce

 

 

All Answers

b-Forceb-Force

Hi Mark,

 

Please try this one 

 

{!REQUIRESCRIPT("/soap/ajax/24.0/connection.js")}

try
{
	var records = {!GETRECORDIDS($ObjectType.OpportunityLineItem)};
	var newRecords = []; 

	if (records[0] == null) 
	{ 
		alert("Please select at least one row");
	} 
	else 
	{
		var strQuery="Select o.UnitPrice, o.Quantity, o.PricebookEntry.Product2Id, o.PricebookEntryId From OpportunityLineItem o  where o.id in ('"+ records.join("','") +"')" ;
		var res = sforce.connection.query(strQuery);

		var oppLineItemRec = res.getArray("records")
		
		for (var n=0; n < oppLineItemRec.length; n++) 
		{ 
			var c = new sforce.SObject("Price_Plan__c");
			c.Product__c = oppLineItemRec[n].PricebookEntry.Product2Id; 
			c.List_Price__c = oppLineItemRec[n].UnitPrice;
			c.Quantity__c = oppLineItemRec[n].Quantity; 
			c.Account__c = '{!Opportunity.AccountId}';
			c.Opportunity__c = '{!Opportunity.Id}';
			newRecords.push(c);
		}
	}

	var result = sforce.connection.create(newRecords);
	window.location.reload();

}catch(err)
{
	alert('Error occured in processing-----'+ err);
}

 

If you find any difficulties in above JS ,feel free to revert back.

 

 

Thanks,

bForce

Mark.MulhollandMark.Mulholland

Hello B-Force,

 

Thank you very much for your contribution however the button is still producing the same error which doesn't really make any sense

 

Thanks

Mark

b-Forceb-Force

Basically It should not,

PLease mail me screenshot of error and Javascript code on gmail  at balasahebwani@gmail.com

 

We will fixed this.

 

Thanks,

bForce

 

 

This was selected as the best answer
Mark.MulhollandMark.Mulholland

Thank you very much for the help bForce, the button is working now

 

Mark

HariPHariP

Hi,

 

I have same problem. Can you please post what did you do after sending your code email to B-Force.

 

Thanks

Hari