Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

how to open record in native ui on data table click

Akki1
Tera Contributor

Hi,

I have made a custom widget and used in catalog which shows the records I want that whenever the user clicks the record that record should open in new tab in native servicenow. 

find_real_file.png

1 ACCEPTED SOLUTION

Markus Kraus
Kilo Sage

Duplicate of this: Data table widget using macro variable

Solution for this is (make sure to add $window to the function declaration of the client controller):

$scope.$on('data_table.click', function (event, params) {
    $window.open('nav_to.do?uri=%2F' + params.table + '.do%3Fsys_id%3D' + params.sys_id, "_blank");
});

View solution in original post

4 REPLIES 4

Aman Kumar S
Kilo Patron

Hey,

Check below article and go through all responses.

 

service portal: data table widget form redirection

 

Feel free to mark correct, If I answered your query.

Will be helpful for future visitors looking for similar questions 🙂

Best Regards
Aman Kumar

This wont work as you do not have any instance options available when using a custom widget in a service catalog item...

Community Alums
Not applicable

Hello,

Not sure which code you are using, please check below piece of HTML code if it helps you.

 

  <tr ng-repeat="item in data.list track by item.sys_id">
            <td role="{{$first ? 'rowheader' : 'cell'}}" class="pointer sp-list-cell" ng-class="{selected: item.selected}"
                ng-click="go(item.targetTable, item)"
                ng-repeat="field in ::data.fields_array"
                data-field="{{::field}}"
                data-th="{{::data.column_labels[field]}}">
                <a href="javascript:void(0)" ng-if="$first" aria-label="${Open record}: {{::item[field].display_value}}">{{::item[field].display_value | limitTo : item[field].limit}}{{::item[field].display_value.length > item[field].limit ? '...' : ''}}</a>
                <span ng-if="!$first">{{::item[field].display_value | limitTo : item[field].limit}}{{::item[field].display_value.length > item[field].limit ? '...' : ''}}</span>
            </td>
          </tr>

 

 

Markus Kraus
Kilo Sage

Duplicate of this: Data table widget using macro variable

Solution for this is (make sure to add $window to the function declaration of the client controller):

$scope.$on('data_table.click', function (event, params) {
    $window.open('nav_to.do?uri=%2F' + params.table + '.do%3Fsys_id%3D' + params.sys_id, "_blank");
});