Unable to create a Consumer record in csm_consumer table.

Community Alums
Not applicable

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

16 REPLIES 16

Ankur Bawiskar
Tera Patron
Tera Patron

@Community Alums 

where is this written?

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

Community Alums
Not applicable

Hi @Ankur Bawiskar ,

Thanks for your response. I believe there is a oob client script 'Set type values' on Consumer(csm_consumer) table that is causing the issue. Please let me know if any additional info is required. Thanks.

Hi @Community Alums In PDI I am able to create a case from this table, I dont think this OOB script is an issue ,are there any other scripts which are created by your team?

Regards
Harish

Community Alums
Not applicable

Hi @Harish KM ,
Thanks for your response. Are you able to create a new consumer in your PDI manually?