insomniacc / PSSnow

A powershell module for interacting with the ServiceNow REST API
GNU General Public License v3.0
41 stars 9 forks source link

Adding an attachment to a new request cart item for checkout #64

Closed steveturnbull closed 1 day ago

steveturnbull commented 2 months ago

Hi

i've been doing some testing on the module and it's working for creating a request with new-snowsccartitem and checkout. This creates the RITM.

However i am trying to figure out how to attach a document to the request so that it will appear within the RITM.

I was looking at new-snowattachment and I can use this to added a file to the req but only once the req is already checked out and then its missing from the RITM.

Is there a way to attach a document/file to the REQ? If not could this be an enhancement?

Thanks!

insomniacc commented 1 month ago

Hey @steveturnbull , sorry for the late reply, life has been pretty busy lately. Just to clarify, the attachment needs to go on the RITM or REQ? I can take a look at this at the weekend and get this feature added if there isnt currently a way to do it.

steveturnbull commented 1 month ago

Hey, no problem :) totally understand.

So right now I can attach a document to an existing request but it won’t automatically show up in the ritm. This is because it’s submitted and I don’t know if it’s possible to attach a file to the request before submit

for example if I create a request manually in service now and add an attachment. I can then click submit, the request is created and the ritm includes the attachment that I attached in the request.

Hope that makes sense.

insomniacc commented 1 month ago

Yeah I get you! I'll play around with it, it could be some sort of reference that's being missed when it's attached currently but doesn't show up, so hopefully just a small fix.

insomniacc commented 1 month ago

Hey, no problem :) totally understand.

So right now I can attach a document to an existing request but it won’t automatically show up in the ritm. This is because it’s submitted and I don’t know if it’s possible to attach a file to the request before submit

for example if I create a request manually in service now and add an attachment. I can then click submit, the request is created and the ritm includes the attachment that I attached in the request.

Hope that makes sense.

@steveturnbull - Just looking at this now, I'm playing around manually first as its been a while since i used servicenow. If I open a new request via the service catalog, that has an associated RITM, I can add an attachment to either the REQ or the RITM, but cannot see that one will show up in the other natively, albeit this is after the catalog item has been submitted as there's no good out of the box examples for it in the default catalog.

For example, (and I'm doing all this with the web GUI not the module for now, just to understand how it behaves): I have RITM0010001 which is underneath REQ0010001. If I add an attachment to RITM0010001 it shows up at the top: image If I navigate to REQ0010001, I do not see the attachments from here.

Likewise, if I attach something to REQ0010001, then navigate to RITM0010001 again, the attachment only shows on the REQ, not the RITM.

This is the same behaviour I'm seeing through the web UI as it is using the module with the following commands:

New-SNOWAttachment -Sys_ID "0553e95683515210d4c3c710feaad3c0"  -File "<path to file>\attachment2.txt" -Sys_Class_Name "sc_request"
New-SNOWAttachment -Sys_ID "8953e95683515210d4c3c710feaad3c0"  -File "<path to file>\attachment1.txt" -Sys_Class_Name "sc_req_item"

I'm wondering right now, if the behavior you're seeing is how the catalog item has been configured and I'm wondering if the attachment provided through the cart item is being added to both REQ and RITM by that configuration? It's been a couple of years since I worked with Servicenow but from memory, at the last org I used it, I seem to remember that attachments would only go into the RITM and not the REQ in our instance.

It could also just be my understanding is off here and I may be missing something, but it's hard to picture or replicate without seeing your setup. If you could do a screen recording to show maybe the process in the GUI - how you log the request with attachment, and then where it shows, maybe with something like screen2gif, or I'm even happy to go as far as setup a call to chat about it if you wanted, let me know!

insomniacc commented 1 day ago

Closing this as I've had no reply, happy to continue looking into it if you think there's a problem but I need a way to understand and replicate the issue if there is one.