So I had a Name field with text and had populated it with Account Names. Upon converting back to an autonumber, all of the existing data had stayed the same and all new records received the autonumber.
Is it possible for me to change the datatype in Apex to text, then on-save trigger, to update the field, then change back to an autonumber? I like the Autonumber in that the user doesn't need to fill in random text on entry HOWEVER, I like how meaning full the text is.
So the process would go as follows:
- Object has autonumber
- user creates record for object
- entry form opens up and the user fills it out
- a trigger is fired on save which turns the autonumber to a text, the trigger then changes the text of the auto number field to the text ([date] + ': ' + Owner.name) 5) the autonumber is turned back to an autonumber
The reason I think this is possible is because I had a name field that was updated via trigger. Then, at some point, I needed to change the field to an autonumber. After changing it to an auto number all of the existing records kept their old value (date + ': ' + owner.name)
So I was hoping to have a more desctiptive field by using text for the key BUT I don't want to force the user to enter a "token" value just to save the record to have the trigger overwrite it.
Example for how it works now with a name field:
- user opens record and fills in a date field (which is the only thing I'm interested in)
- The user has to fill in a name field which is unnecessary (for the user, in a mobile setting this is problematic or at least not elegant)
- User saves
- name field is overwritten (date + ': ' + owner.name)
Example for how it works with autonumber field:
- user opens record and fills out date
- user saves (but now autonumber is not useful in Salesforce1) and list views
How I'd like it to work
- user opens record and fills out date (and does not have to fill out a name field)
- user saves
- trigger updates "key" field to (date + ': ' + owner.name)
perhaps a quick action can do this? However, this is a master object therefore, I'd have to trigger the action via a tab. Perhaps this could be done with a flow? I'm not sure how they can look in lightning
Otherwise, I was thinking this was possible because I had text with all the key fields filled in. Then changed to autonumber and the old key fields stayed and only new records had the autonumber.
So i'm looking for the best of both worlds