rahul-garg/createserviceportalwidget icon
public
Published on 4/15/2025
Create Service Portal Widget

Create Service Portal Widget

Prompts
Create Service Portal Widget
Create Service Portal Widget
## Create Service Portal Widget

**Goal:** Generate code for a new Service Portal widget.

**Widget Name:** {Provide a name, e.g., "My Task List"}
**Purpose:** {Describe what the widget should do. e.g., "Display a list of active incidents assigned to the current user."}

**Requirements:**
- **Data:** {Specify data needed. e.g., "Needs Incident number, short description, state, priority."}
- **Functionality:** {Describe interactions. e.g., "Clicking an incident opens it in the standard form view. Needs a refresh button."}
- **Appearance:** {Optional: Describe basic layout or elements. e.g., "Display as a simple list/table."}

**Instructions:**
Generate the necessary code for the following sections:
1.  **HTML Template:** Structure the widget's view.
2.  **CSS:** Basic styling for readability.
3.  **Client Script:** Implement client-side logic (e.g., handling clicks, calling server). Use `spUtil` or `c.server.get()` as appropriate.
4.  **Server Script:** Implement server-side logic (e.g., querying data using `GlideRecord` on table '{table_name}', processing input). Populate `data` object.

Ensure the code follows ServiceNow best practices for portal widgets.