unable to use else if statement

kevfbs
ServiceNow Employee
ServiceNow Employee

i have a piece of code in a business rule that im unable to use:

(function executeRule(current, previous /*null when async*/) {
var gCase = new GlideRecord('sn_customerservice_case');
gCase.get(current.u_case);

//gs.addInfoMessage('SUPPORT SEGMENT:'+gCase.account.u_support_segment);


var fName = 'OPE - RFO CASE /INC';

if(gCase.account.u_support_segment == "9e4aef96874d3910baccc8840cbb3533" || gCase.account.u_support_segment == "035ae3d6874d3910baccc8840cbb3504");
{

var text = '<html>';
text += '<p>Enterprise Repair Closure Summary </p>'
text += '<p>Dear Customer, </p> '
text += '<p>Regarding the Ticket: '+ gCase.number; + 'to investigate the Circuit' + gCase.incident.u_circuit_id_network + 'here is the reason for outage:</p>'
text += '<p>Failure Type:' + gCase.incident.u_failure_origin + '</br> '
text += 'Root Cause:' + gCase.incident.cause + '</br> '
text += 'Actions Taken:' + gCase.incident.actions_taken + '</br> '
text += 'Date/Hour Outage Start:' + gCase.incident.u_outage_start + '</br> '
text += 'Date/Hour Outage Stop:' + gCase.incident.u_outage_stop + '</br> '
text += 'Normalization confirmed by:' + gCase.incident.u_nombre_persona_recu + '</br> '
text += 'Contact Phone Number:' + gCase.incident.u_tel_de_la_persona_recuperacion + '</p> '
text += '<p>If you have any further questions, please do not hesitate to contact us. In the next few days, you will receive a satisfaction survey to evaluate our customer service. </p> '
text += '<p>Regards,</br> '
text += 'Cirion.</br> '
text += 'Inspires the future.</p> '

text += '</html>';

 

var v = new sn_pdfgeneratorutils.PDFGenerationAPI;
var result = v.convertToPDF(text, "sn_customerservice_case", gCase.sys_id.toString(), fName);

 

var attachId = result.attachment_id;
var status = result.status;
gs.info(status);
gs.info(attachId);
gs.eventQueue('incident.send_email_with_pdf', current, gs.getUserID(), gs.getUserName());
}


if(gCase.account.u_support_segment == "24e9a427879cb5d02beeeb930cbb35b4" || gCase.account.u_support_segment == "856f0f43871835d02beeeb930cbb3593");
{
gs.eventQueue('incident.send_email_with_pdf_pt', current, gs.getUserID(), gs.getUserName());

var text = '<html>';
text += '<p>Enterprise Repair Closure Summary </p>'
text += '<p>Prezado cliente, </p> '
text += '<p>Sobre o incidente: '+ gCase.number; + 'para análise do circuito' + gCase.incident.u_circuit_id_network + 'segue o resumo:</br>'
text += 'Tipo de Problema:' + gCase.incident.u_failure_origin + '</br> '
text += 'Causa Raiz:' + gCase.incident.cause + '</br> '
text += 'Ações para Solução:' + gCase.incident.actions_taken + '</br> '
text += 'Data/Hora de Criação do Ticket (Outage Start):' + gCase.incident.u_outage_start + '</br> '
text += 'Data/hora de Resolução (Outage Stop):' + gCase.incident.u_outage_stop + '</br> '
text += 'Validado por:' + gCase.incident.u_nombre_persona_recu + '</br> '
text += 'Contato telefônico:' + gCase.incident.u_tel_de_la_persona_recuperacion + '</p> '
text += '<p>Qualquer dúvida, não hesite em contactar-nos. Nos próximos dias chegará uma pesquisa de satisfação para avaliar o nosso atendimento. </p> '
text += '<p>Atenciosamente,</br> '
text += 'Cirion.</br> '
text += 'Inspira o Futuro</p> '

text += '</html>';

 

var v = new sn_pdfgeneratorutils.PDFGenerationAPI;
var result = v.convertToPDF(text, "sn_customerservice_case", gCase.sys_id.toString(), fName);

 

var attachId = result.attachment_id;
var status = result.status;
gs.info(status);
gs.info(attachId);

}



if (gCase.account.u_support_segment == "8c75570b875835d02beeeb930cbb35de" || gCase.account.u_support_segment == "9a0a2c27879cb5d02beeeb930cbb35e5" || gCase.account.u_support_segment == "975fcb43871835d02beeeb930cbb35f8" || gCase.account.u_support_segment == "67e960a3879cb5d02beeeb930cbb3587" || gCase.account.u_support_segment == "85f9e427879cb5d02beeeb930cbb35e7" || gCase.account.u_support_segment == "72f96427879cb5d02beeeb930cbb358a" || gCase.account.u_support_segment == "730a6067879cb5d02beeeb930cbb3591" || gCase.account.u_support_segment == "691aec27879cb5d02beeeb930cbb3518") {

gs.eventQueue('incident.send_email_with_pdf_sp', current, gs.getUserID(), gs.getUserName());

var text = '<html>';
text += '<p>Enterprise Repair Closure Summary </p>'
text += '<p>Estimado cliente, </p> '
text += '<p>Sobre el Ticket: '+ gCase.number; + 'para el servicio' + gCase.incident.u_circuit_id_network + 'este es el resumen:</p>'
text += '<p>Tipo de problema: ' + gCase.incident.u_failure_origin + '</br> '
text += 'Causa Raíz:' + gCase.incident.cause + '</br> '
text += 'Acción para resolución:' + gCase.incident.actions_taken + '</br> '
text += 'Fecha/Hora de creación de Ticket (Outage Start):' + gCase.incident.u_outage_start + '</br> '
text += 'Fecha/hora de Resolución (Outage Stop): ' + gCase.incident.u_outage_stop + '</br> '
text += 'Persona que confirma servicio:' + gCase.incident.u_nombre_persona_recu + '</br> '
text += 'No. Telefónico del contacto: ' + gCase.incident.u_tel_de_la_persona_recuperacion + '</p> '
text += '<p>Ante cualquier consulta, no dude en contactarnos. En próximos días les llegara una encuesta para calificar nuestro servicio. </p> '
text += '<p>Saludos,</br> '
text += 'Cirion.</br> '
text += 'Inspira el Futuro</p> '

text += '</html>';

 

var v = new sn_pdfgeneratorutils.PDFGenerationAPI;
var result = v.convertToPDF(text, "sn_customerservice_case", gCase.sys_id.toString(), fName);

 

var attachId = result.attachment_id;
var status = result.status;
gs.info(status);
gs.info(attachId);

}

})(current, previous);
 
im trying to generate a pdf only when specific conditions are met however when i use this 3 pdf get created as if all the conditions are being met, additionally it does not allow me to use "if/else if/else" giving the or statements, any ideas?
1 ACCEPTED SOLUTION

Peter Bodelier
Giga Sage

Hi @kevfbs,

 

You had ; behind your if statements. It didn't like that:

(function executeRule(current, previous /*null when async*/ ) {
    var gCase = new GlideRecord('sn_customerservice_case');
    gCase.get(current.u_case);

    //gs.addInfoMessage('SUPPORT SEGMENT:'+gCase.account.u_support_segment);

    var fName = 'OPE - RFO CASE /INC';

    if (gCase.account.u_support_segment == "9e4aef96874d3910baccc8840cbb3533" || gCase.account.u_support_segment == "035ae3d6874d3910baccc8840cbb3504") {

        var text = '<html>';
        text += '<p>Enterprise Repair Closure Summary </p>';
        text += '<p>Dear Customer, </p> ';
        text += '<p>Regarding the Ticket: ' + gCase.number; + 'to investigate the Circuit' + gCase.incident.u_circuit_id_network + 'here is the reason for outage:</p>';
        text += '<p>Failure Type:' + gCase.incident.u_failure_origin + '</br> ';
        text += 'Root Cause:' + gCase.incident.cause + '</br> ';
        text += 'Actions Taken:' + gCase.incident.actions_taken + '</br> ';
        text += 'Date/Hour Outage Start:' + gCase.incident.u_outage_start + '</br> ';
        text += 'Date/Hour Outage Stop:' + gCase.incident.u_outage_stop + '</br> ';
        text += 'Normalization confirmed by:' + gCase.incident.u_nombre_persona_recu + '</br> ';
        text += 'Contact Phone Number:' + gCase.incident.u_tel_de_la_persona_recuperacion + '</p> ';
        text += '<p>If you have any further questions, please do not hesitate to contact us. In the next few days, you will receive a satisfaction survey to evaluate our customer service. </p> ';
        text += '<p>Regards,</br> ';
        text += 'Cirion.</br> ';
        text += 'Inspires the future.</p> ';

        text += '</html>';

        var v = new sn_pdfgeneratorutils.PDFGenerationAPI;
        var result = v.convertToPDF(text, "sn_customerservice_case", gCase.sys_id.toString(), fName);



        var attachId = result.attachment_id;
        var status = result.status;
        gs.info(status);
        gs.info(attachId);
        gs.eventQueue('incident.send_email_with_pdf', current, gs.getUserID(), gs.getUserName());
    } else if (gCase.account.u_support_segment == "24e9a427879cb5d02beeeb930cbb35b4" || gCase.account.u_support_segment == "856f0f43871835d02beeeb930cbb3593") {
        gs.eventQueue('incident.send_email_with_pdf_pt', current, gs.getUserID(), gs.getUserName());

        var text = '<html>';
        text += '<p>Enterprise Repair Closure Summary </p>'
        text += '<p>Prezado cliente, </p> '
        text += '<p>Sobre o incidente: ' + gCase.number; + 'para análise do circuito' + gCase.incident.u_circuit_id_network + 'segue o resumo:</br>'
        text += 'Tipo de Problema:' + gCase.incident.u_failure_origin + '</br> '
        text += 'Causa Raiz:' + gCase.incident.cause + '</br> '
        text += 'Ações para Solução:' + gCase.incident.actions_taken + '</br> '
        text += 'Data/Hora de Criação do Ticket (Outage Start):' + gCase.incident.u_outage_start + '</br> '
        text += 'Data/hora de Resolução (Outage Stop):' + gCase.incident.u_outage_stop + '</br> '
        text += 'Validado por:' + gCase.incident.u_nombre_persona_recu + '</br> '
        text += 'Contato telefônico:' + gCase.incident.u_tel_de_la_persona_recuperacion + '</p> '
        text += '<p>Qualquer dúvida, não hesite em contactar-nos. Nos próximos dias chegará uma pesquisa de satisfação para avaliar o nosso atendimento. </p> '
        text += '<p>Atenciosamente,</br> '
        text += 'Cirion.</br> '
        text += 'Inspira o Futuro</p> '

        text += '</html>';



        var v = new sn_pdfgeneratorutils.PDFGenerationAPI;
        var result = v.convertToPDF(text, "sn_customerservice_case", gCase.sys_id.toString(), fName);



        var attachId = result.attachment_id;
        var status = result.status;
        gs.info(status);
        gs.info(attachId);

    } else if (gCase.account.u_support_segment == "8c75570b875835d02beeeb930cbb35de" || gCase.account.u_support_segment == "9a0a2c27879cb5d02beeeb930cbb35e5" || gCase.account.u_support_segment == "975fcb43871835d02beeeb930cbb35f8" || gCase.account.u_support_segment == "67e960a3879cb5d02beeeb930cbb3587" || gCase.account.u_support_segment == "85f9e427879cb5d02beeeb930cbb35e7" || gCase.account.u_support_segment == "72f96427879cb5d02beeeb930cbb358a" || gCase.account.u_support_segment == "730a6067879cb5d02beeeb930cbb3591" || gCase.account.u_support_segment == "691aec27879cb5d02beeeb930cbb3518") {

        gs.eventQueue('incident.send_email_with_pdf_sp', current, gs.getUserID(), gs.getUserName());

        var text = '<html>';
        text += '<p>Enterprise Repair Closure Summary </p>'
        text += '<p>Estimado cliente, </p> '
        text += '<p>Sobre el Ticket: ' + gCase.number; + 'para el servicio' + gCase.incident.u_circuit_id_network + 'este es el resumen:</p>'
        text += '<p>Tipo de problema: ' + gCase.incident.u_failure_origin + '</br> '
        text += 'Causa Raíz:' + gCase.incident.cause + '</br> '
        text += 'Acción para resolución:' + gCase.incident.actions_taken + '</br> '
        text += 'Fecha/Hora de creación de Ticket (Outage Start):' + gCase.incident.u_outage_start + '</br> '
        text += 'Fecha/hora de Resolución (Outage Stop): ' + gCase.incident.u_outage_stop + '</br> '
        text += 'Persona que confirma servicio:' + gCase.incident.u_nombre_persona_recu + '</br> '
        text += 'No. Telefónico del contacto: ' + gCase.incident.u_tel_de_la_persona_recuperacion + '</p> '
        text += '<p>Ante cualquier consulta, no dude en contactarnos. En próximos días les llegara una encuesta para calificar nuestro servicio. </p> '
        text += '<p>Saludos,</br> '
        text += 'Cirion.</br> '
        text += 'Inspira el Futuro</p> '

        text += '</html>';



        var v = new sn_pdfgeneratorutils.PDFGenerationAPI;
        var result = v.convertToPDF(text, "sn_customerservice_case", gCase.sys_id.toString(), fName);



        var attachId = result.attachment_id;
        var status = result.status;
        gs.info(status);
        gs.info(attachId);

    }

})(current, previous);

Help others to find a correct solution by marking the appropriate response as accepted solution and helpful.

View solution in original post

1 REPLY 1

Peter Bodelier
Giga Sage

Hi @kevfbs,

 

You had ; behind your if statements. It didn't like that:

(function executeRule(current, previous /*null when async*/ ) {
    var gCase = new GlideRecord('sn_customerservice_case');
    gCase.get(current.u_case);

    //gs.addInfoMessage('SUPPORT SEGMENT:'+gCase.account.u_support_segment);

    var fName = 'OPE - RFO CASE /INC';

    if (gCase.account.u_support_segment == "9e4aef96874d3910baccc8840cbb3533" || gCase.account.u_support_segment == "035ae3d6874d3910baccc8840cbb3504") {

        var text = '<html>';
        text += '<p>Enterprise Repair Closure Summary </p>';
        text += '<p>Dear Customer, </p> ';
        text += '<p>Regarding the Ticket: ' + gCase.number; + 'to investigate the Circuit' + gCase.incident.u_circuit_id_network + 'here is the reason for outage:</p>';
        text += '<p>Failure Type:' + gCase.incident.u_failure_origin + '</br> ';
        text += 'Root Cause:' + gCase.incident.cause + '</br> ';
        text += 'Actions Taken:' + gCase.incident.actions_taken + '</br> ';
        text += 'Date/Hour Outage Start:' + gCase.incident.u_outage_start + '</br> ';
        text += 'Date/Hour Outage Stop:' + gCase.incident.u_outage_stop + '</br> ';
        text += 'Normalization confirmed by:' + gCase.incident.u_nombre_persona_recu + '</br> ';
        text += 'Contact Phone Number:' + gCase.incident.u_tel_de_la_persona_recuperacion + '</p> ';
        text += '<p>If you have any further questions, please do not hesitate to contact us. In the next few days, you will receive a satisfaction survey to evaluate our customer service. </p> ';
        text += '<p>Regards,</br> ';
        text += 'Cirion.</br> ';
        text += 'Inspires the future.</p> ';

        text += '</html>';

        var v = new sn_pdfgeneratorutils.PDFGenerationAPI;
        var result = v.convertToPDF(text, "sn_customerservice_case", gCase.sys_id.toString(), fName);



        var attachId = result.attachment_id;
        var status = result.status;
        gs.info(status);
        gs.info(attachId);
        gs.eventQueue('incident.send_email_with_pdf', current, gs.getUserID(), gs.getUserName());
    } else if (gCase.account.u_support_segment == "24e9a427879cb5d02beeeb930cbb35b4" || gCase.account.u_support_segment == "856f0f43871835d02beeeb930cbb3593") {
        gs.eventQueue('incident.send_email_with_pdf_pt', current, gs.getUserID(), gs.getUserName());

        var text = '<html>';
        text += '<p>Enterprise Repair Closure Summary </p>'
        text += '<p>Prezado cliente, </p> '
        text += '<p>Sobre o incidente: ' + gCase.number; + 'para análise do circuito' + gCase.incident.u_circuit_id_network + 'segue o resumo:</br>'
        text += 'Tipo de Problema:' + gCase.incident.u_failure_origin + '</br> '
        text += 'Causa Raiz:' + gCase.incident.cause + '</br> '
        text += 'Ações para Solução:' + gCase.incident.actions_taken + '</br> '
        text += 'Data/Hora de Criação do Ticket (Outage Start):' + gCase.incident.u_outage_start + '</br> '
        text += 'Data/hora de Resolução (Outage Stop):' + gCase.incident.u_outage_stop + '</br> '
        text += 'Validado por:' + gCase.incident.u_nombre_persona_recu + '</br> '
        text += 'Contato telefônico:' + gCase.incident.u_tel_de_la_persona_recuperacion + '</p> '
        text += '<p>Qualquer dúvida, não hesite em contactar-nos. Nos próximos dias chegará uma pesquisa de satisfação para avaliar o nosso atendimento. </p> '
        text += '<p>Atenciosamente,</br> '
        text += 'Cirion.</br> '
        text += 'Inspira o Futuro</p> '

        text += '</html>';



        var v = new sn_pdfgeneratorutils.PDFGenerationAPI;
        var result = v.convertToPDF(text, "sn_customerservice_case", gCase.sys_id.toString(), fName);



        var attachId = result.attachment_id;
        var status = result.status;
        gs.info(status);
        gs.info(attachId);

    } else if (gCase.account.u_support_segment == "8c75570b875835d02beeeb930cbb35de" || gCase.account.u_support_segment == "9a0a2c27879cb5d02beeeb930cbb35e5" || gCase.account.u_support_segment == "975fcb43871835d02beeeb930cbb35f8" || gCase.account.u_support_segment == "67e960a3879cb5d02beeeb930cbb3587" || gCase.account.u_support_segment == "85f9e427879cb5d02beeeb930cbb35e7" || gCase.account.u_support_segment == "72f96427879cb5d02beeeb930cbb358a" || gCase.account.u_support_segment == "730a6067879cb5d02beeeb930cbb3591" || gCase.account.u_support_segment == "691aec27879cb5d02beeeb930cbb3518") {

        gs.eventQueue('incident.send_email_with_pdf_sp', current, gs.getUserID(), gs.getUserName());

        var text = '<html>';
        text += '<p>Enterprise Repair Closure Summary </p>'
        text += '<p>Estimado cliente, </p> '
        text += '<p>Sobre el Ticket: ' + gCase.number; + 'para el servicio' + gCase.incident.u_circuit_id_network + 'este es el resumen:</p>'
        text += '<p>Tipo de problema: ' + gCase.incident.u_failure_origin + '</br> '
        text += 'Causa Raíz:' + gCase.incident.cause + '</br> '
        text += 'Acción para resolución:' + gCase.incident.actions_taken + '</br> '
        text += 'Fecha/Hora de creación de Ticket (Outage Start):' + gCase.incident.u_outage_start + '</br> '
        text += 'Fecha/hora de Resolución (Outage Stop): ' + gCase.incident.u_outage_stop + '</br> '
        text += 'Persona que confirma servicio:' + gCase.incident.u_nombre_persona_recu + '</br> '
        text += 'No. Telefónico del contacto: ' + gCase.incident.u_tel_de_la_persona_recuperacion + '</p> '
        text += '<p>Ante cualquier consulta, no dude en contactarnos. En próximos días les llegara una encuesta para calificar nuestro servicio. </p> '
        text += '<p>Saludos,</br> '
        text += 'Cirion.</br> '
        text += 'Inspira el Futuro</p> '

        text += '</html>';



        var v = new sn_pdfgeneratorutils.PDFGenerationAPI;
        var result = v.convertToPDF(text, "sn_customerservice_case", gCase.sys_id.toString(), fName);



        var attachId = result.attachment_id;
        var status = result.status;
        gs.info(status);
        gs.info(attachId);

    }

})(current, previous);

Help others to find a correct solution by marking the appropriate response as accepted solution and helpful.