﻿ // Sample Custom Icon, Color and Formatter for Single View Configuration
var crmColors = {
    darkAmber: "#F67842",
    lightAmber: "#FFB223",
    darkRed: "#A52121",
    darkBlue: "#4573B1",
    lightBlue: "#5B99C4",
    darkPurple: "#B07395",
    darkGreen: "#4A962A",
    teal: "Teal"
};

function determineCustomColor(record, entityLogicalName) {
    switch (entityLogicalName) {
    case "fin_productholding":
        return crmColors.lightBlue;
    case "opportunity":
        return crmColors.darkGreen;
    case "incident":
        return crmColors.lightAmber; // Replace with RAG Status later on
    default:
        return crmColors.darkPurple;
    }
}
function determineCustomIcon(record, entityLogicalName) {
    switch (entityLogicalName) {
    case "opportunity":
        if (record.Name.indexOf("Equity") >= 0) {
            return "AssetMgt/Equity.png"
        }
        if (record.Name.indexOf("Quant") >= 0) {
            return "Banking/AdvisoryRoadAhead.png"
        }
        if (record.Name.indexOf("sample") >= 0) {
            return "AssetMgt/Investment.png"
        }
        return "Temp.png";
    case "incident":
        if (record.CaseTypeCode.Value == 1) {
            return "Temp.png"
        } // Question
        if (record.CaseTypeCode.Value == 2) {
            return "Insurance/Fire.png"
        } // Problem
        if (record.CaseTypeCode.Value == 3) {
            return "Insurance/Person.png"
        } // Request - Needs Different Icon
    default:
        return "Temp.png";
    }
}
function determineCustomFormat(record, entityLogicalName, field) {
    //alert(entityLogicalName + "/" + field + ": " + record[field]);
    //alert(record[field].Value);
    var t = record[field];
    switch (entityLogicalName + "/" + field) {
    case "fin_productholding/fin_ProductId":
        switch (t.Name) {
        case "Mortgages":
            return "<br /><br >Mortgage<br />Account";
        case "Loans":
            return "<br /><br >Personal<br />Loan";
        case "Savings":
            return "<br /><br >Savings<br />Account";
        case "Overdraft":
            return "<br />Current Account<br />with Overdraft";
        case "Insurance":
            return "<br />Life Insurance<br />Policy";
        case "Current Accounts":
            return "<br /><br />Current Account";
        case "Credit Cards":
            return "<br />Credit Card<br />(Visa)";
        }
        return t.Name.replace(" (Sample)", "").replace(" - ", ":<br />");
    case "incident/Title":
        t = (t == null) ? "" : t.replace(" (sample)", "");
        return (t.length <= 60) ? "<br />" + t : t;
    default:
        return t;
    }
}
function quickButtonClicked(context) {
}
// PM: Unsupported Code for now for Update 7.1 pending Product Group feedback
top.window.quickButtonClicked = quickButtonClicked;
top.window.determineCustomColor = determineCustomColor;
top.window.determineCustomIcon = determineCustomIcon;
top.window.determineCustomFormat = determineCustomFormat;