- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-25-2014 04:46 AM
Hi,
I have a 'script include' which creates a .docx file as an attachment. I can execute that script as I am an admin ( I can create attachment through script). However, When I try this through 'non-admin' user, its not working at all !
Do I need to make any changes in Roles ? I can not assign admin role to that user.
I tried to create a new role to 'sys_attachment' . I want to make user 'able to create attachment'.
What could be the possible ways to achieve that ?
Thanks
Abhijeet
Solved! Go to Solution.
- Labels:
-
Enterprise Release Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-25-2014 05:46 AM
using below script include :
var CreateAttachmentDocwithParam = Class.create();
CreateAttachmentDocwithParam.prototype = Object.extendsObject(AbstractAjaxProcessor,{
_initialize: function() {
},
addAttachment: function () {
// var task = new GlideRecord('incident');
// task.setLimit(1);
// task.query();
// task.next(); //Here is a random task record
var result = this.newItem("result");
var rec = new GlideRecord('incident');
rec.initialize();
rec.short_description = 'Test Creation of Onbording candidate attachment cotract';
rec.caller_id.setDisplayValue('Abhijeet Yadav');
var a = GlideSysAttachment();
var Pssn = this.getParameter('sysparm_ssn');
var text = this.getParameter('sysparm_text');
var formType = this.getParameter('sysparm_formType');
var gdt = new GlideDateTime();
// gs.log(gdt.getValue());
var fileName = formType + gdt.getValue() +'.docx' ;
//gs.log(text);
rec.insert();
result.setAttribute("message", rec.number );
gs.log(rec.number);
a.write(rec, fileName, "application/vnd.openxmlformats-officedoc", text );
},
type: 'CreateAttachmentDocwithParam'
});
=============================================
Calling it on button click from UI page. below is the code :
function createDoc()
{
var ga = new GlideAjax('CreateAttachmentDocwithParam');
ga.addParam('sysparm_name', 'addAttachment');
var name = ${jvar_candidateName};
alert (name);
ga.addParam('sysparm_ssn', 'sample SSN 101010');
element = document.getElementById('contract');
var text = element.textContent || element.innerText;
ga.addParam('sysparm_text', text);
ga.addParam('sysparm_formType', '1099_');
ga.getXML(parseAnswer);
//element = document.getElementById('contract');
//var text = element.textContent || element.innerText;
}
function parseAnswer(response) {
// var answer = response.responseXML.documentElement.getAttribute("incNo");
// alert ('Document is attached to incident : ' + answer );
var result = response.responseXML.getElementsByTagName("result");
var message = result[0].getAttribute("message");
alert('Document is attached to incident : ' +message);
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-25-2014 06:54 AM
Hi Abhijeet,
Thanks for the update.
I have checked with your script and it was working fine for "ITIL" users.
I am sure there should be an issue with ACL on your instance.
Thanks
Pradeep Sharma
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-28-2014 02:46 AM
It was instance issue. It was not working that day.. surprisingly, it started working now ! ( its a good surprise though )
Thanks,
Abhijeet
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-25-2014 05:20 AM
How do you call that script include while being logged in as a non-admin user? Can that user add an attachment manually via the UI?
Blog: https://sys.properties | Telegram: https://t.me/sys_properties | LinkedIn: https://www.linkedin.com/in/slava-savitsky/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-25-2014 05:42 AM
I made a script 'Client callable'. I have created a 'UI page' and a button on that. On that button click, I am creating attachment by using script.
When I run that UI page by using 'Try It ' , its creating a new incident and attachment with that. However, when intended user views that page, that button click is not doing anything !
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-28-2014 02:53 AM
I was trying for a whole day and it was not working.. after couple of days.. its working absolutely fine without any change ! its a good surprise though..