The Zurich release has arrived! Interested in new features and functionalities? Click here for more

Unable to add an signature as an attachment to Signature Image table .....

malidhananjay
Kilo Contributor

I have not used any OOTB Script to create an signed image as an attachment on Signature Image table.

I have created a UI Page to accept the name and Signature .(Signature is drawn on Signature Pad i.e in html Canvas),

wrote a script include to insert an record and add an attachment on Signature Image table with all data.

The Signature drawn was converted to base64 format ,and tryed created a record on   ecc queue table with base64 payload for the record inserted on Signature Image table.

the Issue i m Facing is, record is been created on ecc queue but attachment is not created can anyone help.....

below is the code i have written....

Script :-

insertSignature: function() {

          var sig = this.getParameter('sysparm_sig');           //signature

          var sigName = this.getParameter('sysparm_sigName');     //receiver name

          var table = this.getParameter('sysparm_table');           //table name

          var sysid = this.getParameter('sysparm_sysid');         //record id

                  var user = this.getParameter('sysparm_user');            

          var aTag = this.getParameter('sysparm_aTag');

var arr=sig.split('base64,');

          var sigRec = new GlideRecord('signature_image');

        // sigRec.signed_name = sig;

// sigRec.u_signature = sig;

  sigRec.u_receiver_name = sigName;

sigRec.signed_on=gs.now();

sigRec.user= gs.getUserID();

  sigRec.table = table;

  sigRec.document = sysid;

sigRec.is_drawing=true;

  var id=sigRec.insert();

}

**********************************************************************************************************************************************

below is the ecc queue record created....

find_real_file.png

I am Getting the Message Attachment Creation Failed ....

This is working fine on dev instance but not on client ...........

2 REPLIES 2

malidhananjay
Kilo Contributor

Code to insert on ecc queue



  var attCreator = new GlideRecord('ecc_queue');  


    attCreator.agent = "AttachmentCreator";  


    attCreator.topic = "AttachmentCreator";  


    attCreator.name =   id+":image/png";  


    attCreator.source = "signature_image:"+id;  


    attCreator.payload = arr[1].toString();  


    attCreator.insert();  


  Try using the below code instead of ecc queue



//add Attachment


var StringUtil = GlideStringUtil;


                    var value = StringUtil.base64DecodeAsBytes(arr[1].toString());


                          var attach=new Attachment();


        attach.write("signature_image",id,id+'.png',"image/png", value);          


       


//attach.write(tablename,rec sysid,filename,content type,value) ;