Custom UI Page for attachment & details

SN_Learn
Kilo Patron
Kilo Patron

Hi All,

 

I am following the article posted by @Deepak Negi in which we can attach the attachment and then override the approval but it is not working and throwing an error in the console:
Link to the article: Attachment Transfer: Moving Files from HTML Input to ServiceNow Records 

When the 'override approval is clicked in the popup the error comes up in the console as attached.
Could you please suggest what is going wrong? Thanks.

 

----------------------------------------------------------------
Mark this as Helpful / Accept the Solution if this helps.
6 REPLIES 6

Ankur Bawiskar
Tera Patron
Tera Patron

@SN_Learn 

what debugging have you done so far?

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hi Ankur, Thanks for the response.

 

I have tried the 'Override Arroval' button and 'Cancel' button in the pop which throws the below error onClick:

Uncaught TypeError: gdw.getPreference is not a function
Uncaught TypeError: gdw.destroy is not a function

 

These are defined in the UI page's Client Script and I couldn't find any wrong declarartion in the below:

function invokePromptCallBack(type) {
    var file = document.getElementById('attFile');
    if (type == 'ok' && (file.files.length == 0 || !gel('work_note').value)) {
        alert('Please provide both Attachment and Work Notes');
        return;
    }
    var gdw = new GlideDialogWindow.get();
    if (type == 'ok') {
        var f = gdw.getPreference('onPromptComplete');
        if (typeof(f) == 'function') {
            try {
                f.call(gdw, file, gel('work_note').value);
            } catch (e) {}
        }
    }
    gdw.destroy();
    return false;
}
----------------------------------------------------------------
Mark this as Helpful / Accept the Solution if this helps.

Hi @Ankur Bawiskar @Deepak Negi 

 

I have tried to debug by using an alert in the 'UI Action' and 'UI Page' and the typeof of 'f' is coming up as undefined.
var f = gdw.getPreference('onPromptComplete');

var gdw = new GlideDialogWindow.get();
    if (type == 'ok') {
        var f = gdw.getPreference('onPromptComplete');
        if (typeof(f) == 'function') {
            try {
                f.call(gdw, file, gel('work_note').value);
            } catch (e) {}
        }
    }

 

I believe in the 'UI Action' the function is not getting returned correctly for attFile abd work_notes.

dialog.setPreference("onPromptComplete", function(attFile, work_note)

 

Could you please assist in resolving the issue? Thanks 

----------------------------------------------------------------
Mark this as Helpful / Accept the Solution if this helps.

Deepak Negi
Mega Sage
Mega Sage

Try deleting the UI page and create again