-
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
Most Beneficial Features of Salesforce Sales Cloud For Any Business
Sales cloud of Salesforce is mainly used by B2B and B2C organizations to manage sales, customer support and marketing operations and the engagement strategies. The…
5 Exceptional Qualities of a Salesforce Consultant
Salesforce, it is a top-notch cloud computing technology which is highly acceptable by businesses around the world. The technology has opened new doors for cloud…
Salesforce Summer '25 Highlights
Summer is nearly here, and Salesforce's Summer '25 release update means there's more to look forward to than the sun and the beach. Whether you've…
Popular Salesforce Videos
Salesforce Agentforce for Nonprofits
With Salesforce's latest AI tool, Agentforce, you can boost your Salesforce org with AI agents that can streamline workflows, reduce costs, and improve your constituent…
How To Use Salesforce Campaigns in Pardot
Learn campaign basics to help you plan your marketing strategy. In this video, Pardot experts guide you in: - Defining campaigns in Pardot and Salesforce…
Welcome to Email Template Builder | Salesforce Learning
In this video, you will learn how to create email templates with Email Template Builder and Email Content Builder. If you have any doubts or…