jacebenson / jace.pro

A blog about servicenow and other technology
https://jace.pro
20 stars 17 forks source link

Deep Dive into Multirow variable sets #36

Open jacebenson opened 5 years ago

jacebenson commented 5 years ago

What is the post about? Multirow variable sets

What things would help with writing the post

jacebenson commented 5 years ago

Handling the notifications.

Example from ash on slack;

(function runMailScript(/* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */ event) {

    function genericResource() {
        var itemGr = new GlideRecord("sc_req_item");
        itemGr.addQuery("sys_id", current.sysapproval);
        itemGr.query();

        if (itemGr.next()){
            var service = itemGr.variables.cscr_chooseService; //Providers
            var provChoices = itemGr.variables.cscr_providerChoices; //Create generic provider/resource    

            if (service == 'Providers' && provChoices == 'Create generic provider/resource'){

                template.print('<table border="1px solid black">');
                template.print( "<tr bgcolor='#ddd'align='center'>" );
                template.print("<td style='text-align:center;font-family:tahoma' colspan='10'><strong>Generic Provider/Resource</strong></td>");
                template.print( "</tr>" );

                template.print( "<tr>" );
                template.print( "<td style='font-family:tahoma'><left><b>Department </b></left></td>" );
                template.print( "<td style='font-family:tahoma'><left><b>Visit Type </b></left></td>" );
                template.print( "<td style='font-family:tahoma'><left><b>Block </b></left></td>" );
                template.print( "<td style='font-family:tahoma'><left><b>Duration(Minutes) </b></left></td>" );

                template.print( "</tr>" );

                var mrvs = itemGr.variables.generic_provider_resource;
                var ritm = itemGr.getUniqueValue();
                var rowCount = mrvs.getRowCount();
                for (var i2 = 0; i2 < rowCount; i2++){
                    var row = mrvs.getRow(i2);

                    var deptGenTbl = new GlideRecord('u_mc_sched_dept');
                    deptGenTbl.get("sys_id", row.cscr_generictbl_dept);
                    var deptGen = deptGenTbl.u_display_name;

                    var visitTbl = new GlideRecord('u_mc_sched_sched_visit_type');
                    visitTbl.get("sys_id", row.cscr_generictbl_vsttype);
                    var visitGen = visitTbl.u_display_name;

                    var blockTbl = new GlideRecord('u_mc_sched_blocks');
                    blockTbl.get("sys_id", row.cscr_generictbl_block);
                    var blockGen = blockTbl.u_display_name;

                    template.print( "<tr>" );
                    template.print( "<td style='font-family:tahoma'><left>" +deptGen+ "</left></td>" );
                    template.print( "<td style='font-family:tahoma'><left>" +visitGen+ "</left></td>" );
                    template.print( "<td style='font-family:tahoma'><left>" +blockGen+ "</left></td>" );

                    template.print( "</tr>" );
                }
                template.print('</table>');
            } else {
                return;
            }
        }
    }

    genericResource();
})(current, template, email, email_action, event);
jacebenson commented 4 years ago

So in short; MRVS issues;

MRVS do not access non MRVS content
MRVS do not allow UI Policies to hide variables
MRVS, until NY, were not shown in the summary
MRVS do not allow certain types of variables to be used. This is described better on DOCS
MRVS cascade on Order Guides is not supported (why are you using an order guide, nevermind... it is what it is)
MRVS in emails are weird
Server-side access to the MRVS is weird
MRVS summarizer is only available on Service Portal
jacebenson commented 4 years ago

https://docs.servicenow.com/bundle/newyork-it-service-management/page/product/service-catalog-management/concept/c_ServiceCatalogVariableSets.html

jacebenson commented 3 years ago

Another interesting related from checksumfailed https://gist.github.com/ChecksumFailed/c6e62c133fd2ecefb4affe9f5d675bb6