Not getting sys id of the attachment when using g_form.getValue

EKTA2
Tera Expert

Hi. I need to grab the sys id of the submitted Attachment variable so that I can push the same image ( submitted by the user) to sc_cat item table. 

 

I am not getting the sys_id of the attachment variable. It is coming blank when I am using getValue method. pls suggest. 

17 REPLIES 17

@EKTA  Right, we need to create two attachments one each for Icon and Picture.

So we can achieve this even without creating attachments by referring the sys_id of attachment that user attached in submitting the record. But the risk is if someone accidentally delete the attachment from that record then the catalog item also looses the attachment.

SO I went for the approach of creating attachments. If you feel the script is running slow then you can make the BR as async to run it in background.

 

And the approach that I referenced without GlideRecord is very simple that you need to set the value of icon and attachment with the sys_id value of icon and picture variables of user submitted record.

 

To your question on not getting variable values....what is the exact code you used to  retrieve the icon, picture variable values?

@Vamsi Sreenivas 

 

I used..... current.variables.getValue("attachment variable). It doesnt work.. but I can query using Table_Sys_id.

 

Anyways, I found another way to do it, so I should be good now.

 

 

@EKTA , glad that you have found a solution. Please add your solution here and mark your response as correct so will help users with similar issue.

 

Regards,

Vamsi S

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

Are you planning to do this once RITM is submitted?

You can use workflow run script and it should be an easy task

Can you share what script did you start with?

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hi Ankur, 

 

I am trying to do this via Business rule and trying it as Vamsi suggested above. But his script has way too many Gliderecords so I am seeing how to achive this. 

 

Also, His script is inserting record into sys_attachment which I dont want ( that will happen automatically). All I want is to insert picture into appropriate catalog Item