whatnowmax / make_jira_button_in_crm

// ==UserScript==
// @name make_jira_button_in_crm
// @description crm make jira
// @version 1.2
// @author whatnowmax
// @license MIT
// @match https://crm.stagrp.com/index.php?action=DetailView&module=Cases&record=*
// @match https://crm.stagrp.com/index.php?module=Cases*

// @run-at document-end
// @grant none
// ==/UserScript==


(function() {
    'use strict';

    //CRM half of this script that makes the JIRA URL full of useful gunk
    var _caseNum = document.getElementById("case_number").innerText;
    var _caseSubject = document.getElementById("name").innerText;
    var _custName = document.getElementById("account_id").innerText;
    var _downloadLink = document.getElementById("tidal_download_link_c").innerText;
    //problem description not used at the moment, but,
    //var _probDesc = document.getElementById("description").innerText;
    //var _buildVer = document.getElementById("dtbc_build").value;
    //var _ver = document.getElementById("tidal_version_c").value;
    //var _component = document.getElementById("tidal_module_c").value;

    //The bad way to get everything that'll change every CRM update
    var bad_ver = document.getElementsByClassName("col-xs-12 col-sm-8 detail-view-field inlineEdit")[11].innerText;
    var bad_buildVer = document.getElementsByClassName("col-xs-12 col-sm-8 detail-view-field inlineEdit")[13].innerText;
    var bad_component = document.getElementsByClassName("col-xs-12 col-sm-8 detail-view-field inlineEdit")[12].innerText;
    var bad_adapter = document.getElementsByClassName("col-xs-12 col-sm-8 detail-view-field inlineEdit")[14].innerText;
    var bad_platform = document.getElementsByClassName("col-xs-12 col-sm-8 detail-view-field inlineEdit")[17].innerText;



    var _btnJIRA = document.createElement("a");
    _btnJIRA.target = "_blank";
    _btnJIRA.href = "https://tidalautomation.atlassian.net/secure/BrowseProjects.jspa?"
    + _caseNum + ";"
    + _caseSubject + ";"
    + _custName + ";"
    + _downloadLink + ";"
    + bad_buildVer + ";"
    + bad_ver + ";"
    + bad_component + ";"
    + bad_adapter + ";"
    + bad_platform + ";" ;


    _btnJIRA.innerText = "(make JIRA)";
    document.getElementById("case_number").appendChild(_btnJIRA);

})();