How to remove null filed in approval email

Brahmi Pandla
Tera Guru

Hi @everyone,

 

Could you please help me with remove null filed in Approval email, please check below snap

BrahmiPandla_0-1770805645675.png

 

7 REPLIES 7

BhavaniYamsani
Giga Contributor

Hi @Brahmi Pandla ,

You have configured this Approval mail in Notification module right? Or Please provide the details how you configured this?

Thanks & Regards
Yamsani Bhavani

Hi @BhavaniYamsani ,

 

Thanks for response Please check provided email script

Ankur Bawiskar
Tera Patron

@Brahmi Pandla 

we don't know how you are printing that email body, so can't help.

seems something is wrong in your script.

Does your catalog item have MRVS inside it?

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Brahmi Pandla
Tera Guru

The below is mail script written

 

template.print("Summary of Requested item:\n");
var item = new GlideRecord("sc_req_item");
item.addQuery("sys_id", current.sysapproval);
item.query();
while (item.next()) {
    var nicePrice = item.price.toString();
    if (nicePrice != '') {
        nicePrice = parseFloat(nicePrice);
        nicePrice = nicePrice.toFixed(2);
    }
    template.print(item.number + ":  " + item.cat_item.getDisplayValue() + "\n");
    template.print("    Options:\n");

    var keys = new Array();
    //var set = new Packages.com.glideapp.servicecatalog.variables.VariablePoolQuestionSet();
    var set = new GlideappVariablePoolQuestionSet();
    set.setRequestID(item.sys_id);
    set.load();
    var vs = set.getFlatQuestions();
    template.print("<table style=' border-color: white; background-color: lightblue;' border='1' width='400' cellspacing='2' cellpadding='2'><tbody>");
    template.print("<tr style=' border-color: white; background-color: lightblue;' border='1' width='400' cellspacing='2' cellpadding='2'><th>Item</th><th>Value</th></tr>");
    //template.space(4);

    for (var i = 0; i < vs.size(); i++) {
        if (vs.get(i).getLabel() != '') {
            if (item.cat_item == 'cf2a3f204f0d2a006209ecee0210c7df' || item.cat_item == 'aa895f894f4acb0029160ad14210c70d' || item.cat_item == '2f7aafc04f1dab80aca9e28d0210c743') {
                if (vs.get(i).getDisplayValue() != "false" && vs.get(i).getDisplayValue() != "")
                    if (vs.get(i).getLabel() == "Contact name (If different from Requested By)" || vs.get(i).getLabel() == "[Optional] Contact phone" || vs.get(i).getLabel() == "Name (needs to be selected from the Service Catalog Home Page)" || vs.get(i).getLabel() == "User ID" || vs.get(i).getLabel() == "Region" || vs.get(i).getLabel() == "Job  Title" || vs.get(i).getLabel() == "New IFF employee? (For rehire or relocation, choose No)" || vs.get(i).getLabel() == "Location" || vs.get(i).getLabel() == "Business Unit" || vs.get(i).getLabel() == "Equivalent user" || current.wf_activity.name == 'Get manager approval' || vs.get(i).getLabel() == "Requested For Name" || vs.get(i).getLabel() == "Job Title" || vs.get(i).getLabel() == "Requested By Name" || vs.get(i).getLabel() == "Create new AD user" || vs.get(i).getLabel() == "Frutarom File Server permissions" || vs.get(i).getLabel() == "Please provide the File Server path" || vs.get(i).getLabel() == "Frutarom HPM (Hyperion)" || vs.get(i).getLabel() == "Frutarom EIS (Finance Reporting)" || vs.get(i).getLabel() == "Justification for your access request:")

                {
                    //template.space(4);
                    template.print("<tr style=' border-color: white; background-color: lightblue;' border='1' width='400' cellspacing='2' cellpadding='2'><td>" + vs.get(i).getLabel() + "</td><td>" + vs.get(i).getDisplayValue() + "</td></tr>");