-1

I am searching for a way to store data in Salesforce via apex(or other way) without using custom objects. I have a trigger that tracks changes in the Task object, and I want to save somewhere that information about every change that have been made for a week and use that data in my visualforce page.

Is there any way to store data like that in Salesforce? I'll be very thankful if you help me or give an advice.

1 Answer 1

1

You could do it using Custom Metadata. Store your required information in custom metadata (via trigger) and use the Metadata.Operations class in your VF page's Apex controller to read/create/update records. (Note that you cannot perform delete)

I will add that using a custom mdt here is an anti-pattern. A custom object is simply a better fit for this use case, unless there's a constraint preventing you from having a new object.

2
  • Unfortunately I can't use custom objects, although this is the best solution. As you said I cant delete metadata, hence I have question: Is it possible to overflow custom metadata or metadata cleans automatically after some time? Commented Aug 23, 2022 at 9:28
  • 2
    Overflowing custom metadata is not possible. However some soft delete options are apparently possible, take at look at this answer.
    – Kishan B
    Commented Aug 23, 2022 at 11:29

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .