Discussions
- General Development
- Schema Development
- Apex Code Development
- Visualforce Development
- Formulas & Validation Rules
- Security
- Mobile
- Force.com Sites & Site.com
- Chatter Development
- Java Development
- .NET Development
- Perl, PHP, Python & Ruby
- Desktop Integration
- APIs and Integrations
- Visual Workflow
- Apple, Mac and OS X
- VB and Office Development
- AppExchange Directory & Packaging
- Salesforce Labs & Open Source Projects
- Other Salesforce Applications
- Jobs Board
- Force.com Discussion Boards
- :
- Developer Boards for Force.com and Database.com
- :
- Other Salesforce Applications
- :
- Re: Custom Button with Javascript
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
Custom Button with Javascript
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
10-19-2012 06:38 AM
I am not sure if this is the correct board for this question. if it is not, would someone point me to the correct board?
From the quotelineitem related list area of the quote page, I am trying to write query inside the javascript in the custom button. Upon testing I recieve the following error:
A problem with the OnClick JavaScript for this button or link was encountered:
missing ; before statement
Here is the custom button.
{!REQUIRESCRIPT("/soap/ajax/19.0/connection.js")};
var records = {!GETRECORDIDS($ObjectType.QuoteLineItem)};
var recordtype = sforce.connection.query("select id from recordtype where name = 'Autoconfig' ");
$newrecord{"id"} = @{$field->{'Id'}}[0];
var CreateNewRecords = [];
try
{
if (records[0] == null)
{
alert("Please select at least one record to update.");
}
else
{
for (var a=0; a<records.length; a++)
{
var create_new_Quote = new sforce.SObject("Quote");
create_new_Quote.RecordTypeId = recordtype;
create_new_Quote.Opportunityid = "006P0000003ahP5";
create_new_Quote.name = "AutoConfig trigger";
CreateNewRecords.push(create_new_Quote);
}
var result = sforce.connection.create(CreateNewRecords);
if (result[0].success=='false')
{
alert(result[0].errors.message);
}
else
{
location.reload(true);
}
}
}
catch(error)
{
alert("Error In Quote creation = "+error);
}
How do I correct my error?
Solved! Go to Solution.
Re: Custom Button with Javascript
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
10-30-2012 02:31 AM
Re: Custom Button with Javascript
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
11-13-2012 04:03 PM
Rahul,
I have pulled this code from an example I found and am not sure what that line states.
Re: Custom Button with Javascript
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
11-19-2012 10:11 PM
Re: Custom Button with Javascript
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
11-20-2012 07:43 AM
Rahul,
Thanks for asking. I found a completely different solution to what I was looking for.
// Include and initialize the AJAX toolkit library
{!REQUIRESCRIPT("/soap/ajax/10.0/connection.js")};
{!REQUIRESCRIPT("/soap/ajax/10.0/apex.js")};
var idList = {!GETRECORDIDS($ObjectType.QuoteLineItem)};
var retURL = window.location.toString();
var proceed = true;
if(idList.length > 1 || idList.length == 0){
alert('Please select 1 record.');
proceed = false;
}
if(idList.length == 1){
window.location="/apex/selectProductOptionsv8?qli= " + idList;
}
Thank you for your help

