Error during migrating Attachments
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-15-2022 07:33 PM
I am trying to migrate attachments from one instance to another and using the modified script got from community.
I'm getting the following Errors .
Access denied to crypto module
Crypto module access is denied for an attachment: no thrown error
Crypto module access is denied for an attachment: com.glide.kmf.CryptoModuleAccessDeniedException: Crypto module access is denied for an attachment: com.glide.kmf.CryptoModuleCipher.getCipher(CryptoModuleCipher.java:111)
Can I deactivate crypto module temporarily during the migration.
var targetInstanceURL = "https://XXXXXX.service-now.com/";
var targetUserID = "test_load_2";
var targetUserPassword = "test_load_2";
var answer = "";
var attachmentMsg = "";
var attachmentCount = sendAttachments("u_new_request", "17db86acdbb6cd1073563533f39619bb", "17db86acdbb6cd1073563533f39619bb");
gs.info('KPK1----attachmentCount-----'+attachmentCount);
if (attachmentCount != "none") {
attachmentMsg = " Attachments successfully sent: " + attachmentCount[0].toString() + ". Attachments failed to be sent: " + attachmentCount[1].toString();
} else {
attachmentMsg = " Record had no attachments to send.";
}
gs.info('KPK1----attachmentMsg-----'+attachmentMsg);
function sendAttachments(sourceTable, sourceID, targetID) {
var answer = [0, 0]; //successful attachments, failed attachments
// Query for any attachments on the current record.
var attachmentRec = new GlideRecord("sys_attachment");
attachmentRec.addQuery("table_sys_id", sourceID);
attachmentRec.addQuery("table_name", sourceTable);
attachmentRec.query();
if (attachmentRec.hasNext()) {
gs.info('KPK1----ATTACHMENT___FOUND');
while (attachmentRec.next()) {
var attachmentMessage = new sn_ws.RESTMessageV2();
attachmentMessage.setHttpMethod("post");
attachmentMessage.setBasicAuth(targetUserID, targetUserPassword);
attachmentMessage.setEndpoint(targetInstanceURL + "api/now/attachment/file");
attachmentMessage.setQueryParameter("table_name", attachmentRec.table_name);
attachmentMessage.setQueryParameter("table_sys_id", targetID);
attachmentMessage.setQueryParameter("file_name", attachmentRec.file_name);
attachmentMessage.setRequestHeader("Content-Type", attachmentRec.content_type);
attachmentMessage.setRequestHeader("Accept", "application/json");
attachmentMessage.setRequestBodyFromAttachment(attachmentRec.sys_id);
var response = attachmentMessage.execute();
var responseBody = response.getBody();
var httpStatus = response.getStatusCode();
gs.info('KPK1----httpStatus-----'+httpStatus);
if (httpStatus.toString() == "201") {
answer[0] += 1;
} else {
answer[1] += 1;
}
}
} else {
answer = "none";
}
gs.info('KPK1----answer-----'+answer);
return answer;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-16-2022 07:21 AM
Hi @pardhiv ,
I think all the records on which attachments are present should be present in your destination instance.
If you can activate plugins try to use IDR:
Regards,
Reshma
**Please mark my answer correct or helpful based on the impact**
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-25-2024 10:59 PM
Did we get any solution for this problem.. I am also facing same issue while transfer encrypted document from one system to another.