You can also use the Visuals API to access recipe data, including the name. Here is an example of printing out all stored recipes.
(function () {
/**
* replace module name with a custom name for the local-script.
*
* All local-script should be attached to the "custom.ls" package.
* If more than one script is required for an application, a common root package
* should be created (e.g. "custom.ls.customerName.*").
*/
var MODULE_NAME = "getRecipeName",
ENABLE_LOGGING = false,
RECORD_LOG = false,
logger = shmi.requires("visuals.tools.logging").createLogger(MODULE_NAME, ENABLE_LOGGING, RECORD_LOG),
fLog = logger.fLog,
log = logger.log,
module = shmi.pkg( MODULE_NAME );
// MODULE CODE - START
/* private variables */
/* private functions */
function listTemplatesCallback(response,err){
if(!err){
for(template in response.templates){
rm.listRecipes(response.templates[template].id,{},listRecipesCallback);
}
} else {
console.log("Error getting templates: " + err);
}
};
function listRecipesCallback(response,err){
if(!err){
for(recipe in response.recipes){
console.log(response.recipes[recipe].name);
}
} else {
console.log("Error getting recipes: " + err);
}
};
/**
* Implements local-script run function.
*
* This function will be called each time a local-script will be enabled.
*
* @param {LocalScript} self instance reference of local-script control
*/
module.run = function (self) {
// Get recipe manager
rm = shmi.visuals.session.RecipeManager;
// Retrieve all templates and corresponding recipes
rm.listTemplates({}, listTemplatesCallback);
//Place your Code here
/* called when this local-script is disabled */
self.onDisable = function () {
self.run = false; /* from original .onDisable function of LocalScript control */
};
};
// MODULE CODE - END
fLog("module loaded");
})();
... View more