Note: This release is in preview. Features described here don’t become generally available until the latest general availability date that Salesforce announces for this release. Before then, and where features are noted as beta, pilot, or developer preview, we can’t guarantee general availability within any particular time frame or at all. Make your purchase decisions only on the basis of generally available products and features.
Javascript Page Security Plugin
| Available in: Salesforce CPQ Summer '15 and later |
The Javascript Page Security plugin supports four functions. The functions isFieldVisible and isFieldEditable are available starting in Salesforce CPQ Summer '15 and control quote line field visibility and editability. The functions isFieldVisibleForObject and isFieldEditableForObject are available starting in Salesforce CPQ Summer '19 and can control field visibility and editability for both quote fields and quote line fields. When a method using one of these functions returns False, Salesforce CPQ locks or hides the chosen fields. The fields are unchanged if the method returns Null or True.
To create a page security plugin, define your code in a custom script record and then reference that record's name in the Quote Calculator Plugin field within Salesforce CPQ Plugin package settings. If you’re already using a quote calculator plugin in that field, you can add your page security plugin code to the calculator plugin’s custom script record.
| Parameter | Type | Definition |
|---|---|---|
| fieldname | string | If isFieldVisible returns False, this quote line field is hidden. |
| line | SObject | The quote line object |
| conn | Object | Methods access jsforce through the optional parameter conn. |
| Parameter | Type | Definition |
|---|---|---|
| fieldname | string | If isFieldEditable returns False, this quote line field is locked from edits. |
| line | SObject | The quote line object |
| conn | Object | Methods access jsforce through the optional parameter conn. |
| Parameter | Type | Definition |
|---|---|---|
| fieldName | String | if isFieldVisibleForObject returns False, this field is hidden. |
| quote or line | SObject | The object containing the field that you're evaluating to determine whether fieldName is visible. |
| conn | Object | Methods access jsforce through the optional parameter conn. |
| objectName | String |
The object that contains fieldName. If your second parameter is quote, use Quote__c. If your second parameter is quoteline, use QuoteLine__c. Leave this parameter undefined to target the same field on the quote and the quote line. |
| Parameter | Type | Definition |
|---|---|---|
| fieldName | String | if isFieldEditableForObject returns False, this field is locked from edits. |
| quote or line | SObject | The object containing the field that you're evaluating to determine whether fieldName is editable. |
| conn | Object | Methods access jsforce through the optional parameter conn. |
| objectName | String | The object that contains fieldName. If your second parameter is quote, use Quote__c. If your second parameter is quoteline, use QuoteLine__c. Leave this parameter undefined to target the same field on the quote and the quote line. |
We strongly recommend that users on Salesforce CPQ Summer '19 and later use the new functions given their improved flexibility. If your plugin uses pre-Summer '19 functions with isFieldEditableForObject or isFieldVisibleForObject functions using the line parameter, Salesforce CPQ ignores the new functions and uses the old functions instead.
1export function isFieldEditableForObject(fieldName, quote, conn, objectName){
2 if (objectName === 'Quote__c' && fieldName === 'SBQQ__MarkupRate__c')However, the following code segment targets Markup Rate on both the quote and the quote line.
1export function isFieldEditableForObject(fieldName, quote, conn, objectName){
2 if fieldName === 'SBQQ__MarkupRate__c'Example
1export function isFieldEditableForObject(fieldName, quote, conn, objectName){
2 if (objectName === 'Quote__c' && fieldName === 'SBQQ__MarkupRate__c') {
3 if (quote.SBQQ__CustomerDiscount__c > 10) {
4 return false;
5 }
6 }
7}Example
1export function isFieldVisibleForObject(fieldName, line, conn, objectName){
2 if (objectName === 'QuoteLine__c' && fieldName === 'SBQQ__MarkupRate__c') {
3 if (line.SBQQ__CustomerDiscount__c > 10) {
4 return false;
5 }
6 }
7}Example
Example
1export function isFieldEditableForObject(fieldName, quote, conn, objectName){
2 if (objectName === 'Quote__c' && fieldName === 'SBQQ__MarkupRate__c') {
3 if (quote.SBQQ__CustomerDiscount__c > 10) {
4 return false;
5 }
6}
7
8if (objectName === 'QuoteLine__c' && fieldName === 'SBQQ__MarkupRate__c') {
9 if (line.SBQQ__DistributorDiscount__c > 10) {
10
11 return false;
12 }
13 }
14}