Hi,
I have created an action item in a list page and want the action item to be "enabled" or not depending on a data test that is executed in the OnAfterGetRecord trigger of the list page. I have declared a global boolean variable, set the property "IncludeinDataset" for this variable and then used this variable in the Enabled property of the Action item. The variable gets set or not in the OnAfterGetRecord code pf the list page.
This doesn't work correctly all of the time. Additionally, if I scroll up and down the list page with the debugger enabled, it doesn't seem to be triggering the code in the OnAfterGetRecord section when I move between items in the Page list. It seems to work if the list is short but on a longer list it doesn't.
If I stop on an item where my code would set the variable I am using - and then presh "Refresh" - I get the expected results.
I'm fairly new to RTC - am I missing something about how this client works?
Any help greatly appreciated.
Thanks!
0
Comments
Can you show us your code in OnAfterGetRecord, and a screenshot of the button's properties?
Or just upload your object here.
It's a pretty straightforward modification to the item list - I created a (second) picture icon that illuminates if a jpeg image of the item exists (we don't load the picture into the database):
OnInit()
ItemPictureEnable := TRUE;
OnAfterGetRecord()
CLEAR(ItemVariant);
CLEAR(PictureConv);
ItemPictureEnable := PictureConv.GetPictureFileName(Rec,ItemVariant) <> ''; (a function that returns true if a jpeg image exists)
In the Enabled property of the picture Action Item (a new one I created) - I set the value to "ItemPictureEnable"
What I can't understand is that if I set a breakpoint in the debugger in the OnAfterGetRecord() trigger it doesn't break when scrolling the list. Also if I do a Ctrl+Alt+F1 to zoom on the record the ItemPictureEnable variable is FALSE as I scroll up and down the page list (even when it should be TRUE). If I stop on an item which would set the ItemPictureEnable variable TRUE and press "Refresh" then it works. Of course, if I fire up the debugger and launch the page (from scratch) then the debugger breaks where I would expect but then if I scroll up and down the page list, I can't seem to get the debugger to break where I would expect it to. It's as if the trigger code is just not firing.
Hope this makes sense - perhaps you could post me the example of what you did so I could cross checkit and see ...??
Thanks for helping.
Name: MyNewAction
Enabled: BtnEnabled
RunPageMode: Create
Image: AddAction
Promoted: Yes
PromotedCategory: New
To enable the button when the location code contains an 'A' I just added the following code in OnAfterGetRecord:
BtnEnabled := (STRPOS(Code,'A') <> 0);
I didn't try using the debugger, or Ctrl+Alt+F1, but as I scroll up and down, the button does get enabled when (and only when) the location code contains an A.
I also got it working on a "short" list - the problem occurs when you have a longer list (or so it seems to me!)
Thanks anyway!
In your function GetPictureFileName, I would suggest passing the parameters by reference (i.e. tick the 'VAR' checkbox), and doing a CALCFIELDS on the field that contains the jpg.
Could you post the code for that function?
Looks like NAV triggers the OnAfterGetRecord code only when the page is launched.