Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Create an attachment in a Catalog Item Before Submiting it

User327722
Tera Contributor

I´m creating a new catalog item that will have an html field that must show, before submitting the item, a picture.

These picture will be captured by an external integration where I will receive an Base64 content and needs to generate the attachment that will be displayed in the html field mentioned earlier.

It this requirement possible?

 

 

1 REPLY 1

Paul Kunze
Tera Guru

Yes this is possible. I would suggest an onSubmit Client Script which reads your picture payload and prevents a submit if the picture is not available/ valid.

You will have a variable or a table entry of some sort which holds your Base64 image payload. You can either check this on the client side using g_form.getValue() or on the server side using GlideAjax (note: must not be asynchronous).

 

function onSubmit() {
    var picturePayload = '<Your Base64 content>';
    if (!picturePayload) {
        alert('There was an internal error, you cannot submit at this time, sorry.');
        return false;
    }
}