ChuckJonas / ts-force

A Salesforce REST Client written in Typescript for Typescript
88 stars 21 forks source link

Child relationship field missing #116

Open andrenarchy opened 3 years ago

andrenarchy commented 3 years ago

On the Opportunity object I have a custom field Renewed_From_Opportunity that is a lookup relationship to an Opportunity (thus linking opportunities to each other). The child relationship on Opportunity is called Renewed_In_Opportunities but it does not show up when generating the types with ts-force-gen@3.0.2 (while the lookup field shows up as Renewed_From_Opportunity__r and Renewed_From_Opportunity__c).

When I manually add the following to Opportunity.ts everything works as expected:

  @sField({
    apiName: 'Renewed_in_Opportunities__r',
    createable: false,
    updateable: false,
    required: false,
    reference: () => {
      return Opportunity
    },
    childRelationship: true,
    salesforceType: SalesforceFieldType.REFERENCE,
    salesforceLabel: 'Renewed in Opportunities',
    externalId: false,
  })
  public renewedInOpportunities?: Opportunity[]
  // ...
  constructor(fields?: OpportunityFields, restInstance?: Rest) {
    // ...
    this.renewedInOpportunities = void 0
  }

Is ts-force treating this particular relationship differently because it's linking the same object types? In any case, it would be great if it would just support this setting as well!

ChuckJonas commented 3 years ago

in theory this should work. Pretty sure I've done something similar several times. Does the parent relationship get generated?

If not, can you check FLS? If you're an Admin profile with "see all data", you can query fields you don't have read access to, but they won't show up in the tooling API