- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-15-2022 01:30 PM
Hi All,
We have a requirement to have an option to export a record as a word document.
I looked through various posts in the community but could not find anything.
Has anybody worked on similar requirement? or any idea on how this can be achieved?
Thanks in advance
Solved! Go to Solution.
- Labels:
-
Architect
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-27-2022 02:16 AM
Hi All,
I was able to achieve this with the below code.
I have used UI action on click of which word document will be created and attached the record
var variables = current.variables.getElements();
var variablesBody = '';
for (var j = 0; j < variables.length; j++) {
var question = variables[j].getQuestion();
variablesBody = variablesBody + '<tr><td style="background-color:#3388FF;color:white;">' + question.getLabel() + ':</td><td>' + question.getDisplayValue() + '</td></tr>';
}
var fieldProperty = gs.getProperty('changerequest.mop.fields');
var fields = fieldProperty.split(',');
var body = '';
for (var i = 0; i < fields.length; i++) {
var field = fields[i];
body = body + '<tr><td style="background-color:#3388FF;color:white;">' + current[field].getLabel() + ':</td><td>' + current[field].getDisplayValue() + '</td></tr>';
}
var html = '<html><table border = "1">' + body + variablesBody + '</table></html>';
var attachmentName = current.number.toString() + ".doc";
var gsa = new GlideSysAttachment();
var attachmentId = gsa.write(current, attachmentName, 'text/plain', html);
action.setRedirectURL(current);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-16-2022 02:16 AM
Hi,
I've never heard of anyone asking for a solution to export a record to Word before.
Would it be possible to use the built-in Export to PDF function, and then manually generate a Word document from the PDF using Acrobat?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-16-2022 05:58 AM
me either didn't heard that one even want's to have word from SN.
if you manage to do that, please share.
i would suggest on something that is semi-automated with TXT file export and so on...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-27-2022 02:16 AM
Hi All,
I was able to achieve this with the below code.
I have used UI action on click of which word document will be created and attached the record
var variables = current.variables.getElements();
var variablesBody = '';
for (var j = 0; j < variables.length; j++) {
var question = variables[j].getQuestion();
variablesBody = variablesBody + '<tr><td style="background-color:#3388FF;color:white;">' + question.getLabel() + ':</td><td>' + question.getDisplayValue() + '</td></tr>';
}
var fieldProperty = gs.getProperty('changerequest.mop.fields');
var fields = fieldProperty.split(',');
var body = '';
for (var i = 0; i < fields.length; i++) {
var field = fields[i];
body = body + '<tr><td style="background-color:#3388FF;color:white;">' + current[field].getLabel() + ':</td><td>' + current[field].getDisplayValue() + '</td></tr>';
}
var html = '<html><table border = "1">' + body + variablesBody + '</table></html>';
var attachmentName = current.number.toString() + ".doc";
var gsa = new GlideSysAttachment();
var attachmentId = gsa.write(current, attachmentName, 'text/plain', html);
action.setRedirectURL(current);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-27-2022 02:22 AM
ok, so you actually creating TXT document with HTML markup.
well, if that works 😉