Perform calculation only if edit form is opened

I want to perform a calculation only if the edit form is opened. How can I differentiate the state of the form?

Thanks.

@sanitasihalt, I don’t think this should be possible with the form building.

@Kal_Lam is it possible to get the _id or _instanceid in the form building?