Skip to content

Instantly share code, notes, and snippets.

@mhulse
Created April 5, 2012 22:20
Show Gist options
  • Save mhulse/2314638 to your computer and use it in GitHub Desktop.
Save mhulse/2314638 to your computer and use it in GitHub Desktop.
Caché DTI ContentPublisher: Tested in 7.6: A Simple CSP method that gets the StartDate timestamp from the dt_cms_schema.CMSStoryPubTracking table.
<csp:comment>++++++++++++++++++++++++++++++++++++++++++++++++++++++++++</csp:comment>
<script language="cache" method="cmsPubTracking" arguments='cmsStory:dt.cms.schema.CMSStory=-1, latest:%Integer=0' returntype="%TimeStamp" procedureblock="1">
set return = ""
; By default, get the oldest entry:
set order = $case(latest, 1:"DESC", :"ASC")
try {
; See Roberto's and Sungung's replies:
; https://groups.google.com/d/topic/intersystems-public-cache/yKft-NK826I/discussion
; https://groups.google.com/d/topic/intersystems-public-cache/DH1fQOzwPiM/discussion
set sql = "SELECT StartDate FROM dt_cms_schema.CMSStoryPubTracking WHERE CMSStory = ? ORDER BY StartDate " _ order
set (sc1, sc2, sc3) = -1
set rs = ##class(%ResultSet).%New()
set sc1 = rs.Prepare(sql)
if ($$$ISOK(sc1)) {
set sc2 = rs.Execute(cmsStory.%Id())
if ($$$ISOK(sc2)) {
do rs.%Next(.sc3)
set:($$$ISOK(sc3)) return = rs.GetData(1)
}
}
} catch(e) {
; What to log and where?
}
quit return
</script>
<csp:comment>
<csp:object name="gStory" classname="dt.cms.schema.CMSStory" objid="27846880">
#(..cmsPubTracking(gStory))#
</csp:comment>
<csp:comment>++++++++++++++++++++++++++++++++++++++++++++++++++++++++++</csp:comment>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment