Applies to:
SharePoint Online and SharePoint On-Premises
Description
Custom actions run in the browser. In some cases, it is required to capture custom action logs for the purpose of troubleshooting. Console logs for the custom actions can be captured and stored in a custom list.
This article describes steps to capture console logs for a custom action by configuring ‘Execute Script’ action and ‘Add List Item’ action in the same custom action. ‘Add List Item’ action is configured to store logs in a separate custom list. Similarly, we can create or modify any custom action to capture and store the custom action console logs.
If multiple actions are configured in a custom action, then we can configure ‘Execute Script’ action and ‘Add List Item’ action at the beginning and at the end of all the actions to ensure that the custom action is completely executed.
List schema
Custom SharePoint list titled as ‘Console Logs’ with following columns to capture the console logs:
Column display name | Column internal name | Column type |
Title | Title | Single line of text |
ListName | ListName | Single line of text |
ItemID | ItemID | Single line of text |
Logs | Logs | Multiple line of text |
CustomAction | CustomAction | Single line of text |
Execution | Execution | Single line of text |
Detailed steps
In this example, it is required to capture console logs for an existing custom action.
Sample flowchart of the custom action:
- Configure an empty variable.
Edit the required custom action -> Click ‘Variables’ from the ‘CUSTOM ACTION’ ribbon -> Click ‘New Variable’ and configure an empty variable.

Variable Name: ‘ConsoleLog’
Default Value:

2. Configure ‘Execute Script’ action.
Expand ‘Actions’ section -> Drag and drop ‘Execute Script’ action and place it as the first action on the canvas -> Specify below script in the execute script action.
Script:
var CLog = JSON.stringify(console.NITROLogs);
ccs_setwfvariablevalue("ConsoleLog", CLog);
functionCallback();
Note: “ConsoleLog” is the variable name.

3. Configure ‘Add List Item’ action to store the custom action console logs.
Drag ‘Add List Item’ action from the ‘Actions’ section and drop it after the ‘Execute Script’ action -> Configure the action as shown below:

Column mappings:
Column Name | Value Expression |
CustomAction | Specify name of the current custom action |
ItemID | [ID|ID] |
ListName | {ListName} |
Logs | ConsoleLog##Value |
Title | [Title|Title] |
Execution | Started (To indicate that these console logs are captured at the beginning of custom action execution.) |

4. Configure an execute script action and add list item action same as configured above in #2 and #3 at the end of all the actions configured in the custom action.
5. Configure column mappings in the ‘Add List Item Action’ action as shown below:
Column mappings:
Column Name | Value Expression |
CustomAction | Specify name of the current custom action |
ItemID | [ID|ID] |
ListName | {ListName} |
Logs | ConsoleLog##Value |
Title | [Title|Title] |
Execution | Ended (To indicate that these console logs are captured at the end of custom action execution.) |

Sample output

Console logs are stored in the ‘Console Logs’ list after execution of the custom action on ‘Virtual Machine’ item of ‘Tickets’ list.
