Auto fetch assignment group from native incident record to UI page glidemodel wildow?

Shantharao
Kilo Sage

Hi All,
We got a requirement to create a glidemodel window with below three fields
=> Assignment group
=>Work notes
=>Category with default choices

If I click the UI action it will auto fetch the assignment group from native incident record to the glide model window, if the group is not empty

Please share the UI Action and UI page (HTML/Client script/Server processing script) to make it works

Thanks

1 REPLY 1

tejarekanda
Tera Expert

Hi @Shantharao ,
UI Page(name : assign_worknotes_modal):
HTML:

<g:ui_form>
    <table style="width:100%">
        <tr>
            <td><b>Assigned To:</b></td>
            <td>
                <!-- Reference field -->
                <g:ui_reference name="assigned_to" table="sys_user"/>
            </td>
        </tr>

        <tr>
            <td><b>Work Notes:</b></td>
            <td>
                <textarea id="work_notes" rows="5" style="width:100%"></textarea>
            </td>
        </tr>

        <tr>
            <td colspan="2" style="text-align:right;padding-top:10px;">
                <button type="button" class="btn btn-primary" onclick="submitData()">Submit</button>
                <button type="button" class="btn btn-default" onclick="closeModal()">Cancel</button>
            </td>
        </tr>
    </table>
</g:ui_form>

 Client Script:

onLoad();
function onLoad() {
    var dialog = GlideDialogWindow.get();
	

    var assignedToSysId = dialog.getPreference('assigned_to_sysid');
    var assignedToDisplay = dialog.getPreference('assigned_to_display');
	alert(assignedToSysId);

    if (assignedToSysId) {
        gel('assigned_to').value = assignedToSysId;
        gel('sys_display.assigned_to').value = assignedToDisplay;
    }
}

function submitData() {
    var assignedToSysId = gel('assigned_to').value;
    var assignedToDisplay = gel('sys_display.assigned_to').value;
    var workNotes = gel('work_notes').value;

    if (!assignedToSysId) {
        alert("Please select Assigned To");
        return;
    }

    if (!workNotes) {
        alert("Please enter Work Notes");
        return;
    }

    var dialog = GlideDialogWindow.get();

    var callback = dialog.getPreference('onSubmit');
    if (callback) {
        callback(assignedToSysId, assignedToDisplay, workNotes);
    }

    dialog.destroy();
}

function closeModal() {
    GlideDialogWindow.get().destroy();
}

UI Action:

function openModal() {
    var dialog = new GlideModal('assign_worknotes_modal');
    dialog.setTitle('Assign and Add Work Notes');

    // Get current form values
    var assignedToSysId = g_form.getValue('assigned_to');
    var assignedToDisplay = g_form.getDisplayValue('assigned_to');
	alert(assignedToSysId);

    //Pass to UI Page
    dialog.setPreference('assigned_to_sysid', assignedToSysId);
    dialog.setPreference('assigned_to_display', assignedToDisplay);

    dialog.setPreference('onSubmit', function(sysId, displayValue, workNotes) {
        g_form.setValue('assigned_to', sysId, displayValue);
        g_form.setValue('work_notes', workNotes);
    });

    dialog.render();
}

 

If my response helped, mark it as helpful and accept the solution.

 Regards.