I have a Canvas App inside a standard page layout on the Opportunity layout. I'd like to expose some information to the external Canvas App (some field values), but it seems like the lifecycle handler isn't doing the trick.
Here's the source:
public void onRender(Canvas.RenderContext renderContext)
{
Canvas.ApplicationContext app = renderContext.getApplicationContext();
Canvas.EnvironmentContext env = renderContext.getEnvironmentContext();
Set<String> fields = new Set<String>{'Id', 'Name'};
env.addEntityFields(fields);
}
Is it because it can only expose information if it is used inside a Visualforce page (apex:canvasPage
) ?
EDIT
Based on this part in the documentation, it should technically work when included as a Page Layout item since it is inside an object context:
The list of object fields for which Salesforce will return Record context data if the canvas app appears on an object page. One way a canvas app can appear on an object page is if the canvas app appears on a Visualforce page through the use of the component and that Visualforce page is associated with an object
EDIT 2
Considering this link (https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_canvas_EnvironmentContext_addEntityField.htm), does it only work in <apex:canvasApp>
? Do I have to create a dummy Visualforce page with a StandardController and add the canvasApp to get this data in?