g_form.getSysId() and g_form.getUniqueValue returning -1

cljordan
Tera Expert

I need to check if a record has an attachment onSubmit in ServicePortal with the out-of-box form widget.  When using g_form.getSysId in a client script, it is returning -1.  g_form.getUniqueValue() returns -1 as well.

g_form.getUniqueValue() works in CMS.  

 

My GlideAjax seems to be working.  I'm just having trouble getting the sys_id for the record to send as a parameter.  

Any advice will be much appreciated.  

Thanks,

Chris

1 ACCEPTED SOLUTION

Ashutosh Munot1
Kilo Patron
Kilo Patron

HI,

 

Below code will work for you:

if ((this.document.getElementsByClassName('get-attachment').length == 0)) {
alert('Please attach the requested laptop desktop template before submitting.');
return false;
}

 

Thanks,
Ashutosh Munot

View solution in original post

5 REPLIES 5

SanjivMeher
Kilo Patron
Kilo Patron

Can you check, when you attach the record, if you see a record in sys_attachment table and what is the table sys id?

Also how are you creating record in service portal?


Please mark this response as correct or helpful if it assisted you with your question.

Yes, when I add an attachment it creates a record in sys_attachment, has the correct table and has an entry for the record sys_id.  If I submit the record the sys_ids match (the one for the submitted record and the sys_attachment entry).  

The record is created on a custom page with the OOB form widget.  It's accessed by URL with sys_id=-1 to submit a new record.  

I am not sure if you can get the sys_id.

Another option you can try is using current.hasAttachments() in a business rule. And if it returns false, do a current.setAbortAction(true);


Please mark this response as correct or helpful if it assisted you with your question.

Ashutosh Munot1
Kilo Patron
Kilo Patron

HI,

 

Below code will work for you:

if ((this.document.getElementsByClassName('get-attachment').length == 0)) {
alert('Please attach the requested laptop desktop template before submitting.');
return false;
}

 

Thanks,
Ashutosh Munot