SupportCenter Plus

    Script Invocation

    Any kind of script can be invoked from SupportCenter Plus application through a click on the menu from the Request Details page.

     

     

    Follow the steps given below to configure script invocation.

     

    Step 1: Copy configuration files.

    1. Copy the 'scriptimpl.jar' file from "[SCP_Home]/actionplugins/script/lib" directory to "[SCP_Home]/server/default/lib" directory.

    2. Copy the ScriptActionConfig.xml present in the "[SCP_Home]/actionplugins/script/conf" directory to "[SCP_Home]/server/default/conf" directory.

    3. Copy the contents of the Script_Menu.xml available in the "[SCP_Home]/actionplugins/script/conf" directory to Request_ActionMenu.xml file available in the "[SCP_Home]/server/default/conf" directory.

     

    Step 2: Configure XMLs.

    1. The menu options that have to be displayed in SCP request will be configured in Request_ActionMenu.xml file.
    2. The type and path of the script which is going to be invoked will be specified in the ScriptActionConfig.xml file.

    NOTE: The actual implementation class file (ScriptExecutor.java) is available under the [SCP_Home]\actionplugins\script\src\com\scp\script directory. You can modify the file as per your requirement, compile it and update the scriptimpl.jar file (update the jar file in [SCP_Home]\server\default\lib directory). Finally restart the server.

     

    Setting Up Request_ActionMenu.xml Configuration

     

    The Actions menu that has to be displayed in the Request Details page can be configured in the Request_ActionMenu.xml file. Modifying this file would require server restart. After restart, open a request in SCP, you will have the Actions menu plugin-icon as shown below. By clicking on the Actions menu option, you can invoke the script.

    script-action-plugin

    Setting Up ScriptActionConfig.xml Configuration

    1. Open the ScriptActionConfig.xml file copied under "[SCP_Home]/server/default/conf" directory.

    2. Under the menu name "<menu name="Invoke_vbs">", specify the script name that has to be invoked upon invocation of the action menu from SCP request in the <script> element. You also need to specify how this script should be invoked. For example, if you would like to invoke VBS file, then you need to give cscript followed by the name of the script file (cscript RequestVbsFile.vbs). The dynamic arguments can be passed to the scripts by using the "$" variable followed by the key. For example, if subject needs to be passed to the script, then "$subject" should be specified. In addition to these individual variables, if the script needs all the properties to be passed, then you need to specify "$COMPLETE_JSON". This will pass the complete JSON string as an argument. Click here to view the sample JSON data returned by SCP when the Actions menu is invoked.

     

     

    <script>cscript RequestVbsFile.vbs //nologo $COMPLETE_JSON</script> <!-- Specify the script that needs to be invoked upon invocation of the actions menu-->

     

    <dir>C:\ManageEngine\SupportCenter</dir><!-- Specify the directory from where the script has to be executed-->

    1. Specify the directory from where the script file should be invoked in the <dir> element.

    2. Custom messages can be set upon success or failure invocation. These messages will be shown up in SupportCenter Plus interface when the action menu is invoked.

     

     

    <success>Successfully Invoked $ScriptType File</success>

    <failure>Failed to invoke</failure>

     

    1. Handling response from Script: The Scripts returns the response to SCP in JSON format. Below is the sample response from script in JSON format:


      {

      "isScriptExecuted":"Yes",

      "ScriptType":"vbs",

      }




      To update SCP with the script response, create additional fields (For example, "Is Script Executed" and "Script Type") in SCP under Admin --> Helpdesk Settings --> Request --> Additional Fields (See, Request - Additional Fields.) and include it in the Request template. And map the fields with the JSON object as shown in the below table. The response can also be added as a note in SCP.

     

    <response>

    <param>

    <!-- name indicates the SCP field that should be updated with the response returned from script -->

    <name>Is Script Executed</name> <!-- Specify the additional field created in SCP -->

    <!-- value indicates the attribute in the return JSON format received from script -->

    <value>$isScriptExecuted</value> <!-- Specify the JSON object prefixed with $ symbol -->

    </param>

    <param>

    <name>Script Type</name>

    <value>$ScriptType</value>

    </param>

     

    <!-- If any note needs to be added at the end of the operation, then it needs to be specified here. -->

    <notes>

    <note>Successfully Invoked $ScriptType File</note>

    </notes>

    </response>

    1. If you would like to invoke a batch file, configure it under the menu name "Invoke_batch". Specify the script name that has to be invoked upon invocation of the action menu from SCP request in the <script> element. You also need to specify how this script should be invoked. For example, for invoking batch file, you need to give cmd /c followed by the name of the script file (cmd /c startIndex.bat).

    2. Specify the directory from where the script file should be invoked in the <dir> element.

    3. Custom messages can be set upon success or failure invocation. These messages will be shown up in SupportCenter Plus interface when the action menu is invoked.

    4. Handling response from Script: The Scripts returns the response to SCP in JSON format. Below is the sample response from script in JSON format:


      {

      "isScriptExecuted":"Yes",

      "ScriptType":"batch",

      }




      To update SCP with the script response, create additional fields (For example, "Is Script Executed" and "Script Type") in SCP under Admin --> Helpdesk Settings --> Request --> Additional Fields (See, Request - Additional Fields.) and include it in the Request template. And map the fields with the JSON object. The response can also be added as a note in SCP.
    5. Save ScriptActionConfig.xml.

    NOTE: Server restart is not required after editing and saving the ScriptActionConfig.xml file.

     

    Invoking Script from SCP Request

    Once the Request_ActionsMenu.xml is configured, you will find the Actions menu in the Request Details page. Click the Actions menu to invoke script.

    script-actions-menu

     

    The response from the script are handled in SCP in the following ways:

    • If the response complies to the return JSON supported by SCP, then the specified action like adding notes, updating a request etc., are performed.

      A success message will appear, stating that the script is invoked successfully. The status of the script and the script type are updated in the "Is Script Executed" and "Script Type" additional fields respectively.

    • If the response does not comply the JSON supported by SCP, then the response received from the script file will be displayed in SCP and history will be added.

      A sample message returned from script file is shown in the below image.


      script-error-mes2

    • If there is no response but the action is successful, then the success message specified in the XML will be displayed.


      script-error-mes1

    • If there is an invocation error, then the error message will be displayed and added to history.


      script-error-mes

     

     

    Copyright © 2017, ZOHO Corp. All Rights Reserved.