You need to sign in to do that
Don't have an account?
ManuDewan
Fieldsets
Are Fieldsets accessible in Apex or only in Visualforce? From the Release Notes and docs, it seems only the latter but will be great to know for sure as I could REALLY use them in my code for now. I'm basically trying to get the different set of fields on the layouts for different record types but there doesn't seem to be a way in Apex to get those so was hoping to use Fieldsets.
Field Sets are not currently available in Apex (though its on the roadmap). For your case, could you not simply iterate through all the fields on the Opportunity record (use a decribe call to find all Opp. fields dynamically) and then copy over all non-null fields to your 'mirror' object.
Depending on the Opp Rect Type, only certain fields could have been set by the user and so you would indirectly meet your req?
I'm probably oversimplyfying your reqs, but it's worth a shot :)
All Answers
Only VF at this stage, but you could create a fieldset per Record Type, and then only render the fieldset for that RecordType?
Thanks! That's the issue. I'm not tryting to render them; I need to create another object record based on Opportunity and only copy over fields based on which record type it is.
Field Sets are not currently available in Apex (though its on the roadmap). For your case, could you not simply iterate through all the fields on the Opportunity record (use a decribe call to find all Opp. fields dynamically) and then copy over all non-null fields to your 'mirror' object.
Depending on the Opp Rect Type, only certain fields could have been set by the user and so you would indirectly meet your req?
I'm probably oversimplyfying your reqs, but it's worth a shot :)
And here's the code for it in case anyone needs it for future. In my case, the field names were identical, but if you have a number of different fields, it'll be good to use custom settings for mapping the field names and then using describes as here to get the same.
This is great. Thanks so much for sharing your code with the rest of the community!