2

I'm receiving a variety of deployment errors related to OpportunityLineItemSchedule. For example:

sObject type 'OpportunityLineItemSchedule' is not supported. If you are attempting to use a custom object, be sure to append the '__c' after the entity name. Please reference your WSDL or the describe call for the appropriate names.


Didn't understand relationship 'OpportunityLineItemSchedules' in FROM part of query call. If you are attempting to use a custom relationship, be sure to append the '__r' after the custom relationship name. Please reference your WSDL or the describe call for the appropriate names.


Entity is not org-accessible entity name: OpportunityLineItemSchedule

How can I resolve these errors?

3

These errors are arising because you have not enabled Product Schedules in the target org. Enable

Setup > Product Schedule Settings > Revenue Schedules > Scheduling Enabled.

| improve this answer | |
3

If you need to support orgs where revenue schedules may or may not be enabled you can do so so by removing all explicit references to OpportunityLineItemSchedule from the code.

Instead you use metadata, dynamic SOQL and field access to work with the revenue schedules. E.g.

Schema.DescribeSObjectResult describeSObjectResult = Product2.SObjectType.getDescribe();
boolean schedulesEnabled = describeSObjectResult.fields.getMap().containsKey('CanUseRevenueSchedule');

// ...

if(schedulesEnabled) {
    List<sObject> revenueSchedules = Database.query('select Id, Type, Revenue, ScheduleDate from OpportunityLineItemSchedule where OpportunityLineItemId = :oliId');
    //...
}

This is probably overkill if you are just dealing with a single production org and it's associated sandboxes. However, it becomes really important if you are creating managed packages for the app exchange and want to support the widest range of orgs possible.

| improve this answer | |

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.