How to get the attachment sys id or any unique value for attachment related to the catalog

ramesh_r
Mega Sage

Hi All,

 

I have catalog item and it has Attachment type variable. 

 

once file selected in that filed i need to do some work based on the attached document, for that i need to access the attachment before submitting the catalog item..

 

The below script is work only in the native view to get unique value in the attachment table but its not working in the portal.

g_form.getValue('sysparm_item_guid');

 

Please help me how to do that.

 

ramesh_r_0-1666693910940.png

 

ramesh_r_1-1666693937097.png

 

 

 

 

 

1 ACCEPTED SOLUTION

Ahmmed Ali
Mega Sage

Hello @ramesh_r 

 

I assume you want to query attachment table the record with name "user list.xlsx". This you can do by querying sys_attachment table with sys_id of the attachment record. You can read sys_id of the attachment record using g_form.getValue("ATTACHMENT_TYPE_VARIABLE_NAME");

 

you can write script like:

var grAtt = new GlideRecord("sys_attachment");

grAtt.get("SYS_ID_GOT_FROM_ABOVE_SCRIPT");

 

The attachment type variable stores attachment record sys_id as value.

 

Thank you,

Ali

If I could help you with your Query then, please hit the Thumb Icon and mark my answer as Correct!!

Thank you,
Ali

View solution in original post

4 REPLIES 4

Sai Kumar B
Mega Sage
Mega Sage

@ramesh_r 

To get the Unique value of the catalog item you can use g_form.getUniqueValue(); for the service portal view

For more information - "sysparm_item_guid" does not work for Service Portal. Use g_form.getUniqueValue() instead. 

Hi Sai,

 

this g_form.getUniqueValue(); is not giving the same value as g_form.getValue('sysparm_item_guid') 

its just returning catalog sys id g_form.getUniqueValue();.

i am looking for thr out put what this one is retune

g_form.getValue('sysparm_item_guid')

 

Ahmmed Ali
Mega Sage

Hello @ramesh_r 

 

I assume you want to query attachment table the record with name "user list.xlsx". This you can do by querying sys_attachment table with sys_id of the attachment record. You can read sys_id of the attachment record using g_form.getValue("ATTACHMENT_TYPE_VARIABLE_NAME");

 

you can write script like:

var grAtt = new GlideRecord("sys_attachment");

grAtt.get("SYS_ID_GOT_FROM_ABOVE_SCRIPT");

 

The attachment type variable stores attachment record sys_id as value.

 

Thank you,

Ali

If I could help you with your Query then, please hit the Thumb Icon and mark my answer as Correct!!

Thank you,
Ali

ChandanKuma
Tera Contributor

Please update if you found any solution for this