ESC Portal Widget for custom action / button

JuliaHowells
Tera Expert

Hi all, I am attempting to create a custom button on the portal that will create a child incident to a Major Incident when used. 

Currently, when I click the button nothing happens. I can see that it clicks, and I can log to the console and see that it logs my statements when I use them.

 

Any thoughts to get me closer? 

 

ID: create_child_incident

HTML: 

 

 

<button type="button" class="btn btn-primary btn-block" ng-click="sysverb_child_new()">Add me to this issue</button>

 

 

Client Script:

 

 

function() {
    var c = this;
    c.uiAction = function(action) {
        c.data.action = action;
        c.server.update().then(function() {
            spUtil.addInfoMessage("A Child Incident has been created", 3000);

            c.data.action = undefined;
        })
    }
}

 

 

Server Script:  

 

 

(function() {

    // Get table & sys_id
    data.table = input.table || $sp.getParameter("table");
    data.sys_id = input.sys_id || $sp.getParameter("sys_id");

    // Valid GlideRecord
    var gr = new GlideRecord(data.table);
    if (!gr.isValid())
        return;

    // Valid sys_id
    if (!gr.get(data.sys_id))
        return;
    //input
    if (input && input.action == 'sysverb_child_new') {

        // If Incident table
        if (data.table == 'incident') {

            var jr = new GlideRecord('incident');
            jr.get(data.sys_id);
            jr.setValue('incident_state', 'Assigned');
            jr.setValue('state', 'Assigned');
            jr.setValue('assigned_to', '');
            jr.setValue('caller_id', gs.getUserID());
            jr.update();
        }
    }
})();

 

 

 

0 REPLIES 0