Friday, September 28, 2018

Using JSLink as an alternative for Calculated columns to Display Images Depending on Checkbox values

alert("Hello");

(function () {
    alert('starting')
    var fieldCtx = {};

    fieldCtx.Templates = {};
    fieldCtx.Templates.Fields = {
        "ShowOnDisplayBoard": //This is field name, make sure to enter the internal column name
        {
            "View": UpdateApprovalTempalte //Enter the function name
        }
    };

    SPClientTemplates.TemplateManager.RegisterTemplateOverrides(fieldCtx);
})();

var imgTrue = "<img src='/siteassets/checked.png' width='16px'/>"
var imgFalse = "<img src='/siteassets/uncheck.png' width='16px'/>"
 

function UpdateApprovalTempalte(ctx) {
    var columnValue = ctx.CurrentItem.ShowOnDisplayBoard;  // get the value of the ApprovalColumn field of the current item
    var returnValue = "";
    if (columnValue == 'Yes')
        returnValue = imgTrue;
    else if (columnValue == 'No')
        returnValue = imgFalse;
    else if (columnValue == '')
        returnValue = imgFalse;
    else
        returnValue = columnValue;

    return returnValue;
}

No comments:

Power Automate + Excel data

Extract excel data, get manager and update row with user details which will get from GET MANAGER Concepts and examples Key column:  Column i...