I built a workaround for how IOM handles new email addresses while we wait for something built in (please!)
My issue is that I would like to assign a new email address as the first position in a type (ex. Email 1) and shift all other phones up. IOM has the option to add it as the LAST position, but that doesn't work for me.
Also, If the email already exists on the record I would like to not duplicate it, but just move it to the first position (and shift all the other phones).
So here are the conceptual steps and I will upload files with the code.
1) Check if the email exists on the preferred address record
2) If it does, and it's already in the first position, then just leave, you are done!
3) If it exists, but not in the first position, move the older emails up one each (Email 1 -> Email 2, etc.) and then change the type of the existing email to be the first position (ex. Email 1).
4) If it does not exist then move the older emails up one each and then let IOM set the new email to Email 1 (as it would do normally)
If this sounds like something that you want to do then see the code I have attached to get an idea of my solution!
Also, if anyone knows more about this than me and has comments/suggestions please give them!