He was to get an ice cream, is to , was to . Be to + infinitive
Solution 1:
Is (or are), followed by to and a verb is one of the ways English has of talking about the future. So we can say ‘He is to visit New York next year’ as an alternative, but with a different emphasis, to ‘He is going to visit New York next year’ or ‘He will visit New York next year’.
When be is in the past tense, it normally describes an event that should be taking place, but won't. ‘He was to visit New York next year’ suggests that his trip was planned, but something has happened to frustrate it. In referring to a past event that failed to take place, we keep the past tense of be, but change the infinitive to the perfect infinitive, so we get a sentence like ‘He was to have visited New York last year’.
These are rather formal constructions, and for that reason it is unlikely that your example ‘He was to get an ice cream’ would occur very often. The circumstances would probably require something like ‘He was going to get an ice cream (but he changed his mind)’.