convert UI Action to List Action in Workspace

Alon Grod
Tera Expert

Hi,

I created a UI Action on wm_task record that convert the form the pdf in a specific format and download the file to the login user computer.

Now I want to do the same Action but on a List so that the user can choose multiple records and click on the List UI Action and it will convert and download all the selected records.

This is my script of the record UI Action:

// Code Generated by Sidekick is for learning and experimentation purposes only.
var pdf = new sn_pdfgeneratorutils.PDFGenerationAPI();

var html;

var gr = new GlideRecord("wm_task");

if (gr.get(current.sys_id)) {

    html = "<html><head><style>";
    html += "body { direction: rtl; font-family: Arial, sans-serif; color: #111; margin: 0; padding: 0; }";
    html += ".section { font-size: 16px; font-weight: bold; margin-top: 18px; margin-bottom: 6px; text-align: center; }";
    html += ".field-line { font-size: 11px; margin-bottom: 4px; text-align: right; margin-right: 20px; font-weight: normal; }";
    html += "</style></head><body>";

    // פקודת עבודה section
    html += '<div class="section">פקודת עבודה</div>';
    html += fieldLine("מזהה פנייה", gr.work_order.number);
    html += fieldLine("בר קוד מזהה פנייה", "");
    html += fieldLine("קטגוריה", gr.work_order.u_category_order.title);
    html += fieldLine("מהות הפנייה", gr.work_order.u_pnia);
    html += fieldLine("תיאור הפנייה", gr.description);
    html += fieldLine("תאריך ושעת פתיחה", gr.sys_created_on.getDisplayValue());

    html += "</body></html>";

    function fieldLine(label, val) {
        return '<div class="field-line">' + label + ': ' + val + '</div>';
    }

    var result = pdf.convertToPDF(
        html, 'wm_task', current.sys_id, 
        (gr.parent ? gr.parent.number : gr.number) + 'pdf'
    );

    if (result.status === 'success' && result.attachment_id) {
        var downloadURL = '/sys_attachment.do?sys_id=' + result.attachment_id;
        var gURL = new GlideURL(downloadURL);
       // action.setRedirectURL(gURL);
        gs.addInfoMessage("Success");
    } else {
        gs.addErrorMessage("Failed");
    }
}


How can I adjust this script for the UI List action in Workspace:

AlonGrod_0-1767176872137.pngAlonGrod_1-1767176921434.png

 



0 REPLIES 0