Open mhulse opened 11 years ago
Some interesting info here:
class method for number of rows?
Need %ROWCOUNT
or something.
Here's from ##class(dt.cms.support.Rules).getIsAreaSlotted(areaName, sectionName, PubId)
:
/// Returns a boolean (true if stories are slotting in the section/area.
ClassMethod getIsAreaSlotted(
areaName As %String,
sectionName As %String,
publicationId As %Integer,
debug As %Integer = 0) As %Boolean
{
set GridId = 0
&sql(select p.currentGridId into :GridId from dt_cms_schema.Page p, dt_cms_schema."Section" s
where p.sectionid = s.id and s.publicationid = :publicationId and s.name = :sectionName)
if (SQLCODE '= 0) {
do ..error(debug,"rules.cls - getIsAreaSlotted() - Failed to get grid. SQLCODE: " _ SQLCODE)
Quit 1
}
if (GridId = 0) {
do ..error(debug,"rules.cls - getIsAreaSlotted() - Failed to get grid. SectionName " _ sectionName _ " appears to be invalid.")
Quit 1
}
&sql(select ID from dt_cms_schema.Area where name = :areaName and gridID = :GridId)
if (SQLCODE = 100) {
do ..error(debug,"rules.cls - getIsAreaSlotted() - Failed to get area - " _ areaName _ ". Invalid areaName")
Quit 1
}
set Slots = ##class(dt.cms.schema.Area).GetAreaMappings(areaName, GridId)
Quit (Slots.Count() > 0)
}
Not sure if that's of any help.
... Or something along those lines.
I'd try to re-use existing query... Maybe make it an
SQL
ClassMethod
and write anotherClassMethod
to return acount()
.Would also need a new RULE to do and
if
else
check.