-
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 is an Enhanced Domain in Salesforce in 2023?
Enhanced domains are coming to My Domain in a future version. All URLs within your company—including those for your Experience Cloud sites, Salesforce Sites, Visualforce…
Popular Salesforce Videos
Pardot Engagement Studio | Salesforce
Learn how to use Pardot Engagement Studio to engage and attract prospective students. Do let us know in the comment section if you have any…
Top 50 Salesforce Lightning Interview Questions And Answers | Salesforce Lightning Interview
This video by MindMajix includes all the frequently asked Interview questions that give you an idea to crack your Salesforce Lightning interview smartly. These Interview…
Schedule Batch Apex | Asynchronous Apex in Salesforce | Learn Salesforce Development
Watch this video tutorial to learn how to schedule batch apex in Salesforce. If you have any doubts or concerns do let us know in…