Click Editor to view the HTML which builds this card and to add handlebars classes.
Make sure Define source without mapping is checked, here the actual mapping of the data is defined.
In this template, there is already a d. added in front of Handlebars expression and this expression points to the correct JSON path.
Scroll down and you will find Handlebars block helper function each, it points to the correct JSON path of the items result set.
Replace {{dataSets.[0].data.d.LifeCycleStatusName}}
with {{lcsHelper dataSets.[0].data.d.LifeCycleStatusName}}
handlebar helper function.
{{lcsHelper dataSets.[0].data.d.LifeCycleStatusName}}
You will see a pop-up window alerting on missing helper function. Click Close to implement it.
We have not yet implemented lcsHelper
function.
Click Handle… to switch to the Handlebars tab where missing Handlebars helper function can be implemented.
Replace existing source code with below.
Handlebars.registerHelper("lcsHelper", function (passedString) {
if (passedString.includes("A")) {
return new Handlebars.SafeString( "<img src='green.png' style=' width: 24px; height: 24px;'>");
}
if (passedString.includes("R")) {
return new Handlebars.SafeString("<img src='yellow.png' style=' width: 24px; height: 24px;'>");
}
return new Handlebars.SafeString( "<img src='red.png' style=' width: 24px; height: 24px;'>");
});
This Handlebars helper function will evaluate the passedString
which is the LifeCycleStatusName
JSON value. This function will insert an image depending on the status and return the related HTML
snippet. If the Status is C (closed) than the function will not insert any image.