I've created a button on opportunity page using LWC. Once the button is clicked it should create OpportunityLineItemSchedule records based on Opportunity and related OpportunityLineItem record.

Below is the logic implemented, but it was throwing an error like

Object OpportunityLineItemSchedule is not supported in UI API


import { LightningElement, track, wire, api } from 'lwc';
import { getRecord, createRecord } from 'lightning/uiRecordApi';
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
import getOpporunityLineItems from '@salesforce/apex/CreateProjectAndRevenueScheduleHelper.getOpportunityLineItems';
import SCHEDULE_OBJECT from '@salesforce/schema/OpportunityLineItemSchedule';

//Opp fileds to create project record later
const fields = [

export default class CreateProjectAndRevenueSchedule extends LightningElement {

    @track hideButton = false;//to grey out the button after the click
    @api recordId;//current opportunity recordId
    opportunityData;//hold the opportuity record
    @track error;//to track error
    opprotunityLineItem;//to store opportunity line item details
    revenueCreated;//revenue schedule

    @wire(getRecord, { recordId: '$recordId', fields })
    loadOpportunity({ error, data }) {
        if (error) {
            // TODO: handle error
            this.error = error;
        } else if (data) {
            // Get Opportunity data
            this.opportunityData = data;

    //get the releted opportunity product details
    connectedCallback() {
        getOpporunityLineItems({'opporunityId': this.recordId})
            this.opprotunityLineItem = result;
            this.error = error;

    //onclick logic to execute
    handleClick () {

    createRevenue() {
        var startDate = Date.parse(this.opprotunityLineItem.Start_Date__c);
        var endDate = Date.parse(this.opprotunityLineItem.End_Date__c);
        var timeDiff = endDate - startDate;
        var months = Math.ceil(Math.floor(timeDiff / (1000 * 60 * 60 * 24))/30);
        let monthyPayment = this.opprotunityLineItem.TotalPrice/months; 

        for(let i=0;i<months;i++){
            // eslint-disable-next-line no-shadow
            const fields = {};
            fields.Type = 'Revenue';
            fields.OpportunityLineItemId = this.opprotunityLineItem.Id;
            //fields.Quantity = this.opprotunityLineItem.Quantity;
            fields.Revenue  = monthyPayment;
            fields.Opportunity__c = this.recordId;
            const recordInput = { apiName : SCHEDULE_OBJECT.objectApiName, fields};


    //createRecord revenue schedules
    createRecords(recordInput) {
            .then(result => {
                this.revenueCreated = true;
            .catch(error => {
                    new ShowToastEvent({
                        title: 'Error creating record',
                        message: error.message,
                        variant: 'error',

As per the documentation User Interface API Developer Guide, OpportunityLineItemSchedule is not supported in UI API.

Can someone explain how can I fix this?

  • If an object is not supported, you cannot use it using UI API, and that’s what the error suggests. You’ll need to write custom logic here to be able to create the record.
    – Jayant Das
    Aug 31 '19 at 16:23

If the SObject is not supported by the UI API the createRecords() method would need to be replaced with an apex method that would create the records. Additionally, the SCHEDULE_OBJECT variable would need to be replaced with the object name.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.