-
Custom button to add existing records In org.
I am trying to add a custom button to add existing records to a custom object related list (Specifications(custom obj) to Products(custom obj))
Ext class code:
public with sharing class AddExistingSpecsExt {
public Product__c specs { get; set; }
public AddExistingSpecsExt() {
String specs Specification__c = ApexPages.currentPage().getParameters().get('id');
specs = [SELECT Id, Name, Product__c FROM specs WHERE Id =: specs.Id];}
public PageReference associate () {
Opportunity opp = new Opportunity ( Id = Specification__c.Product__c, specsid = Specification__c.Id);
try {
Database.update(opp);
} catch (Exception error) {
ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'Error while associating.' + error.getMessage()));
}PageReference page = new PageReference('/' + specs.Id);
return page.setRedirect(true);
}public PageReference cancel () {
PageReference page = new PageReference('/' + specs.Id);
return page.setRedirect(true);
}}
I am getting this error:Line 7: expecting a semi-colon, found 'Specification__c'
Log In to reply.
Popular Salesforce Blogs

Navigating Complex Implementation Challenges with Salesforce Consulting Partners
The complexity of the Salesforce platform often makes it challenging to implement solutions such as Service Cloud, Marketing Cloud, and Sales Cloud. Considering the steep…

Lead Management in Salesforce Sales Cloud: Top 6 Standard Tools Implementation and Custom Configuration Examples
The primary purpose of Salesforce Sales Cloud is to organize fast and smart sales. To do this job, Sales Cloud offers users a simple lead…

Salesforce Automation Testing: Best Practices to Follow
Salesforce comes with multiple OOTB (out-of-the-box) features that are customizable. Just like any complex, integrated solution, quality assurance and testing are important for Salesforce. The configuration…
Popular Salesforce Videos
TrailheaDX '18 Opening Keynote - Part 2: Salesforce Platform
Salesforce TrailheaDX ’18 Opening Keynote – Part 1: Create Connected Customer Experiences TrailheaDX ’18 Opening Keynote – Part 3: Connect Every Experience Salesforce TrailheaDX ’18…
Salesforce Automation Tools
What all automation tools available in Salesforce? Learn more about automation tools - a) Process Builder b) Lighting Flow c) Approval process d) Workflow rules…
AMPscript Math Functions - Salesforce Marketing Cloud Functions in 5 minutes
Cameron Robert steps through how to use the AMPscript Math Functions in Salesforce Marketing Cloud. Key Moments: Introduction to AMPscript Math Functions (0:00) Add, Subtract,…