Macro to reference News page type

Wei Wang asked on April 23, 2020 17:26

So I have a page created using News page type. The table name is Content_News on the backend. Then I added a form wizard to the News Text field (html text field) to have users acknowledge that they have read the news. So I have a NewsID field hidden in the form. Now the question is, how do I use macro to get the NewsID from the Content_News page type as a default value for the form field like PageNewsID? I can get the document ID but I don't know how to get to the NewsID?

Thank you! Wei Wang

Correct Answer

Brenden Kehren answered on April 23, 2020 17:51

if you're accessing the news item by using CurrentDocument data, you can simply use CurrentDocument.DocumentForeignKeyValue which will be the PageNewsId assuming the current document is of class cms.news.

The field DocumentForeignKeyValue on the CMS_Document record, stores the primary key of the page type record as a reference. It does this because the CMS_Document table stores the page and language data while the CMS_News page type table only stores the page types data. There are other references but this is a simple explanation of what is going on.

1 votesVote for this answer Unmark Correct answer

   Please, sign in to be able to submit a new answer.