The correct order for Milotic's "Energy Grace" Ability should be this: 1) Attach 3 basic Energy cards from your discard pile to 1 of your Pokemon (excluding Pokemon-EX), 2) Milotic is Knocked Out. That means you cannot use "Energy Grace" if you have no basic Energy in your discard pile, and you can't use "Energy Grace" to get back any Energy that are attached to Milotic.
Source: TPCi Rules Team (2018-03-08)