When an Attachment is attached, How is the recently attached attachment displayed?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-07-2012 11:00 AM
Hey,
catalog_cart_attachment_list is the UI macro that is getting all the attached attachments into the Service Catalog form.
It is again broken down into attachment_list_body.xml and attachment_list UI macros respectively.
SNOW doesn't allow the access to these two UI macros, But if any one of you know how the Page is refreshing, i.e when I attach a new attachment, how is it getting displayed on the form( I mean the new attachment at the top of the form without a form re-load) is a mystery to me 😞
Please help me out on this!
Thanks!
- Labels:
-
Service Catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-27-2015 02:57 PM
Abhiram,
i stumbled upon this thread while looking to refresh attachments. Here's how to do it.
It's an undocumented API function
addAttachmentNameToForm(sysid, name, hoverText, image, showRename, showView, showPopup)
- sysid - is the sys_id of your image
- name- Filename
- hoverText - Mouse over of Image icon (see below)
- image - should be an icon looks like they use 'images/icons/attach_image.gifx'
- showRename - shows the rename link [true]
- showView - shows the view link [true]
- showPopup - pop's up [true]
addAttachmentNameToForm('4e9c53b36fc34500b3f5b50d5d3ee4df', 'SomeFileImage.png', 'added by admin', 'images/icons/attach_image.gifx', 'true', 'true', 'true')
Here's the full JS if you want to read it
https://yourinstance.service-now.com/scripts/functions_attachments.js
function addAttachmentNameToForm(sysid, name, hoverText, image, showRename, showView, showPopup) {
var modified = $("attachments_modified");
if (modified)
modified.value = "true";
showObjectInline($("header_attachment_list_label"));
var line = $("header_attachment_line");
if (line)
line.setStyle({visibility: 'visible', display: ''});
var span = $(cel('span'));
span.id = "attachment_" + sysid;
span.style.marginRight = "10px";
span.innerHTML = '<a href="sys_attachment.do?sys_id=' + sysid + '" title="' + hoverText + '" style="margin-right:4px;"><img src="' + image + '" alt="" /></a>';
var txt = $(cel('a'));
txt.innerHTML = name;
txt.href='#';
txt.onkeydown = function(event){return allowInPlaceEditModification(txt, event);};
txt.href='sys_attachment.do?sys_id=' + sysid;
txt.setAttribute('data-id', sysid);
txt.style.display = 'inline';
txt.inPlaceEdit({
selectOnStart: true,
turnClickEditingOff: true,
onAfterEdit: function(newName) {
var oldName = this.oldValue;
var ga = new GlideAjax('AttachmentAjax');
ga.addParam('sysparm_type', 'initialRename');
ga.addParam('sysparm_value', sysid);
ga.addParam('sysparm_name', newName);
ga.getXML(function(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
if (answer !== '0')
alert(new GwtMessage().getMessage("Renaming attachment {0} to new name {1} is not allowed", oldName, newName));
$$('a[data-id="' + sysid + '"]').each(function(elem){
elem.innerHTML = (answer === '0') ? newName : oldName;
});
});
}
});
txt.style.marginRight = "5px";
span.appendChild(txt);
if (showRename == 'true') {
var renameAttachment = $(cel('a'));
renameAttachment.className = 'attachment';
renameAttachment.onclick = function() {
txt.beginEdit();
};
renameAttachment.innerHTML = getMessage('[rename]');
span.appendChild(renameAttachment);
}
if (showView == "true") {
var blank = document.createTextNode(" ");
span.appendChild(blank);
var view = cel("a");
var newText = document.createTextNode(getMessage('[view]'));
view.appendChild(newText);
view.className = "attachment";
if (showPopup == "false")
view.href = "sys_attachment.do?sys_id=" + sysid + "&view=true";
else
view.onclick = function() {
tearOffAttachment(sysid)
};
span.appendChild(view);
span.appendChild(blank);
}
var storage = cel('li');
storage.className = 'attachment_list_items';
storage.appendChild(span);
var attachList = $("header_attachment_list");
if (attachList)
attachList.appendChild(storage);
var header_attachment = $('header_attachment');
if (header_attachment) {
_frameChanged();
}
var ga = new GlideAjax('AttachmentAjax');
ga.addParam('sysparm_type', 'attachmentParentSysId');
ga.addParam('sysparm_value', sysid);
ga.getXMLAnswer(changeCount, null, 'increase');
var more_attachments = $('more_attachments');
if (header_attachment && more_attachments)
if( (computeAttachmentWidth() - 20) >= (header_attachment.getWidth() - more_attachments.getWidth()))
more_attachments.style.display = 'block';
else
more_attachments.style.display = 'none';
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-07-2018 12:10 PM
Is this something new to Kingston or London? We just moved to London on the 3rd of this month, we were on Jakarta and this was not an issue.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-04-2019 02:01 AM
then he may select one option then value of that should go back and get set to one the field on task form and then form get submitted.
i am to get the file name of all the attachment he has selected but unable to create dialog window which list all the file name retrieved on submit.
can any one help to develop dialog window listing file name as option of select box as i am not that good in jelly