Update value of a tracker field based on another field

Is it possible to set the value of a field based on a subset of another field value? e.g. I have a national ID number that has the date of birth in the first 6 digits:
7410237098108
In the above, we can glean the date of birth as 23 October 1974 (741023). Would it be possible to set the value of a date of birth field when the user enters the full ID into the national ID field?

1 Like

Hi @Edward_Robinson

Interesting question… I think it might be possible to use program rules for this case because it doesn’t wait for anything to be exported i.e. the value is available in another filed in the form.

If you’re willing to experiment. I’m thinking of something such as
d2:concatenate(d2:substring(dateOfBirth, 2, 4), d2:substring(dateOfBirth, 5, 7), d2:substring(dateOfBirth, 8, 10))

If the date of birth format is yyyyMMdd (19741023) and if substring will be able to recognize it as a string… I think the expression above should work. Would you give it a try and share how it goes?

Thanks!

1 Like

Thanks for the feedback! I’ll be able to confirm later today or before the end of this week at the latest.

1 Like

Thanks! I’m hoping it worked or you might have found a better way? :grin:

1 Like

Thanks for the feedback, I think for now we’re not going to implement this as validation becomes an issue. I’m not sure how we would go about firstly validating the ID to ensure the first 6 digits are indeed a valid yymmdd value before we populate the DOB field.

1 Like

Thanks @Edward_Robinson ! Isn’t the DoB being filled out first? So you’d need to first validate the DoB?

1 Like

Unfortunately not, we’re trying to parse the date of birth from the ID number. What we might do is validate the DOB based on the ID which will help with QA.