As a consequence of all that is normally required in some area of responsibility:-
I'm sorry for your loss. You will be proud to know that he died in the line of duty.
στη γραμμή του καθήκοντος; κατά την εκτέλεση του καθήκοντος;
Your first version (*στη γραμμή του καθήκοντος) is a calque that is not used in Greek. The second one is used, however, along with πέθανε/έπεσε στο καθήκον.