How can I show only picklist values allowed for a specific Record Type?
For example:
Case.Status values are "Pending", "Open", "Closed"
- Case RecordType1 only allows the
Pending
value - Case RecordType2 allows
Open
andClosed
values
I'm developing a Lightning component in a Visualforce Page but I haven't found a convenient lightning-way to do this. I'm looking for a stable solution, that allows me to remove the component from the VF page at any time.
In Visualforce I used to invoke the describeLayout
API offered with connection.js and it worked well:
sforce.connection.describeLayout(
selectedObjectType,
new Array(recordTypeId), {
onSuccess: handleDescribeLayoutSuccess,
onFailure: handleDescribeLayoutFailure
}
);
So I tried to import connection.js in my Lightning component using ltng:require and retrieving the SessionId with a server-side action.
It works well with Locker Service disabled, but when it is enabled the describeLayout response always enter in the onFailure
callback.
The data provided to the onFailure function shows the layout describe in XML, but it is treated as an error.
The response data
is below (just skipped part of the inner describe):
Remote invocation failed, due to:
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns="urn:partner.soap.sforce.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Header>
<LimitInfoHeader><limitInfo><current>2</current><limit>15000</limit><type>API REQUESTS</type></limitInfo>
</LimitInfoHeader>
</soapenv:Header>
<soapenv:Body>
<describeLayoutResponse>
<result><-- correct layout describe, skipped for readability --></result>
</describeLayoutResponse>
</soapenv:Body>
</soapenv:Envelope> status code: