how to convert base64encode into number like cid:1451791534740 through business rule script

saurabhkr2812
Tera Contributor

Hi Team,

how to convert base64encode into number like cid:1451791534740 through business rule script in servicenow. i have done some script for that.

var gr = new GlideRecord('incident');
gr.query();
if(gr.next()){
var base64EncodedString='GVzdGluZyBhdHRjaG1lbnQ=';
var decodeString=GlideStringUtil.base64Decode(base64EncodedString);


var decodeNumber=parseInt(decodeString,10);


gr.short_description="cid:"+decodeNumber;
gs.log("attachment:"+gr.short_description);
}

i am not getting exact output.if anyone know pls let us know.

 

1 REPLY 1

Dnyaneshwaree
Mega Sage

Hello @saurabhkr2812 ,

 

Please refer below articles:
https://www.servicenow.com/community/developer-forum/decoding-base64/m-p/2006290
https://www.servicenow.com/community/developer-forum/decode-base64-field-and-add-to-record-as-attach...
https://www.servicenow.com/community/developer-forum/decoding-base64-encoded-file-and-writing-it-to-...

If my solution helps you any way then mark it as accepted and helpful.

Thank You!!

Please accept my solution if it works for you and thumps up to mark it as helpful.
Thank you!!

Dnyaneshwaree Satpute
Tera Guru