Skip to content

Instantly share code, notes, and snippets.

@waldothedeveloper
Created April 19, 2023 17:17
Show Gist options
  • Select an option

  • Save waldothedeveloper/87231b516c1c51056f0138c4f606b049 to your computer and use it in GitHub Desktop.

Select an option

Save waldothedeveloper/87231b516c1c51056f0138c4f606b049 to your computer and use it in GitHub Desktop.

Revisions

  1. waldothedeveloper created this gist Apr 19, 2023.
    109 changes: 109 additions & 0 deletions script_include.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,109 @@
    var Conviva_WorkflowUtils = Class.create();
    Conviva_WorkflowUtils.prototype = Object.extendsObject(AbstractAjaxProcessor, {
    description: function (item) {
    switch (item) {
    // Conviva Payer Portal
    case "45546e4887a674105a6cc9d6cebb35f4":
    return "Review request and validate the requestors role is appropriate for access.";

    // Conviva Collaboration
    case "f602368c87e674105a6cc9d6cebb35e6":
    return (
    "1. Review request \n" +
    "2. Assign Permissions \n" +
    "3. Communicate to requestor with instructions on how to access the specific resources."
    );

    // Conviva Software Request
    case "6f55fa80872a74105a6cc9d6cebb35b0":
    return "1. Review request \n" + "2. Install Software on device";

    // Conviva Virtual Visits
    case "e2f03a0c87e674105a6cc9d6cebb3540":
    return (
    "1. Please add user to the following AD group: \n" +
    "SG _conviva_andorvirtualmsteams_users \n" +
    "\n" +
    "\n" +
    '2. Send email to "[email protected] " and "[email protected]" with the the following directions: \n' +
    "Add user and provide: \n" +
    "First name, last name, e-mail, Role, Clinic and Clinic ID."
    );

    // Conviva Mobile Request
    // case '4848047a1b4adc10684eea4cbc4bcbda':
    // return '1. Procure device from vendor. \n' +
    // '2. Contact user, provide information from vendor with Tracking Number.';

    default:
    return "Review the request and provide the requested access.";
    }
    },

    getAssignGroup: function (item) {
    switch (item) {
    // Conviva Payer Portal
    case "Wireless Keyboard/Mouse":
    return "";

    // Conviva Collaboration
    case "Laptops - Standard":
    return "";

    // Conviva Software Request
    case "Desktops (Minis)":
    return "";

    // Conviva Virtual Visits
    case "Monitors":
    return "";

    default:
    return "";
    }
    },

    ServerRetirement: function (sysIDs, number) {
    var grCMDB = new GlideRecord("cmdb_ci");
    grCMDB.addEncodedQuery("sys_idIN" + sysIDs);
    grCMDB.query();
    while (grCMDB.next()) {
    grCMDB.comments = "Server is retired as per " + number;
    grCMDB.update();
    }
    },
    // Waldo code here :)
    StandardChangeServerRetirement: function (arrOfSysIDs, changeNumber) {
    var queryStr = "sys_idIN" + CIstoRetire;
    var grCMDB = new GlideRecord("cmdb_ci");
    grCMDB.addEncodedQuery(queryStr);
    var isValidQuery = grCMDB.isEncodedQueryValid(queryStr);

    // checking if the array if CIs to retire is not empty and that we have a change number
    if (
    arrOfSysIDs instanceof Array &&
    arrOfSysIDs.length > 0 &&
    changeNumber
    ) {
    if (isValidQuery) {
    grCMDB.query();
    while (grCMDB.next()) {
    // retire the CI
    grCMDB.operational_status = 6;
    // leave a comment on the CI
    grCMDB.comments = "Server is retired as per " + changeNumber;
    grCMDB.update();
    return true;
    }
    } else {
    // gs.log("No valid query");
    gs.addErrorMessage(
    "The system could not select the services to be retired. Please try again, or contact your ServiceNow support admin."
    );
    return false;
    }
    }
    },

    type: "Conviva_WorkflowUtils",
    });