lewiswill / sn-react-record-picker

A React.js record picker example component for ServiceNow

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ServiceNow React Record Picker

Reference field is a key functionality for many ServiceNow applications. Especially when it comes to custom web apps and Service Portal.

This implementation is based on react-select and react-select-async-paginate libraries, so you can use all of their options and features in your ServiceNow applications.

The key idea for this reference field (record picker) implementation is to show how you can utilize React components for ServiceNow applications and create complex functionality with a few lines of code.

Run Locally

  1. Clone this repository
git clone https://github.com/elinsoftware/sn-react-record-picker.git
  1. Install dependencies
npm install
  1. Set up proxy to handle requests to your ServiceNow instance

In package.json add:

"proxy": "https://<instance-name>.service-now.com"
  1. Add your ServiceNow instance account and password by creating an .env file

In .env add:

REACT_APP_USER=<your-username>
REACT_APP_PASSWORD=<your-password>
  1. Run React
npm start

You're all set to run React app locally 🙂

Deploy to ServiceNow

  1. Build the application package
npm run build
  1. For each .js and .css file from build/static folder create a Style Sheet record in ServiceNow, copy the corresponding code.
  2. Create UI page, set Direct = True. Copy HTML code from /build/index.html.
  3. Replace inline javascript code in HTML with a reference to the runtime~main code from the corresponding Style Sheet. The reference link should look like [style_sheet_sys_id].cssdbx
  4. Replace all other links with references to the corresponding Style Sheets.

Your updated UI page should look like this: uipage

You just deployed a React application to ServiceNow.

Open the UI page in a browser to see how the application works.

About

A React.js record picker example component for ServiceNow


Languages

Language:JavaScript 63.0%Language:HTML 21.0%Language:CSS 16.1%