Custom Action - how to create a custom action to view records in one table based on a related record in another table
I have two tables. One is called “campaigns”. The other is called “tactics”. You have multiple tactics for each campaign. The “tactics” table is linked to the "campaigns" table by the lookup field “campaign_name” in the tactics table. Each campaign is treated as a separate record in the "campaign" table.
I know I could create a subform in the "campaigns" form that would allow you to enter tactics within the campaigns form, and the 1 to many relationship would be created automatically, displaying the associated tactics.
However, I don’t want to create a subform. I want to place a custom action button in each record (row) in the "campaigns" report, that when clicked displays a report of all the tactics linked to that campaign by the lookup field "campaign_name." with that campaign record.
I've created the custom action button, but so far I haven’t been able to write the correct code that will filter the records in the tactics report based on the lookup field (campaign_name) in the "tactics" table. A report displays, but it is of all records in the "tactics" table, not just those associated with the selected campaign record in the "campaigns" table. In effect, I want to fetch the tactics records for each campaign by clicking a custom action button, placed in the row (record) of the "campaigns" report, displaying a "tactics" report for that campaign.
This is the code that generates the linked report that isn't filtered:
void viewtactics(int tactics_obj)
{
openUrl("#Report:Tactics_Report?campaign=","same window");
}
See attached jpgs
I have looked just about everywhere for advice on writing this code, but haven't seen anyone else with this particular issue. Would love some help and advice, as I want to be able to do this for more than one table and related table.