Activity Forums Salesforce® Discussions Custom button to add existing records In org.

  • Custom button to add existing records In org.

    Posted by Nitish on April 30, 2016 at 6:29 pm

    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'

    Himanshu replied 8 years, 5 months ago 2 Members · 1 Reply
  • 1 Reply
  • Himanshu

    Member
    May 30, 2016 at 10:09 am

    Hi Nitish,

    Try to remove the word Specification__c. You have declared your variable name twice.

    Hope this helps you.

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos