is there and equivalent of "g_form.getElement('sysparm_item_guid').value" in the portal ?

poyntzj
Kilo Sage

Looking to revise one of my old Client Scripts which depends on checking a record while the user is in a catalog item

In the old CMS I would use  g_form.getElement('sysparm_item_guid').value which obviously fails in the Portal, but wondered if there is an equivalent I can use

I can see the Catalog Item is already assigned a new sys_id in the instance, but I cannot find how to access this Id from the portal.

 

Any ideas ?

 

TIA

24 REPLIES 24

@poyntzj 

If you wish to have mandatory attachment check; please refer my blog and enhance

It works well in Native + Portal

Verify Mandatory Attachments Count on Catalog Item

If my blog helps please mark it helpful and also bookmark it

Regards
Ankur

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

Hi Ankur

I have variations on the count and name check, but it is the content type that now needs to be addressed.

 

@poyntzj 

so the file attachment extension is to be validated?

 

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

No, validation of extention (which I do via a regex) is not enough for the current client.

Most examples use the indexOf - so if I check for an xls extension, in most examples the following will match

a.file.xls.is.not.a.true.excel.file.txt

whereas, using a regex and the $ anchor ensures the file name has to end with xls

However, for the current client I need to validate the content type is what it says it is.

My CMS code does this, but I cannot get the sys_id to then go and look at the sys_attachment table

I have just looked through a PDI

The sys_id of the catalog item is "596fec022ffcf0103c345fd62799b635"

In the sys_attachment table I have 

find_real_file.png

 

I cannot find the sys_id 9ff51bca2fe9bc503c345fd62799b610 anywhere in the instance - the sc_cart_item table is empty

I cannot see The sys_id of the catalog item is 596fec022ffcf0103c345fd62799b635 in the form either

Hi,

okay you are using old CMS and not the portal

Regards
Ankur

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