function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
swamyswamy 

Small doubt in code

The below class is given in pdf....but it is not saved...it shows errror....

 

Error: Compile Error: dimensions is not a fieldSet of Merchandise__c at line 7 column 8

 

Whata is this error ..how can i achieve it...

 

public class MerchandiseDetails {

public Merchandise__c merch { get; set; }

public MerchandiseDetails() {

this.merch = getMerchandise();

}

public List getFields() {

return SObjectType.Merchandise__c.FieldSets.Dimensions.getFields();

}

private Merchandise__c getMerchandise() {

String query = 'SELECT '; for(Schema.FieldSetMember f : this.getFields()) { query += f.getFieldPath() + ', '; } query += 'Id, Name FROM Merchandise__c LIMIT 1'; return Database.query(query); } }

 

For the above class v.f:

 

<apex:page controller="MerchandiseDetails">
<apex:form >
<apex:pageBlock title="Product Details">
<apex:pageBlockSection title="Product">
<apex:inputField value="{!merch.Name}"/>
</apex:pageBlockSection>
<apex:pageBlockSection title="Dimensions">
<apex:repeat value="{!fields}" var="f">
<apex:inputField value="{!merch[f.fieldPath]}" required="{!OR(f.required, f.dbrequired)}"/>
</apex:repeat>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>

Suresh RaghuramSuresh Raghuram

check u r merchandise__c object is having dimensions as a field or field set

swamyswamy

am not having any dimensions field....and what is this field sets....