Comments on: Create an Attachment UI Action https://servicenowguru.com/ui-actions-system-ui/create-attachment-ui-action/ ServiceNow Consulting Scripting Administration Development Thu, 07 Mar 2024 15:24:05 +0000 hourly 1 https://wordpress.org/?v=6.8.2 By: Wayne https://servicenowguru.com/ui-actions-system-ui/create-attachment-ui-action/#comment-8943 Mon, 08 Dec 2014 17:29:49 +0000 https://servicenowguru.wpengine.com/?p=4035#comment-8943 Hi. I achieved this by creating a UI Page like this:

HTML:

<a>
   <b>Attach files</b>
</a>

You can change the ‘sc_cart_item’ to be any table but be sure create a new UI Page for each one.
I found this method to be great because you can make the image and text as big as you like.

]]>
By: moniika https://servicenowguru.com/ui-actions-system-ui/create-attachment-ui-action/#comment-8942 Thu, 21 Mar 2013 15:41:58 +0000 https://servicenowguru.wpengine.com/?p=4035#comment-8942 Christian,
I am trying to do exactly what you mentioned above. No success .I am missing some piece i was able to put a button on the item.Its not saving the atttachment once you submit the request .can you please share your code.

Thanks
Monika

]]>
By: Lesley Mills https://servicenowguru.com/ui-actions-system-ui/create-attachment-ui-action/#comment-8941 Tue, 29 Jan 2013 23:17:34 +0000 https://servicenowguru.wpengine.com/?p=4035#comment-8941 My query relates to attachments, hence adding it to this thread.
We’ve noticed that in our Berlin upgrade we now have a dropdown list of attachments as well as attachments showing across the top of the banner frame. My issue is that before the upgrade we could have a large number of attachments showing in the banner but now we’re limited to a maximum of 6. I can’t see any documentation on this new feature in ServiceNow Community and also can’t find any documentation on configurations that can be made to this. Eg I’m keen to remove all these banner attachments and have them only show in the dropdown rather than have a limited number appear.

]]>
By: Jason Stephens https://servicenowguru.com/ui-actions-system-ui/create-attachment-ui-action/#comment-8940 Tue, 29 Nov 2011 16:13:02 +0000 https://servicenowguru.wpengine.com/?p=4035#comment-8940 In reply to Christian Tuebing.

Do you care to share your code as to how you modified the ui macro to add the “Attachment” button to the item. This is exactly what I need to do.

Thank you for the help!

Jason

]]>
By: Jim https://servicenowguru.com/ui-actions-system-ui/create-attachment-ui-action/#comment-8939 Thu, 10 Nov 2011 04:08:12 +0000 https://servicenowguru.wpengine.com/?p=4035#comment-8939 In reply to Mark Stanger.

I should have guessed that you’d have addressed that issue already ;-)

]]>
By: Christian Tuebing https://servicenowguru.com/ui-actions-system-ui/create-attachment-ui-action/#comment-8938 Wed, 05 Oct 2011 12:30:49 +0000 https://servicenowguru.wpengine.com/?p=4035#comment-8938 Hi Chris, just to update: I ttok the Jelly route and it works well. The scripting approach just doesn’t feel robust enough to me. I know the downsides. Thanks for the good input. CT :-)

]]>
By: Christian Tuebing https://servicenowguru.com/ui-actions-system-ui/create-attachment-ui-action/#comment-8937 Mon, 03 Oct 2011 05:38:19 +0000 https://servicenowguru.wpengine.com/?p=4035#comment-8937 Hi Chris,
thanks for sharing. I was talking about individual items, not the checkout. But I will go ahead today and try if any of thise works for this. I’ll keep things posted here.

CT :)

]]>
By: Chris Terzian https://servicenowguru.com/ui-actions-system-ui/create-attachment-ui-action/#comment-8936 Wed, 28 Sep 2011 19:52:46 +0000 https://servicenowguru.wpengine.com/?p=4035#comment-8936 In reply to Christian Tuebing.

Hi Christian – I’ve done things on the checkout screen a couple of ways. One is to modify the associated ui_macro, the other is to create a ui_script that essentially does a getElementById on some existing element, then insert a new element in there, i.e. an attachment icon image and set the onClick action to whatever… saveCatAttachment() in this case. The trick with the former approach is dealing with Jelly and modifying an out of the box file, whereas the trick with the latter approach is finding an element you can reference by ID. In some cases, I had to iterate through elements when the page loads, find the 5th for example and set the ID of that element so I could then do a getElementById on it and manipulate it. The jelly approach is cleaner, but would prevent this macro from being updated by Service Now in the future, so in that sense, the UI Script is less intrusive but will be a bit slower so you need to be careful when writing your scripts to iterate through the page elements.

In the example below, I used Firebug or equivalent to look at the elements and find which one I needed to modify – in this case a table, finds the 2nd table, adds an ID tag to it, then using that ID I set display to none to hide it. For what you’re trying to do, rather than hiding, you could insert a new element for the attachment button and have it call the attachment function you need.

function hideCheckoutFields(){
  //adds an ID to the checkout details table, then sets to hidden
  //we could possibly add some arguments to hide only certain fields here
  var tables = document.getElementsByTagName('table');
  var count = 0;
  var tableArr = [];

  for(var i=0;i!=tables.length;i++){
    if(tables.item(i).getAttribute('className') == 'wide' || tables.item(i).getAttribute('class') == 'wide' ){
      count++;
      if(count==2){
        tables.item(i).setAttribute('id','checkoutDetails');
      }
    }
  }
  gel('checkoutDetails').style.display = 'none';
}

Chris

]]>
By: Christian Tuebing https://servicenowguru.com/ui-actions-system-ui/create-attachment-ui-action/#comment-8935 Wed, 28 Sep 2011 08:29:48 +0000 https://servicenowguru.wpengine.com/?p=4035#comment-8935 Hi Mark, how would you do this for a catalog item? The paper clip is on the top right of the item form when the ESS users orders it. However that is not very prominent at all. The link points to: saveCatAttachment(gel(‘sysparm_item_guid’).value, ‘sc_cart_item’). But I can not get a UI action up there, right? I notices that in the checkout screen under “sepcial instructions” there is a nice text next to this item but I do not know how to utilize that to make the item form look similar… Any idea?

]]>
By: Mark Stanger https://servicenowguru.com/ui-actions-system-ui/create-attachment-ui-action/#comment-8934 Mon, 19 Sep 2011 21:36:54 +0000 https://servicenowguru.wpengine.com/?p=4035#comment-8934 In reply to Jim.

Great point. That’s definitely something to keep in mind whenever you’re working with any system image. The real challenge is finding an image that’s 16×16 pixels that you can actually see :). Here’s a post I wrote on the method you described.

]]>