I am working on building a rules processor and have a text (string) field in a custom metadata type that I would like to store a formula in (i.e. datetime.now()) and then convert to the correct field format within apex. Is this something that can be done? I know that I can use something like below to parse an actual datetime string:
(field.ValueType__c == 'Date/Time'){
DateTime dt = DateTime.parse(field.ValueType__c);
o.put(field.APIFieldName__c, dt);
In the custom metadata I am storing Value, ValueType, and IsFormula, but am having trouble figuring out how to actually set the formula for the datetime variable. Thanks.