Add checkbox field to notification only if true

This topic contains 4 replies, has 3 voices, and was last updated by  Paul Ostwick 1 week, 4 days ago.

  • We have a third party company that handles our printer toner orders. Currently, a form with checkboxes is filled out and a notification is sent to them with “true” or “false” by the cartridge color.

    Is there a way to only show the field if the value is true?

     

    Form:

    <span class=”sn-tooltip-basic ” title=”” data-original-title=”” data-toggle=”tooltip” data-placement=”auto”>Colors Needed</span>
    <div class=”io_table col-xs-12 form-field input_controls”><input id=”IO:7c3e07e4db8c2200a8f2f72aaf961961″ class=”cat_item_option” name=”IO:7c3e07e4db8c2200a8f2f72aaf961961″ type=”HIDDEN” />
    <div class=”row sc-row sc_checkbox”>
    <div class=”col-xs-12 catalog-checkbox”><span class=”input-group-checkbox”><input id=”ni.IO:c6dc63ecdb8c2200a8f2f72aaf96192f” class=”checkbox” title=”” checked=”checked” name=”ni.IO:c6dc63ecdb8c2200a8f2f72aaf96192f” type=”checkbox” data-original-title=”Black” /><label id=”ni.IO:c6dc63ecdb8c2200a8f2f72aaf96192f_label” class=”checkbox-label” for=”ni.IO:c6dc63ecdb8c2200a8f2f72aaf96192f”>Black</label></span></div>
    <input id=”IO:c6dc63ecdb8c2200a8f2f72aaf96192f” class=”cat_item_option” name=”IO:c6dc63ecdb8c2200a8f2f72aaf96192f” type=”HIDDEN” value=”false” /><input id=”sys_original.IO:c6dc63ecdb8c2200a8f2f72aaf96192f” class=”cat_item_option” name=”sys_original.IO:c6dc63ecdb8c2200a8f2f72aaf96192f” type=”HIDDEN” value=”false” /></div>
    <div class=”row sc-row sc_checkbox”>
    <div class=”col-xs-12 catalog-checkbox”><span class=”input-group-checkbox”><input id=”ni.IO:5f2da3ecdb8c2200a8f2f72aaf9619e8″ class=”checkbox” title=”” name=”ni.IO:5f2da3ecdb8c2200a8f2f72aaf9619e8″ type=”checkbox” data-original-title=”Cyan” /><label id=”ni.IO:5f2da3ecdb8c2200a8f2f72aaf9619e8_label” class=”checkbox-label” for=”ni.IO:5f2da3ecdb8c2200a8f2f72aaf9619e8″>Cyan</label></span></div>
    <input id=”IO:5f2da3ecdb8c2200a8f2f72aaf9619e8″ class=”cat_item_option” name=”IO:5f2da3ecdb8c2200a8f2f72aaf9619e8″ type=”HIDDEN” value=”false” /><input id=”sys_original.IO:5f2da3ecdb8c2200a8f2f72aaf9619e8″ class=”cat_item_option” name=”sys_original.IO:5f2da3ecdb8c2200a8f2f72aaf9619e8″ type=”HIDDEN” value=”false” /></div>
    <div class=”row sc-row sc_checkbox”>
    <div class=”col-xs-12 catalog-checkbox”><span class=”input-group-checkbox”><input id=”ni.IO:9d9dafecdb8c2200a8f2f72aaf961995″ class=”checkbox” title=”” name=”ni.IO:9d9dafecdb8c2200a8f2f72aaf961995″ type=”checkbox” data-original-title=”Magenta” /><label id=”ni.IO:9d9dafecdb8c2200a8f2f72aaf961995_label” class=”checkbox-label” for=”ni.IO:9d9dafecdb8c2200a8f2f72aaf961995″>Magenta</label></span></div>
    <input id=”IO:9d9dafecdb8c2200a8f2f72aaf961995″ class=”cat_item_option” name=”IO:9d9dafecdb8c2200a8f2f72aaf961995″ type=”HIDDEN” value=”false” /><input id=”sys_original.IO:9d9dafecdb8c2200a8f2f72aaf961995″ class=”cat_item_option” name=”sys_original.IO:9d9dafecdb8c2200a8f2f72aaf961995″ type=”HIDDEN” value=”false” /></div>
    <div class=”row sc-row sc_checkbox”>
    <div class=”col-xs-12 catalog-checkbox”><span class=”input-group-checkbox”><input id=”ni.IO:50bd2fecdb8c2200a8f2f72aaf961926″ class=”checkbox” title=”” name=”ni.IO:50bd2fecdb8c2200a8f2f72aaf961926″ type=”checkbox” data-original-title=”Yellow” /><label id=”ni.IO:50bd2fecdb8c2200a8f2f72aaf961926_label” class=”checkbox-label” for=”ni.IO:50bd2fecdb8c2200a8f2f72aaf961926″>Yellow</label></span></div>
    </div>
    </div>
    <div class=”col-xs-12 catalog-checkbox”></div>
    <div class=”col-xs-12 catalog-checkbox”>Notification:</div>
    <div class=”col-xs-12 catalog-checkbox”>

    Colors Needed:

    Black:  true

    Cyan:  false

    Magenta:  false

    Yellow:  false

    </div>

  • Here’s the clean version of the checkboxes

    Attachments:
    You must be logged in to view attached files.
  • Hi Mary,

    It will always show all the field values. You would need scripting to make it conditional, which is only in our enterprise suite.

    How are you presenting the variable data? Are you using ${variables.variable_name} in the notification? I would add text in the surrounding notification calling attention to the true/false values and what they mean.

  • Below is the notification, so it sends out each color with a true or false next to it.  I’d rather only have the colors that are true.  The way it is now seems a bit archaic.

    Colors Needed:
    Black:  ${u_black}
    Cyan:  ${u_cyan}
    Magenta:  ${u_magenta}
    Yellow:  ${u_yellow}

  • Here’s a trick I used to use in another help desk product.  It should work in ServiceNow.  You can do it with style sheets.

    First, the style sheet…I’ll use [ and ] instead of < and > so the forum here doesn’t corrupt the code.

    [style type=”text/css”]

    truex { display:block};

    falsex { display:none};

    [/style]

     

    Then you use the SPAN tag around each value:

    [SPAN style=”${u_black}x”]Black: ${u_black}<BR>[/span]
    [SPAN style=”${u_cyan}x”]Black: ${u_cyan}<BR>[/span]

     

    What happens here is if ${u_black} is false, the style sheet applied is “falsex” which is defined in the CSS style sheet as “display:none” which means the browser (or email client) doesn’t even render that text.  Make sure to keep any line breaks (BR) or other such tags inside the SPAN, so you don’t get empty lines in the output.

    This offers various options including using the CSS to actually display a visual checkbox instead of the words “true” or “false.”

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.