Table Type field query

Deepa Srivastav
Kilo Sage

Dear All,

I have a "table name" type field whose base table is alm_asset. According to my requirement it should show all extended tables except one/two. Also it shows table name in bracket i.e. dropdown value are in format ... Hardware[alm_hardware] etc, which we don't want.

To implement this I have added tableschoicescript attribute in the field and hardcoded extended table names there..

But problem is that I want first option to be "--None--" but in the field by default some other value is coming from script include (one of the table name) when I open the form .It is proper if I click the dropdown.

I wrote a client script to to add "--None--" in index 0..but nothing is helping..

Can somebody suggest me way to achieve this..Please check screenshots for reference.

Thanks in advance!

find_real_file.png

find_real_file.png

find_real_file.png

find_real_file.png

1 ACCEPTED SOLUTION

I haven't used that Attribute before so I am not sure how to do it at source (Script include)



But DOM manipulation is unnecessary and you can add a onload script for this.



g_form.addOption('u_table_choice_example','','-- None --',0);


g_form.setValue('u_table_choice_example','');


View solution in original post

15 REPLIES 15

Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

Hi Deepa,



Go to the field->Right click dictionary on the field->Select Advanced view->Select choice "Dropdown without None->Now add your own choice value "None" and set this to default value.


I haven't tried this but should work. Let me know.


Thanks a lot Pradeep for your response but i did try this before posting..didn't work...As far as i remem it sets none by default but then it comes as last option.


Abhinay Erra
Giga Sage

Deepa,



    You can go back to your first approach like creating an attribute for base table as "alm_asset" and write a client script for DOM manipulation. You can write a script to remove the table name in brackets and only show Table Label. You can also hide choices by using hide() method. Here is the script for that


onLoad Client script:



//var choiceID=$('<table_name>.<field_name>').options;


var choiceID=$('incident.u_table_name').options;


  for(var i=0; i<choiceID.length; i++){


  var splitArr=choiceID[i].label.split(' [');


  choiceID[i].label=splitArr[0];


//Put in the the Table Label you want to hide. In my case "Employers" is the table Label


/* if(splitArr[0]=="Employers"){


  choiceID[i].hide();


  }*/


  }



Thanks,


Abhinay


Thanks Abhinav for your reply... I wouldn't prefer DOM manipulation...but surely i will try this too as the last option.


Can you suggest some other method to achieve this.