glide record not working in onsubmit client script.

uma7
Kilo Guru

find_real_file.pngThis code is giving the alert of if condition and stopping the submission even i am attaching a file.

whats wrong in my code?

1 ACCEPTED SOLUTION

Pooja Mallikarj
Kilo Sage

Hi,

It is not recommended to use GlideRecord in client scripts still if you want to achieve by client scripts then you can try with below code.

function onSubmit() {
//Type appropriate comment here, and begin script below

var cat_id = g_form.getValue('sysparm_item_guid');
var gr = new GlideRecord("sys_attachment");
gr.addQuery("table_name", "sc_cart_item");
gr.addQuery("table_sys_id", cat_id);
gr.query();
if (!gr.next()) {
alert("You must add an attachment before submitting this request.");
return false;
}
}

 

Thanks,

Pooja M

View solution in original post

11 REPLIES 11

What is the meaning of header_attachment_list_label.how can I get that?

Hi Uma,

You can directly paste the code it will you don't have to put any additional value.Its complete code.

Make sure that sure have made the isolate script field to false as mention in the above step.

For more information on the  header_attachment_list_label This is the id of the element which stores the attachment.

screesnshot:

find_real_file.png

 

 

 

 

Mark helpful and correct if it helps

Thanks,

CB