Unable to create a Consumer record in csm_consumer table.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-17-2024 07:34 PM
Hi All,
I am trying to create a consumer record in csm_consumer table but unable to do so as I am encountering following error while submitting the record. Anyone knows how to fix this?
***********************************************************************************************************
onSubmit script error: TypeError: Cannot read properties of null (reading 'getElementsByTagName'):
function onSubmit() {
var types =[];
$$(".location_types_class").each(function(el){
if (el.checked){
types.push(el.value);
}
});
var gr = new GlideRecord('cmn_location');
gr.addQuery('consumer',g_form.getUniqueValue());
gr.addQuery('primary','true');
gr.query();
if(gr.next()){
gr.setValue('type',types);
gr.update();
}else{
var changed = g_form.getValue('street') || g_form.getValue('city') || g_form.getValue('state') || g_form.getValue('zip') || g_form.getValue('country');
if(changed){
gr.initialize();
var name = g_form.getValue('street');
if (g_form.getValue('city'))
name += "," + g_form.getValue('city');
if (g_form.getValue('state'))
name += "," + g_form.getValue('state');
gr.setValue('name',name);
gr.setValue('primary','true');
gr.setValue('street',g_form.getValue('street'));
gr.setValue('city',g_form.getValue('city'));
gr.setValue('state',g_form.getValue('state'));
gr.setValue('zip',g_form.getValue('zip'));
gr.setValue('country',g_form.getValue('country'));
gr.setValue('consumer',g_form.getUniqueValue());
gr.setValue('type',types);
gr.insert();
}
}
}
***********************************************************************************************************
Any help is appreciated.
Thanks & Regards,
Gulzar Manuja
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-17-2024 08:44 PM
Hi @Community Alums Yes I can create it, you can try in your PDI as well
Harish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-17-2024 08:51 PM
Thanks again for your response. That's strange, I have already tried it on my personal instance unsuccessfully.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-17-2024 09:05 PM
Hi @Community Alums which version of PDI are you using? I am on Vancouver patch 2
here is screenshot for reference
Harish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-17-2024 09:16 PM
@Harish KM : It's the same for me as well(glide-vancouver-07-06-2023__patch2-hotfix1-10-04-2023)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-17-2024 09:21 PM
@Community Alums
you didn't answer the question
Where have you written that script and what's your business requirement to insert data?
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
