Cireson Portal
Dear All,
I would like to disable the viewing of attachments section at the top of a ticket for certain technicians, the paper clip. Do you have any code for this?
Thanks
Daniel
Best Answer
-
Konstantin_Slavin-Bo Customer Ninja IT Monkey ✭✭✭✭
Ah yes, I see. There's a timing issue, even though the code only runs after the form is bound, but apparently before the button is initialized (probably a race conditions between the two instruction on the call stack).
Usually this community solves this by watching the DOM for the element (mutation observer), but in this case I find it easier to simply add a ruleset to the style-tag, ensuring the element will be hidden, no matter when it's initialized from the stack:
app.custom.formTasks.add('Incident', null, function (formObj, viewModel) { formObj.boundReady(function () { // Hide attachment btn for usernames in the list let disableAttachementsFor = ['User1','User2']; if(disableAttachementsFor.includes(session.user.UserName)) { $('<style>').text("#headerAttachmentBtn{display:none}").appendTo(document.head); } }); return; });
Tested and works on 10.1.1
6
Answers
Something like this should do it:
I tried the above code but it didn't work.
Thanks
Daniel
@CaterhamITSupport
Just put the line in the code you use for hidden the other buttons
Hm, try wrapping the hide in a 0-timeout, maybe the timing is a little off:
setTimeout( function(){ $('#headerAttachmentBtn').hide(); }, 0);
Dear Mikkel,
I tried:
But it didn't seem to work? I maybe doing something wrong?
Daniel
Ah yes, I see. There's a timing issue, even though the code only runs after the form is bound, but apparently before the button is initialized (probably a race conditions between the two instruction on the call stack).
Usually this community solves this by watching the DOM for the element (mutation observer), but in this case I find it easier to simply add a ruleset to the style-tag, ensuring the element will be hidden, no matter when it's initialized from the stack:
Tested and works on 10.1.1
That worked really well.
Thank you.
Daniel