Template code not working for #AT(%BrowserMethodCodeSection ... 'TakeKey' )

Hi All,

Any suggestions please,

This works (I believe because it is NOT Derived)

#AT(%BrowserMethodCodeSection, %ActiveTemplateParentInstance, 'TakeNewSelection', '()'),PRIORITY(2500)

BUT this does not work (I think because it is derived in the browse class [TakeKey PROCEDURE(),BYTE,PROC,DERIVED])

#AT(%BrowserMethodCodeSection, %ActiveTemplateParentInstance, 'TakeKey', '(),BYTE'),PRIORITY(2500)

Am I correct?
Is there a way to fix this please, so my templates can work please?

The only info coming out of the active template symbols is %activetemplateinstance, %activetemplateinstancedescription and %activetemplatetype.

Ownerinstance and parentinstance are both displaying zero.
Primaryinstance is blank.

This is the same on both embeds, although %embedparameters is showing a 1 for %activetemplateinstance.

These browse templates of mine dont have a parent or owner instance, do yours?

Thats using my embed info template, which you can see a screenshot of here. Template to add correct template embeded point - #10 by anon23294430

Edit.

You know what I love about these post… it ties up my past… :grin:

In Class ABC add the “Create #AT from Embed”

Then in the Embeditor you’ll see:

BRW1.TakeKey PROCEDURE

ReturnValue          BYTE,AUTO
  CODE
  ! Start of "Browser Method Code Section"
  ! [Priority 1300]
  
  !HELP EMBED : 6 Hub Question
  !Description: Browser Method Code Section
  !EmbedParameters:*1, TakeKey, (),BYTE*
  !#AT(%BrowserMethodCodeSection,%ActiveTemplateInstance,'TakeKey','(),BYTE'),PRIORITY(5000)
  !#ENDAT

So

You: #AT(%BrowserMethodCodeSection, %ActiveTemplateParentInstance, 'TakeKey', '(),BYTE'),PRIORITY(2500)
Tpl: #AT(%BrowserMethodCodeSection, %ActiveTemplateInstance,'TakeKey','(),BYTE'),PRIORITY(5000)

Hello,
(NOT WORKING)

I tried that and this is what it recommended;

BRW_StreamingDocumentsCheckList.TakeKey PROCEDURE
ReturnValue          BYTE,AUTO
! Start of "Browser Method Data Section"
! [Priority 5000]
! End of "Browser Method Data Section"
  CODE
  ! Start of "Browser Method Code Section"
  ! [Priority 1300]
  ! Parent Call
  ReturnValue = PARENT.TakeKey()
  ! [Priority 5000]
  !HELP EMBED : 5 MARIUS
  !Description: Browser Method Code Section
  !EmbedParameters:*6, TakeKey, (),BYTE*
  !#AT(%BrowserMethodCodeSection,%ActiveTemplateInstance,'TakeKey','(),BYTE'),PRIORITY(5000)
  !#ENDAT
  ! [Priority 7500]  
  ! End of "Browser Method Code Section"
  RETURN ReturnValue

I then changed my template and my code looks like this;

#!**********
!#AT(%BrowserMethodCodeSection,%ActiveTemplateInstance,'TakeKey','(),BYTE'),PRIORITY(5000)
      IF RECORDS(SELF.ListQueue) AND KEYCODE() = MouseLeft2
        POST(EVENT:Accepted,%MNDocuVaultViewEngagement)
      END
!#ENDAT
#!**********

It does not even show?

This works; [“Clarion Mag Template”]
#AT(%BrowserMethodCodeSection,'6','TakeKey','(),BYTE'),PRIORITY( ???? )
Question; So will this always stay 6?

Your code above is !#AT(
Shouldn’t have ! so #AT( is correct, same for !#ENDAT

The !would make would make it a code comment, not a # Template statement.

No.

The 6 is the %ActiveTemplateInstance which you would see on the window control as #SEQ(6). It will be a different number based on the order the controls are populated.


We need to see the first line of your Template, i.e. the #EXTENSION, #CONTROL, etc. That may need a REQ() for %ActiveTemplateInstance to have the right value.

Does your #EXTENSION or #CONTROL template have this attribute: REQ(BrowseBox(ABC))? If so, then %ActiveTemplateParentInstance will actually be the instance of the BrowseBox, and your #AT should work.

If you don’t have that REQ(...) attribute, then your template’s instance has nothing to do with the BrowseBox, which is why your #AT doesn’t work.

Post both your #EXTENSION or #CONTROL statement, and your #AT statement. Then I can advise you further.

1 Like

Hello Mike,

See as requested;

Extension

#Extension(BrowseDocuVault,'[MN] DocuVault'),REQ(BrowseBox(ABC))
#Sheet,HSCROLL
  #Tab('DocuVault')
    #Boxed(' DocuVault '),section,prop(PROP:FontName,'Tahoma')
      #Prompt('Disable DocuVault Here',Check),%MNDisableBRWDocuVault,At(10,4),DEFAULT('FALSE')
    #EndBoxed
    #Boxed(' Activate DocuVault'),section,prop(PROP:FontName,'Tahoma'),WHERE(%MNDisableBRWDocuVault=0)
          #PROMPT('Object to use',@s255),%MNPopUpObject,REQ,DEFAULT('BRW1')
          #PROMPT('Program Area (with the <39>) :',@S30),%MNDocuVaultArea,REQ
          #PROMPT('Control used for Filter on Browse',CONTROL),%MNDocuVaultFilterYN,REQ,DEFAULT('?Loc:EngagementFilterYN')
          #PROMPT('Control used for Lock Entries',CONTROL),%MNDocuVaultLockYN,REQ,DEFAULT('?Lock_Unlock_CheckList_Item_Engagement_BUTTON')
          #PROMPT('Control used for View Entries',CONTROL),%MNDocuVaultViewEngagement,REQ,DEFAULT('?View_StreamingDocuments_Engagement_BUTTON')
          #PROMPT('Control used for Upload Entries',CONTROL),%MNDocuVaultUpload,REQ,DEFAULT('?Upload_to_Vault_Engagement_BUTTON')
          #PROMPT('Control used for Load Standard Templates',CONTROL),%MNDocuVaultStandard,REQ,DEFAULT('?Load_StandardDocuments_Engagement_BUTTON')
          #PROMPT('Parent GUID',FIELD),%MNDocuVaultParentGUID,REQ
          #PROMPT('Parent Description',FIELD),%MNDocuVaultDesc,REQ
    #ENDBOXED
  #EndTab
#EndSheet

AT

#AT(%BrowserMethodCodeSection,'6','TakeKey','(),BYTE'),PRIORITY(5300)
! Start Added for DocuVault By Marius Nel Templates
  IF RECORDS(SELF.ListQueue) AND KEYCODE() = MouseLeft2
    POST(EVENT:Accepted,%MNDocuVaultViewEngagement)
  END
! End Added for DocuVault By Marius Nel Templates  
#ENDAT

This little template injected the code as expected:

#Extension(BrowseDocuVault,'[MN] DocuVault'),REQ(BrowseBox(ABC))
#AT(%BrowserMethodCodeSection,%ActiveTemplateParentInstance,'TakeKey','(),BYTE'),PRIORITY(5300)
! Start Added for DocuVault By Marius Nel Templates
#ENDAT

Note that because your template REQ(BrowseBox(ABC)), that makes it a child of the BrowseBox instance. Therefore, in your #AT statement, you reference the browse’s instance using %ActiveTemplateParentInstance, as shown above.

Rereading your original message, you comment that TakeKey is derived. I’m not entirely sure what you mean by that. Methods that host code in your generated procedure will usually have the DERIVED attribute (unless they aren’t VIRTUAL in the base class, which would be very rare). I’ve checked ABBrowse.inc, and it’s as expected within the BrowseClass declaration:

TakeKey           PROCEDURE,BYTE,PROC,VIRTUAL   ! 1 If action taken

Perhaps if you clarify your mention of DERIVED, that might help us to get to the bottom of it.

What I Meant to say was: The derived once’s are the only one’s that does not work as expected when using the %ActiveTemplateParentInstance in my template(s) - All others Browse Procedures works

Is there another way to populate the %ActiveTemplateParentInstance in templates?

The %ActiveTemplateParentInstance is automatic.

Every template has an %ActiveTemplate (its template name) and %ActiveTemplateIntance (its instance number, which is unique within the procedure). For example, your browse template’s instance is 6. Your BrowseDocuVault template will have a different instance number.

If a template has the REQ(…) attribute, then it has a parent. When you look at the Extensions tab, you’ll see the child template below the parent to which it’s attached. In that case the child template’s %ActiveTemplateParentInstance will be the template it’s sitting beneath. In the case of your BrowseDocuVault, the parent instance would also be 6.

Are you sure you’re attaching your template to the correct browse? When you populate it on the Extension tab, be sure to highlight the preferred parent browse before pressing the Insert button. That will show you two types of templates:

  • Templates that REQ(…) the type of template you’re highlighting. After adding them, they’ll appear as a child of the highlighted parent. It’s %ActiveTemplateParentInstance will match the template you highlighted before hitting Insert.
  • Templates that don’t have a REQ(…) attribute. After adding them, they’ll appear at the top level, not as a child of the the highlighted template.

Probably the best example of this are the browse update, select and view buttons, which everyone will probably know.

1 Like