- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-02-2015 10:45 PM
Can we reload a form automatically right after attaching files? I wrote a business rule which count up attachments and show the number in the form. But we need to refresh the form to display the new number. So it should be reloaded automatically right after attaching files.
Thanks.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-03-2015 12:00 AM
Hi Koji, why don't you do this through a client script?
You can use the client function getCurrentAttachmentNumber(sys_id_of_your_record) to get the Attachment Number for your record.
This function just looks-up into the field which holds the attachmentNumber for that record. Here goes how internally ServiceNow has defined this function:
function getCurrentAttachmentNumber(sysid) {
if ($$('.attachmentNumber_' + sysid)[0] == undefined) {
if ($('header_attachment_list_label') == undefined)
return undefined;
else
return $('header_attachment_list_label').down().innerHTML;
}
Clarification: This function is already defined and available in your client code.
Thanks,
Berny
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-03-2015 12:14 AM
Hi Koji, your UI action need to be a client one. If that's the case, then you just need to call the function:
getCurrentAttachmentNumber('here_goes_the_sys_id_of_your_record');
Thanks,
Berny
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-03-2015 12:16 AM
You could also access the field directly on the following way:
var sys_id = 'here_goes_the_sys_id_of_your_record';
gel('attachmentNumber_' + sys_id).innerHTML;
Thanks,
Berny
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-03-2015 12:27 AM
Hi Berny, Thank you for your advice.
Should I make the function as a script include or UI script?
Thanks,
Koji
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-03-2015 12:39 AM
Hi Koji, the function getCurrentAttachmentNumber is already defined as part of the internal client functions of ServiceNow
Thanks,
Berny
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-03-2015 12:00 AM
Hi Koji, why don't you do this through a client script?
You can use the client function getCurrentAttachmentNumber(sys_id_of_your_record) to get the Attachment Number for your record.
This function just looks-up into the field which holds the attachmentNumber for that record. Here goes how internally ServiceNow has defined this function:
function getCurrentAttachmentNumber(sysid) {
if ($$('.attachmentNumber_' + sysid)[0] == undefined) {
if ($('header_attachment_list_label') == undefined)
return undefined;
else
return $('header_attachment_list_label').down().innerHTML;
}
Clarification: This function is already defined and available in your client code.
Thanks,
Berny