Correct position to Insert template code into browse

I have a window with a standard browse.
I have my own update template. The below shows a little of adding an embed into the browse.

! ---
! --- Declaring %MNActiveTemplateParentInstance --
#DECLARE(%MNActiveTemplateParentInstance)
#SET(%MNActiveTemplateParentInstance,%ActiveTemplateParentInstance)
! MNActiveTemplatParentInstance %MNActiveTemplateParentInstance
! --- Result ---
  ! MNActiveTemplatParentInstance 1
! ---------------------------
! ---

What I am trying to is add code after the

! ---
BRW1.ResetQueue PROCEDURE(BYTE ResetMode)
  CODE
  PARENT.ResetQueue(ResetMode)
  IF RECORDS(Queue:Browse) = 0
    ! DO Something <<<<<<<<<<<<<<<
    .
! ----
#AT(%BrowserMethodCodeSection,%ActiveTemplateParentInstance),'ResetQueue','(BYTE Force=0),LONG'),PRIORITY(5500)
! ========= TEST =========
#ENDAT
! ---

Doesn’t seem to work - I think it is close, but…
! —

Hey Jeff, welcome aboard!

You haven’t shown it but if you want to add code to a browse you probably need to say so in your template declaration. eg for a Control template, the same idea applies to an Extension template…

#CONTROL(BrowsePrintButton,'Print record from a Browse Box'),DESCRIPTION('Print a Record from Browse on ' & %Primary),REQ(BrowseBox),FIRST,HLP('~TPLControlBrowsePrintButton.htm')

…the REQ(BrowseBox) links your code to whichever browse box is selected when adding your template to the procedure. This then becomes the %ActiveTemplateInstance, you can’t create that link yourself, so far as I am aware?

And the embed pointer you will need is …

#AT(%BrowserMethodCodeSection,%ActiveTemplateInstance,‘ResetQueue’,‘(BYTE ResetMode)’),PRIORITY(5000)

What is your template supposed to accomplish or what problem is it trying to solve?

If it’s what I think it could be, then this could be the solution instead of a template Easy Peasy Top of the List - #2 by jslarve

Otherwise, maybe some more detail about what you are looking for? It looks like some mixing of previously generated code into your template, which could be limiting.

There is a “Create #AT from Embed” CODE Template you can drop into an Embed and it will give you the #AT parameters.

Thankyou - worked well

What I have in place is a template that works fairly well. The template is designed to allow Insert, Change, Delete functionality to a browse (on the same window).
The problem (solved now) relates to, “what happens when the browse has NO records?” The template now has a “No Browse records” procedure, which will clean up any “stuff” that is calculated or displayed on the window.
I am new to this group, and thanks for your concern.