-
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

What are Apex Basics? A Guide in 2023
The primary languages required to know in salesforce are: - Apex – It is used to write the business logic or we can say it…

Learn All About Salesforce Hyperforce
Developing a working relationship with customers is critical to a company's long-term success. A strong connection built on trust and communication makes customers feel more…

Salesforce Lightning Vs. Salesforce1 Mobile Device Components
Salesforce1 and Salesforce Lightning are the two most popular Salesforce platforms, used by Salesforce Developers, especially those who are into the mobile application development field…
Popular Salesforce Videos
Boosting your Application's Marketing through Salesforce AppExchange
Explore the key benefits of AppExchange, the largest business app marketplace, and discover how you can tap into its vast ecosystem of potential customers. In…
Salesforce Interview With an 11 Year Old Aspiring Salesforce Pro!
In this video, Brad interviews an up-and-coming YouTuber whose content focuses on various topics, including Salesforce. At the age of 11, young Emir has already…
Salesforce for Beginners | Getting Started with Salesforce and CRM
Chapter 1 of Salesforce for Beginner. It includes the following topics: 00:11 Login and Navigation 00:31 App launcher 00:48 Search 01:15 List Views 02:23 Salesforce…