Git Product home page Git Product logo

picklist-service's Introduction

Salesforce Lightning Picklist Service Component

⚠️ This project is archived ⚠️

Consider moving to Lightning Web Components. See the Retrieving Picklist Values Without Using Apex blog post and the sample LWC repository.

About

This is a generic and reusable Lightning component that retrieves any picklist entries.
This is a service component so it has no user interface of it's own: it is meant to be called by other components.

Features

The component provides the following features:

  • fetches picklists for any dynamic object (standard or custom) and field names
  • integrated error notifications (developer console + toast notifications in Lightning Experience)
  • storable actions for client-side cache
Sample app screenshot

Documentation

The component is documented using Aura documentation.
You can access it from this URL (replace the domain):
https://<YOUR_DOMAIN>.lightning.force.com/auradocs/reference.app#reference?descriptor=c:PicklistService&defType=component

Use the service by adding the component to a parent component's markup:

<c:PicklistService aura:id="picklistService"/>

Then, simply call the service from the parent's component controller like this:

// Getting picklist entries for Account.Industry field
component.find('picklistService').getEntries('Account', 'Industry', entries => {
    console.log(entries);
});

Entries are returned as an Array of JS Object:

[
    {
        "value": "Agriculture",
        "label": "Agriculture",
        "isDefaultValue": false
    },
    ...
]

Entries can directly be used in a lightning:combobox component:

<lightning:combobox name="values" label="Picklist entries" options="{!v.entries}"/>

Salesforce DX setup instructions

Deploy the sample application with the Salesforce CLI.

Sample application

The default installation installs the component and a sample application available under this URL (replace the domain):
https://<YOUR_DOMAIN>.lightning.force.com/c/SamplePicklistApp.app

If you wish to install the project without the sample application, edit sfdx-project.json and remove the src-sample path.

picklist-service's People

Contributors

pozil avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

picklist-service's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.