The Now Platform® Washington DC release is live. Watch now!

Help
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Service Portal Data Table widget - Double-click to edit columns

James D_ Downer
Kilo Explorer

I've cloned the service portal "Data Table with URL filter" widget and am trying to figure out how to edit it so that the end user can double-click a column to edit it instead of it redirecting him/her to the form view for the selected row.

My question is: How do I capture a double-click on the data-table in the Client Controller script, and how do I get both the row and column clicked?

1 ACCEPTED SOLUTION

Jon Barnes
Kilo Sage

Check out this post. I provided a widget that will do what you are asking (but it uses the OOB sp-editable-field directive, so it currently triggers on a single click).

 

https://community.servicenow.com/community?id=community_question&sys_id=a6b2ca9bdb98db445322f4621f961989

 

I am attaching here a Kingston version and an Istanbul version. feel free to use these or tweak them as needed.

View solution in original post

9 REPLIES 9

Jon Barnes
Kilo Sage

Check out this post. I provided a widget that will do what you are asking (but it uses the OOB sp-editable-field directive, so it currently triggers on a single click).

 

https://community.servicenow.com/community?id=community_question&sys_id=a6b2ca9bdb98db445322f4621f961989

 

I am attaching here a Kingston version and an Istanbul version. feel free to use these or tweak them as needed.

This is awesome!

There is a bug, however, when including dot-walked fields in the Fields section of the configuration tab (Kingston release).

For example, when I include ci.name...

find_real_file.png

... it fails to retrieve that from sys_dictionary in the function EditableDataTableUtil.getFields:

/**
 * EditableDataTableUtil : Lines 14—19
 **/
var grDic = new GlideRecord('sys_dictionary');
grDic.addQuery('name', new TableUtils(table).getHierarchy());
grDic.addQuery('element', 'IN', fields.join(','));
grDic.query(); // <== "ci.name" is ignored
while (grDic._next()) {
    var name = grDic.getValue('element'); // <== "ci.name" is excluded
    ...

This throws an error later when evaluating grForDetails:

/**
 * EditableDataTableUtil : Lines 81—86
 **/
var grForDetails = new GlideRecord(table);
for (var i=0; i<fields.length; i++) {
    var ge = grForDetails.getElement(fields[i]);
    if (ge == null)
        continue;
    ret[fields[i]].label = ge.getLabel(); // <== error when fields[i] is "ci.name"
    ...

The thrown exception is:

Server JavaScript error Cannot set property "label" of undefined to "Name"

Line number 86

 

Why it doesn't evaluate ci.name when querying sys_dictionary is something I've yet to determine.

thanks for pointing that out. I will see if I can work around that. hadn't thought about dot-walked fields in there. that probably presents a bit of a challenge to the overall solution.

 

The workaround for now may be to detect that it is a dot-walked field, and don't use sp-edit-field. just use the regular display of the field.

 

Hey,

I have the same exact issue with the dot walk fields, did you find a solution for this?

Thanks,