variables.ElementName = getStoryCEName();
variables.CCAPIName = getCCAPIName(variables.elementName);
if ( LEN(TRIM(arguments.uniqueID)) AND LEN(TRIM(arguments.idField)) )
return application.npsStory.ceData.getCEData(variables.elementName, arguments.idField, TRIM(arguments.uniqueID));
else
return application.npsStory.ceData.getCEData(variables.elementName);
return application.npsStory.ceData.getCEData(customElementName=variables.elementName,
searchFields=arguments.searchFields,
searchValues=arguments.searchValues,
queryType='search'
);
return getStory(uniqueID=arguments.globalStoryID,idField=application.npsStory.appConfig.story.fieldNames.globalStoryID);
var idField = application.npsStory.appConfig.story.fieldNames.globalStoryID;
var versionField = application.npsStory.appConfig.story.fieldNames.storyVersionID;
var filterFieldList = "wip,active,published,archived";
var filterFieldNameList = "#application.npsStory.appConfig.story.fieldNames.wip#,#application.npsStory.appConfig.story.fieldNames.active#,#application.npsStory.appConfig.story.fieldNames.active#,#application.npsStory.appConfig.story.fieldNames.archived#";
var sortField = versionField;
var dataArray = getStoryByGlobalStoryID(globalStoryID=arguments.globalStoryID);
var newDataArray = ArrayNew(1);
var sItm = 1;
var vItm = 1;
var currStateFieldPos = 0;
var currFieldName = "";
// excludeStates variables
var eItm=1;
var s=1;
var exState = "";
var exStateFieldPos = 0;
var exStateFieldName = "";
var itemExcluded = false;
// Make sure we have data to filter and sort
if ( ArrayLen(dataArray) AND StructKeyExists(dataArray[1],"values") ) {
// Get the current state field to use
currStateFieldPos = ListFindNoCase(filterFieldList,arguments.state);
if ( currStateFieldPos GT 0 ) {
// Set the field name for the current field. This differs from the state argument.
currFieldName = ListGetAt(filterFieldNameList, currStateFieldPos);
// Filter the returned data by state
for ( sItm=1; sItm LTE ArrayLen(dataArray); sItm=sItm+1 ) {
// Filter out records that DO NOT match the 'state' value
if ( StructKeyExists(dataArray[sItm].values, currFieldName) AND dataArray[sItm].values[currFieldName] EQ 1 ) {
// - Build the array of records where the state = 1
arrayAppend(newDataArray, dataArray[sItm]);
}
}
dataArray = newDataArray;
}
// Does the version parameter have a length
if ( ArrayLen(dataArray) AND LEN(TRIM(arguments.version)) ) {
// If a version is provided, return only the record that matches that verisonID
// If the version is a number get the specific record
if ( IsNumeric(arguments.version) ) {
newDataArray = ArrayNew(1);
// Filter the returned data by version
for ( vItm=1; vItm LTE ArrayLen(dataArray); vItm=vItm+1 ) {
// Filter out records that DO NOT match the 'version' value
if ( TRIM(dataArray[vItm].values[versionField]) EQ arguments.version ) {
// - Filter out expired records
arrayAppend(newDataArray, dataArray[vItm]);
break;
}
}
// Reset the dataArray so it only returns the selected record
dataArray = ArrayNew(1);
dataArray[1] = newDataArray[1];
}
else {
newDataArray = ArrayNew(1);
// Sort the records by versionID ( DOES NOT use the SORTORDER parameter )
newDataArray = application.npsStory.ceData.arrayOfCEDataSort(aOfS=dataArray,key=sortField,sortOrder="asc",sortType="numeric");
if ( arguments.version EQ "max" ) {
// Reset the dataArray so it only returns the selected record
dataArray = ArrayNew(1);
dataArray[1] = newDataArray[ArrayLen(newDataArray)];
}
else if ( arguments.version EQ "min" ) {
// Reset the dataArray so it only returns the selected record
dataArray = ArrayNew(1);
dataArray[1] = newDataArray[1];
}
}
}
else {
// Version argument is Blank so sort the dataArray Values by the sortField using the sortOrder type
if ( ArrayLen(dataArray) GT 1 AND ListFindNoCase("asc,desc",arguments.sortOrder) ) {
// Sort the records by storyVersionID field
newDataArray = application.npsStory.ceData.arrayOfCEDataSort(aOfS=dataArray,key=sortField,sortOrder=arguments.sortOrder,sortType="numeric");
dataArray = newDataArray;
}
}
// Before returning the Array check for Excluded States
// - Remove the excluded states that were passed in from the the dataArray
if ( ArrayLen(dataArray) AND ListLen(arguments.excludeStates) ) {
newDataArray = ArrayNew(1);
// Filter the returned data by state
for ( eItm=1; eItm LTE ArrayLen(dataArray); eItm=eItm+1 ) {
// Start each record as not excluded
itemExcluded = false;
// Go through the list of excluded states to check if it should be excluded
for ( s=1; s LTE ListLen(arguments.excludeStates); s=s+1 ) {
exState = ListGetAt(arguments.excludeStates,s);
// Get the exclude state field to use
exStateFieldPos = ListFindNoCase(filterFieldList,exState);
if ( exStateFieldPos GT 0 ) {
// Set the field name for the current field. This differs from the state argument.
exStateFieldName = ListGetAt(filterFieldNameList, exStateFieldPos);
// Filter out records that DO NOT match the 'state' value
if ( StructKeyExists(dataArray[eItm].values, exStateFieldName) AND dataArray[eItm].values[exStateFieldName] EQ 1 ) {
itemExcluded = true;
break;
}
}
}
if ( NOT itemExcluded )
arrayAppend(newDataArray, dataArray[eItm]);
}
dataArray = newDataArray;
}
}
return dataArray;
var dataPageID = 0;
var dataArray = getStoryVerisonsByGlobalStoryID(globalStoryID=arguments.globalStoryID,version=arguments.version,state=arguments.state);
// Get the pageID from the first record
if ( ArrayLen(dataArray) AND StructKeyExists(dataArray[1],"pageid") )
dataPageID = dataArray[1].pageid;
return dataPageID;
var csPageID = 0;
var dataArray = getStoryVerisonsByGlobalStoryID(globalStoryID=arguments.globalStoryID,version=arguments.version,state=arguments.state);
// Get the pageID from the first record
if ( ArrayLen(dataArray) AND StructKeyExists(dataArray[1],"values") AND StructKeyExists(dataArray[1].values, application.npsStory.appConfig.story.fieldNames.storyPageID) AND IsNumeric(dataArray[1].values[application.npsStory.appConfig.story.fieldNames.storyPageID]) )
csPageID = dataArray[1].values[application.npsStory.appConfig.story.fieldNames.storyPageID];
return csPageID;
var dataArray = ArrayNew(1);
var ccapiDataStruct = StructNew();
var retStruct = StructNew();
var saveStatus = StructNew();
// Check to see if there is data in the element to be updated
if ( StructKeyExists(arguments.elementData, application.npsStory.appConfig.story.fieldNames.storyID) AND LEN(TRIM(arguments.elementData[application.npsStory.appConfig.story.fieldNames.storyID])) )
{
dataArray = getStory(uniqueID=arguments.elementData[application.npsStory.appConfig.story.fieldNames.storyID]);
}
// If no record exists create one, if so update it
/* if ( NOT ArrayLen(dataArray) )
{
// Create the a new record
dataStruct = arguments.elementData;
//dataStruct[variables.elementIDfield] = createUUID(); // new UUID for this "new" data was already created
// Set the update type
retStruct['type'] = 'created';
} */
if ( ArrayLen(dataArray) )
{
// Update the Record
// Set the existing values
ccapiDataStruct = dataArray[1].values;
// Override with the new values
for ( key in arguments.elementData ) {
ccapiDataStruct[key] = arguments.elementData[key];
}
// Set the Page ID from the existing record
ccapiDataStruct.dataPageID = dataArray[1].PageID;
// Update the record
retStruct = saveElementData(elementData=ccapiDataStruct,action="update");
// Set the update type
retStruct['type'] = 'updated';
// Add the current storyIDs to the retStruct
retStruct['storyID'] = ccapiDataStruct.storyID;
retStruct['globalStoryID'] = ccapiDataStruct.globalStoryID;
retStruct['storyVersionID'] = ccapiDataStruct.storyVersionID;
}
// Return the status struct
return retStruct;
var dataArray = ArrayNew(1);
var ccapiDataStruct = arguments.elementData;
var retStruct = StructNew();
var saveStatusStruct = StructNew();
if ( arguments.action EQ "update" )
{
if ( StructKeyExists(arguments.elementData,"dataPageID") AND IsNumeric(arguments.elementData.dataPageID) AND arguments.elementData.dataPageID GT 0 )
{
// Update the record
saveStatusStruct = storyParentCCAPI(ccapiDataStruct);
// Set the update type
if ( NOT StructKeyExists(retStruct,"type") )
retStruct['type'] = 'update-dpid';
}
else
{
// Check to see if there is data in the element to be updated
if ( StructKeyExists(arguments.elementData,arguments.idFieldName) AND LEN(TRIM(arguments.elementData[arguments.idFieldName])) )
{
//dataArray = getStory(uniqueID=arguments.elementData[arguments.idFieldName]);
dataArray = application.npsStory.ceData.getCEData(variables.elementName, arguments.idFieldName, arguments.elementData[arguments.idFieldName]);
}
if ( ArrayLen(dataArray) )
{
// Update the Record
// Set the existing values
ccapiDataStruct = dataArray[1].values;
// Set the Page ID from the existing record
ccapiDataStruct.dataPageID = dataArray[1].PageID;
// Use the arguments.elementData and modify specific values for the keys in the ccapiDataStruct
StructAppend( ccapiDataStruct, arguments.elementData, true);
// Loop over the updateDataStruct and modify specific values for the keys in the ccapiDataStruct
/* for ( key IN ccapiDataStruct ) {
if ( StructKeyExists(arguments.elementData,key) )
ccapiDataStruct[key] = arguments.elementData[key];
} */
// Override with the new values
/* for ( key in arguments.elementData ) {
ccapiDataStruct[key] = arguments.elementData[key];
}*/
// Update the record
saveStatusStruct = storyParentCCAPI(ccapiDataStruct);
// Set the update type
if ( NOT StructKeyExists(retStruct,"type") )
retStruct['type'] = 'update-uuid';
}
}
}
else
{
// If action is "new" remove the dataPageID if it is passed in
if ( StructKeyExists(ccapiDataStruct,"dataPageID") )
StructDelete(ccapiDataStruct,"dataPageID");
// Check to see if there is data in the element that has this ID already
// If so create a new UUID for this "new" record
if ( StructKeyExists(arguments.elementData,arguments.idFieldName) AND LEN(TRIM(arguments.elementData[arguments.idFieldName])) )
{
dataArray = application.npsStory.ceData.getCEData(variables.elementName, arguments.idFieldName, arguments.elementData[arguments.idFieldName]);
if ( ArrayLen(dataArray) )
{
ccapiDataStruct[arguments.idFieldName] = createUUID();
}
}
// Create a new record (no page ID)
saveStatusStruct = storyParentCCAPI(ccapiDataStruct);
// Set the update type
if ( NOT StructKeyExists(retStruct,"type") )
retStruct['type'] = 'create';
}
// Build the status struct
if ( StructKeyExists(saveStatusStruct,"CONTENTUPDATED") AND saveStatusStruct['CONTENTUPDATED'] IS true )
retStruct['status'] = 'success';
else
retStruct['status'] = 'fail';
// Return the status struct
return retStruct;
var retStatusStruct = StructNew();
//application.ADF.utils.doDump(arguments.dataValues,"arguments.dataValues", false);
// Create the page
retStatusStruct = application.ADF.csContent.populateContent(variables.CCAPIName, arguments.dataValues);
/* retStatusStruct RETURNS: CONTENTUPDATED : true/false & CONTENTUPDATERESPONSE: Success:1 */
// Initialize the variables
var csQry = QueryNew("temp");
SELECT AvailableControls.ID,
AvailableControls.ShortDesc AS FormName
FROM AvailableControls
INNER JOIN FormControlMap ON AvailableControls.ID = FormControlMap.FormID
WHERE FormControlMap.ClassID = 1
AND AvailableControls.ElementState = 0
ORDER BY FormName ASC
var qryPageID = "";
var ceDataArray = ArrayNew(1);
SELECT DISTINCT pageid
FROM data_fieldvalue
WHERE fieldValue =
AND formid =
// Check the records returned
if ( qryPageID.recordCount )
{
// Get the element record for the pageid and form id
ArrayAppend(ceDataArray, application.npsStory.ceData.getElementInfoByPageID(pageid=qryPageID.pageid, formid=arguments.formid));
}
return ceDataArray;