In service operations workspace view details button is not working

KandulaGeet
Tera Contributor

View Details Button is not working for Service operations workspace

  1. Navigate to service operations work space

  2. Click on the QTC button

  3. Select the ITS service catalog under catalogs dropdown

  4. Click on laptop software support

  5. Fill the mandatory fields

  6. click on submit

  7. after clicking on submit there are two buttons available close and view details

  8. after clicking on view details button
    Not working while clicking on view details.

    We have a widget AW-SC order status.
    Script of client controller in widget, The same script is working as expected for Agent workspace.

    Please provide me some inputs or help me with the code.

    function($scope, $window, $timeout, $location, spAriaUtil, cabrillo) {
        /* widget controller */
        var c = this;
        $scope.animateTick = '';
        $scope.toggle = function($event, item) {
            item.expand = !item.expand;
        }

        $scope.isNative = cabrillo.isNative() && c.data.isMEE;
        var wrapperClassName = $scope.isNative ? "wrapper-xs " : "wrapper-md ";
        if (c.data.is_new_order) {
            $timeout(function() {
                spAriaUtil.sendLiveMessage(c.data.msg.orderSubmitMsg, "status");
            }, 1000);

            // Set Title in Workspace
            if ($scope.options.isServiceWorkspace && !$scope.isNative) {
                $window.postMessage({
                    msg: 'CATALOG_ITEM_SET_TITLE',
                    title: c.data.msg.pageTitle
                }, $location.origin);
            }
        }

        if ($scope.isNative) {
            cabrillo.viewLayout.setTitle(c.data.msg.pageTitle);
            cabrillo.viewLayout.hideBackButton();
        }
        $scope.actions = {
            isOpen: false
        };
        $scope.field = {
            ed: {
                reference: 'sys_user',
                qualifier: "active=true^EQ"
            },
            value: '',
            isMandatory: function() {
                return false;
            },
            display_value_list: [],
            g_form: {
                $private: {
                    events: {
                        on: function() {}
                    }
                },
                setValue: function(name, value, displayValues) {
                    $scope.field.value = value;
                    $scope.field.display_value_list = displayValues;
                    $scope.field.displayValue = displayValues.join(',');
                }
            }
        }

        $scope.reOrder = function() {
            if (!$scope.field.value)
                return;
            var numOfClones = $scope.field.display_value_list.length;
            window.GlideWebAnalytics.trackEvent("Service Catalog", "Catalog Post Submission", "Request Cloned", numOfClones);
            $scope.server.get({
                userList: $scope.field.value,
                action: 'clone_request'
            }).then(function(response) {
                var progressModalCtrl;
                var unregister = $scope.$on('$sp.service_catalog.close_cloning', function() {
                    progressModalCtrl.close();
                    $window.location.reload();
                });
                var progressModal = angular.copy(response.data.progressModal);
                progressModal.options.afterOpen = function(ctrl) {
                    progressModalCtrl = ctrl;
                };
                progressModal.options.afterClose = function() {
                    unregister();
                    c.progressModal = null;
                    progressModalCtrl = null;
                    $window.location.reload();
                };
                c.progressModal = progressModal;
            });
        }

        $scope.displayRequestItemTable = function() {
            return ((c.options.display_description === 'true') ||
                (c.options.display_delivery_date === 'true') ||
                (c.options.display_stage === 'true') ||
                (c.options.display_price === 'true') ||
                (c.options.display_quantity === 'true') ||
                (c.options.display_number === 'true')) && !c.options.isServiceWorkspace;
        }

        $scope.getSVGClass = function() {
            var classForWorkspace = wrapperClassName + "text-center";
            var svgClass = wrapperClassName + "b-b text-center visible-xs visible-sm";
            return c.options.isServiceWorkspace ? classForWorkspace : svgClass;
        }

        $scope.getOrderInfoClass = function() {
            var classForWorkspace = wrapperClassName + "text-center";
            var orderInfoClass = wrapperClassName + "b-b text-sm-center";
            return c.options.isServiceWorkspace ? classForWorkspace : orderInfoClass;
        }

        $scope.viewDetails = function() {
            window.postMessage({
                msg: 'TARGET_RECORD_SELECTED',
                target_number: c.data.currentRecord.number,
                target_table: c.data.currentRecord.table,
                target_sys_id: c.data.currentRecord.sys_id
            }, location.origin);
        }


        // var newU = "/now/sow/record/incident/" + c.data.currentRecord.sys_id +"/params/query/undefined";
        // open(newU);
        // $window.location.href = newURL;

        // var newURL = "now/sow/record/incident/" + c.data.currentRecord.sys_id;
        // //$window.open(newURL);
        // $window.location.href = newURL;


        $timeout(function() {
            if ($scope.isNative)
                cabrillo.viewLayout.hideSpinner();
        });
        $scope.closeTab = function() {

            $window.location.href = "swp?id=aw_sw_sc_category"; // redirect to category page on click of close button

        }

        /*  $scope.closeTab = function () {
                if ($scope.isNative) {
                    cabrillo.flowControl.flowEnded();
                    return;
                }
                window.postMessage({
                        msg:'CATALOG_ITEM_CLOSED'
                    }, location.origin);
            } */
    }





 

3 REPLIES 3

Community Alums
Not applicable

Hi @KandulaGeet ,

 

try with this code 

 

function($scope, $window, $timeout, $location, spAriaUtil, cabrillo) {
    var c = this;
    $scope.animateTick = '';

    $scope.toggle = function($event, item) {
        item.expand = !item.expand;
    };

    $scope.isNative = cabrillo.isNative() && c.data.isMEE;
    var wrapperClassName = $scope.isNative ? "wrapper-xs " : "wrapper-md ";

    if (c.data.is_new_order) {
        $timeout(function() {
            spAriaUtil.sendLiveMessage(c.data.msg.orderSubmitMsg, "status");
        }, 1000);

        if ($scope.options.isServiceWorkspace && !$scope.isNative) {
            $window.postMessage({
                msg: 'CATALOG_ITEM_SET_TITLE',
                title: c.data.msg.pageTitle
            }, $location.origin);
        }
    }

    if ($scope.isNative) {
        cabrillo.viewLayout.setTitle(c.data.msg.pageTitle);
        cabrillo.viewLayout.hideBackButton();
    }

    $scope.viewDetails = function() {
        if (!c.data.currentRecord || !c.data.currentRecord.sys_id) {
            console.error("Error: Missing Record Data", c.data.currentRecord);
            alert("Unable to open record details. Missing record information.");
            return;
        }

        var recordSysId = c.data.currentRecord.sys_id;
        var recordTable = c.data.currentRecord.table || "sc_request"; // Default to 'sc_request'

        console.log("Navigating to:", recordTable, recordSysId);

        // Use direct navigation instead of postMessage
        $window.location.href = "/now/sow/record/" + recordTable + "/" + recordSysId;
    };

    $scope.closeTab = function() {
        $window.location.href = "swp?id=aw_sw_sc_category"; // Redirect to category page on close
    };

    $timeout(function() {
        if ($scope.isNative) cabrillo.viewLayout.hideSpinner();
    });
}

 

 

Errors -

window.postMessage() Not Handled in SOW

    • Service Operations Workspace might not support the postMessage() event the same way Agent Workspace does.
    • Instead, direct navigation is used:
      javascript
      $window.location.href = "/now/sow/record/" + recordTable + "/" + recordSysId;
  1. Missing or Undefined c.data.currentRecord

    • If c.data.currentRecord.sys_id is missing, the button won’t work.
    • Fix: Add a validation check with an alert and console log:
      if (!c.data.currentRecord || !c.data.currentRecord.sys_id) { console.error("Error: Missing Record Data", c.data.currentRecord); alert("Unable to open record details. Missing record information."); return; }
  2. Incorrect Table Reference (target_table)

    • If c.data.currentRecord.table is undefined, it will break navigation.
    • Fix: Default to "sc_request" if table is missing:
      var recordTable = c.data.currentRecord.table || "sc_request";

@Community Alums 

The script which you had provided should have to work for both SOW and Agent workspace.



Regards,
Geethika kandula.

I am facing an error while using the code which you had provided.

In agent workspace whilw the form is submitted two headers are coming.