I am receiving apex errors with the following code:
public with sharing class AddExistingSpecsExt {
public Specifications__c loadedSpec { get; private set; }
public AddExistingSpecsExt() {
String specId = ApexPages.currentPage().getParameters().get('id');
if (String.isBlank(specId)) return;
List<Specifications__c> candidates = [
SELECT Id, Name, Product__c FROM Specifications__c WHERE Id = :specId LIMIT 1
];
if (!candidates.isEmpty()) loadedSpec = candidates[0];
}
public PageReference associate () {
Specifications__c candidates = new Specifications__c ( Id = Specifications__c.Product__c, Name = Specifications__c.Id);
try {
Database.update(candidates);
} catch (Exception error) {
ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'Error while associating.' + error.getMessage()));
}
PageReference page = new PageReference('/' + candidates);
return page.setRedirect(true);
}
public PageReference cancel () {
PageReference page = new PageReference('/' + Null);
return page.setRedirect(true);
}
}
Attempting to add records to a related list through a custom button and small vf page.
The Error is Line 16
Invalid initial expression type for field Specifications__c.Id, expecting: Id
Any help?
Name = Specifications__c.Id
insteadName=loadedSpec.Id
alsoSpecifications__c.Product__c
should beloadedSpec.Product__c