How can I set a DateTime value into an exAttribute through CustomSchema?
5 min
overview if you are trying to store a datetime value in an exattribute using datestringproperty, this will not work as expected for ex attributes the reason is that datestringproperty is not currently supported on ex attributes it expects an ad attribute definition in connectorschema, which causes an exception internally that exception is handled silently, so the value does not save and no obvious error is returned why the current schema does not work the following schema definition is not supported for ex attributes \<property name="exdatetimeexample" extended="innovation activate library\innovation activate properties datestringproperty"> \</property> although the script can read the value as a datetime, assigning it back to the exattribute in this way will not persist correctly recommended options option 1 store the value as a string store the date as a string and parse it whenever you need to use it this is the safest and recommended approach option 2 use the syntax attribute try defining the property with the syntax attribute set to date time instead \<property name="exdatetimeexample" syntax="date time"> \</property> this may be a suitable alternative depending on how the attribute is being used option 3 custom script parsing modify the active directory script logic to parse your chosen date format string and return a datetime object this is an advanced option and should be approached with caution, as incorrect changes can have wider system impact example of the original script using system; using innovation activate; class script scriptbase { public void main() { userdirectoryentry user = job arguments getobject("user") as userdirectoryentry; datetime dt = job arguments getdatetime("data/attribute/exdatetimeexample"); trace writeline(dt tostring()); user properties\["exdatetimeexample"] value = dt; user setinfo(); } } summary datestringproperty is not currently supported on ex attributes the failure is caused by the property expecting an ad attribute definition in connectorschema the exception is handled internally, so it does not appear as a visible error the safest option is to store the value as a string and parse it when needed an alternative is to define the property using syntax="date time" custom script based parsing is possible, but it is an advanced approach