Default API functions which are available in each intercepted method.

Example

// The API can be obtained from the parameters of intercepted method
// This will be triggered when a user opens an existing Quote
export const quotesDetailOpen = async ({ api }) => {
api.notify.success('Hello World!');
}

Hierarchy

  • InterceptorMethodAPI

Properties

add: { customer: ((customer: any) => Promise<any>); product: ((product: any) => Promise<any>) }

Type declaration

  • customer: ((customer: any) => Promise<any>)
      • (customer: any): Promise<any>
      • Parameters

        • customer: any

        Returns Promise<any>

  • product: ((product: any) => Promise<any>)
      • (product: any): Promise<any>
      • Parameters

        • product: any

        Returns Promise<any>

app: { getCurrentUser: (() => Promise<User>) }

Used for obtaining data from Unity which are not accessible through configuration

Type declaration

  • getCurrentUser: (() => Promise<User>)
      • (): Promise<User>
      • Returns logged user

        Returns Promise<User>

configuration: { overrideConfig: ((path: string, value: any) => Promise<void>); retrieveConfig: ((path: string, defaultValue?: any) => Promise<any>) }

Type declaration

  • overrideConfig: ((path: string, value: any) => Promise<void>)
      • (path: string, value: any): Promise<void>
      • Used to temporarily set a value in the configuration.
        Updated configuration is valid only in the current web browser tab.

        Parameters

        • path: string

          The path to the value, for example environmentSettings.salesforce.displayLocation.Aura.autoGrow.

        • value: any

        Returns Promise<void>

  • retrieveConfig: ((path: string, defaultValue?: any) => Promise<any>)
      • (path: string, defaultValue?: any): Promise<any>
      • Reads values from Pricefx configuration object.
        You can use it to get values from feature flags or some other values such as:

        • type - dev | prod
        • partition
        • applicationEnvironment - standalone | sales-force | c4c | dynamics
        • apiUrl
        • locale

        Example

        const visibleDashboards = await configuration.retrieveConfig(
        'customerSpecificFeatureFlag.dashboards.visible.account',
        []
        );

        Parameters

        • path: string

          The path to the value, for example environmentSettings.salesforce.displayLocation.Aura.autoGrow.

        • Optional defaultValue: any

          The default value if the value under path is not defined.

        Returns Promise<any>

crmManager: { callAndReceive: ((message: any) => Promise<any>); findAccount: (() => Promise<any>); findOpportunitiesByQuery: ((query: string) => Promise<any>); getAccountAssociatedValue: (() => Promise<any>); getAccountAssociationField: (() => Promise<string>); getCurrentUser: (() => Promise<any>); getOpportunityAssociatedValue: (() => Promise<any>); getOpportunityURL: ((externalId: string) => Promise<string>); getPayload: (() => Promise<any>); getQuoteAccountReferenceField: (() => Promise<string>); getSugarCrmEntityById: ((module: string, id: string) => Promise<any>); isAccountPage: (() => Promise<boolean>); isOpportunityPage: (() => Promise<boolean>); postCall: ((url: string, method: string, payload: any) => Promise<any>); reportOpportunityNumberOfQuotes: (() => Promise<void>); updateCache: ((path: string, data: any) => Promise<void>) }

crmManager enables communication with CRMs in which Pricefx is embedded.

Type declaration

  • callAndReceive: ((message: any) => Promise<any>)
      • (message: any): Promise<any>
      • Triggers postMessage with a message in the window with CRM.

        Example

        const message = {
        fields: [
        { id: 'name', value: 'New name' },
        { id: 'description', value: 'New description' }
        ]
        };
        return crmManager.callAndReceive({ action: 'createNewQuote', data: message })

        Parameters

        • message: any

        Returns Promise<any>

  • findAccount: (() => Promise<any>)
      • (): Promise<any>
      • Will return Account from CRM with provided ID.

        Returns Promise<any>

  • findOpportunitiesByQuery: ((query: string) => Promise<any>)
      • (query: string): Promise<any>
      • Finds opportunities by SQL.
        Salesforce only, this has not been implemented yet in other CRMs.

        Example

        export const crmFindOpportunitiesPre = ({
        result,
        searchText,
        api: { crmManager }
        }) => {
        const query = `
        SELECT Id, Name, StageName, RecordType.Name
        FROM Opportunity
        WHERE Name LIKE '%${searchText}%' LIMIT 300`;
        return crmManager.findOpportunitiesByQuery(query).then(list => {
        list.forEach(item => {
        item.Name = `${item.Name} (${item.RecordType.Name})`;
        });
        result.list = list;
        return result;
        });
        };

        Parameters

        • query: string

        Returns Promise<any>

  • getAccountAssociatedValue: (() => Promise<any>)
      • (): Promise<any>
      • Returns a value of the accountAssociatedValue feature flag.
        The value is set when the application starts and contains a value from CRM account entity.
        The feature flag accountAssociationField will determine which value is used.
        The result is based on CRM which is used with Pricefx.

        For "applicationEnvironment": "salesforce" it will return the value from

        • salesforce.accountAssociatedValue

        For "applicationEnvironment":"c4c" it will return the value from

        • c4c.accountAssociatedValue

        Similarly for other CRMs:

        • dynamics.accountAssociatedValue
        • sugarCRM.accountAssociatedValue

        Returns Promise<any>

  • getAccountAssociationField: (() => Promise<string>)
      • (): Promise<string>
      • Returns a value of the accountAssociationField feature flag.
        The result is based on CRM which is used with Pricefx.

        For "applicationEnvironment": "salesforce" it will return the value from

        • salesforce.accountAssociationField

        For "applicationEnvironment":"c4c" it will return the value from

        • c4c.accountAssociationField

        Similarly for other CRMs:

        • dynamics.accountAssociationField
        • sugarCRM.accountAssociationField

        Returns Promise<string>

  • getCurrentUser: (() => Promise<any>)
      • (): Promise<any>
      • Returns Promise<any>

  • getOpportunityAssociatedValue: (() => Promise<any>)
      • (): Promise<any>
      • Returns a value of the opportunityAssociatedValue feature flag.
        The value is set when the application starts and contains a value from CRM opportunity entity.
        The feature flag opportunityAssociationField will determine which value is used.
        The result is based on CRM which is used with Pricefx.

        For "applicationEnvironment": "salesforce" it will return the value from

        • salesforce.opportunityAssociatedValue

        For "applicationEnvironment":"c4c" it will return the value from

        • c4c.opportunityAssociatedValue

        Similarly for other CRMs:

        • dynamics.opportunityAssociatedValue
        • sugarCRM.opportunityAssociatedValue

        Returns Promise<any>

  • getOpportunityURL: ((externalId: string) => Promise<string>)
      • (externalId: string): Promise<string>
      • Returns a link to the opportunity with provided ID.
        Salesforce only, this has not been implemented yet in other CRMs.

        Parameters

        • externalId: string

          ID of the opportunity which you want to link.

        Returns Promise<string>

  • getPayload: (() => Promise<any>)
      • (): Promise<any>
      • Returns CRM payload. The value of the payload will vary based on CRM which is used with Pricefx.

        Example

        // Get payload from CRM and fill in data from it to a Quote
        export const quotesDetailNew = async ({
        quoteAPI,
        api: { crmManager }
        }) => {
        const payload = await crmManager.getPayload();
        // you can use developer tools and key word:
        // debugger;
        // to observe what is in payload
        await quoteAPI.setHeaderValue('label', payload.Name);
        await quoteAPI.setHeaderInputValue('Customer', payload.Customer_Number__c);
        await quoteAPI.setHeaderInputValue('ProjectID', payload.Project_Id__c);
        await quoteAPI.setHeaderInputValue('ProjectName', payload.Project__c);
        };

        Returns Promise<any>

  • getQuoteAccountReferenceField: (() => Promise<string>)
      • (): Promise<string>
      • This method is deprecated, use getAccountAssociationField instead. Returns a value of the quoteAccountReferenceField feature flag.
        The result is based on CRM which is used with Pricefx.

        For "applicationEnvironment": "salesforce" it will return the value from

        • salesforce.quoteAccountReferenceField

        For "applicationEnvironment":"c4c" it will return the value from

        • c4c.quoteAccountReferenceField

        Similarly for other CRMs:

        • dynamics.quoteAccountReferenceField
        • sugarCRM.quoteAccountReferenceField

        Deprecated

        Returns Promise<string>

  • getSugarCrmEntityById: ((module: string, id: string) => Promise<any>)
      • (module: string, id: string): Promise<any>
      • Loads an entity by ID from the module.
        SugarCRM only

        Example

        const parentAccount = await crmManager.getSugarCrmEntityById('Accounts', parentId);
        

        Parameters

        • module: string
        • id: string

        Returns Promise<any>

  • isAccountPage: (() => Promise<boolean>)
      • (): Promise<boolean>
      • Will return true when Pricefx is embedded under an account page in CRM.

        Returns Promise<boolean>

  • isOpportunityPage: (() => Promise<boolean>)
      • (): Promise<boolean>
      • Will return true when Pricefx is embedded under the opportunity page in CRM.

        Returns Promise<boolean>

  • postCall: ((url: string, method: string, payload: any) => Promise<any>)
      • (url: string, method: string, payload: any): Promise<any>
      • Calls HTTP request in CRM.
        Salesforce only, this has not been implemented yet in other CRMs.

        Example

        // Updating opportunity back in Salesforce
        export const quotesDetailSubmit = async ({
        quoteAPI,
        api: { crmManager, notify }
        }) => {
        const externalRef = await quoteAPI.getHeaderValue('externalRef');
        const opportunityUrl = await crmManager.getOpportunityURL(externalRef);
        const totalValue = await quoteAPI.getHeaderOutputResult('TotalAmount');
        const payloadForSF = {
        PriceFx_Quote_No__c: quoteAPI.getHeaderValue('uniqueName'),
        Amount: totalValue
        };
        crmManager.postCall(opportunityUrl, 'PATCH', payloadForSF).then(() => {
        notify.success('Opportunity was updated.');
        });
        };

        Parameters

        • url: string
        • method: string

          HTTP request methods

        • payload: any

        Returns Promise<any>

  • reportOpportunityNumberOfQuotes: (() => Promise<void>)
      • (): Promise<void>
      • Sends a number of quotes back to SugarCRM.
        It shows this number as a part of the panel name. Currently, users may experience some issues. SugarCRM only

        Deprecated

        Returns Promise<void>

  • updateCache: ((path: string, data: any) => Promise<void>)
      • (path: string, data: any): Promise<void>
      • This function is used to manipulate _initCache in SugarcrmManager. It is mainly used to modify the parent account under the account page in SugarCRM SugarCRM only

        Example

        // Data is a parent account for the current account
        crmManager.updateCache('sugarCRMData.payload.Account', data)

        Parameters

        • path: string
        • data: any

        Returns Promise<void>

fetch: { customer: ((customerId: string) => Promise<Customer>); customerByFilter: ((customFilter: Criteria) => Promise<Customer[]>); customerByName: ((customerName: string) => Promise<Customer[]>); customerExtension: ((tableName: string, filter: Criteria) => Promise<CustomerExtension[]>); productById: ((sku: string) => Promise<any>); productByLabel: ((label: string) => Promise<Product[]>) }

Type declaration

  • customer: ((customerId: string) => Promise<Customer>)
      • (customerId: string): Promise<Customer>
      • Parameters

        • customerId: string

        Returns Promise<Customer>

  • customerByFilter: ((customFilter: Criteria) => Promise<Customer[]>)
      • (customFilter: Criteria): Promise<Customer[]>
      • Parameters

        • customFilter: Criteria

        Returns Promise<Customer[]>

  • customerByName: ((customerName: string) => Promise<Customer[]>)
      • (customerName: string): Promise<Customer[]>
      • Parameters

        • customerName: string

        Returns Promise<Customer[]>

  • customerExtension: ((tableName: string, filter: Criteria) => Promise<CustomerExtension[]>)
  • productById: ((sku: string) => Promise<any>)
      • (sku: string): Promise<any>
      • Parameters

        • sku: string

        Returns Promise<any>

  • productByLabel: ((label: string) => Promise<Product[]>)
      • (label: string): Promise<Product[]>
      • Parameters

        • label: string

        Returns Promise<Product[]>

navigate: ((targetPage: string, targetPageState: any) => Promise<void>)

Type declaration

    • (targetPage: string, targetPageState: any): Promise<void>
    • Parameters

      • targetPage: string
      • targetPageState: any

      Returns Promise<void>

API for displaying notifications.

Type declaration

  • alert: NotificationMessage

    Displays a blue notification message.

  • error: NotificationMessage

    Displays a red notification message.

    Example

    // Will display a notification message with the text: "Error message, with help link"
    // where help is a link to https://help.me.
    // The notification will stay on the screen, the user has to close it.

    notify.error(
    'Error message, with help link',
    {
    urlName: "help",
    url: "https://help.me",
    duration: 0
    }
    )
  • info: NotificationMessage

    Displays a blue notification message.

  • success: NotificationMessage

    Displays a green notification message.

  • warning: NotificationMessage

    Displays an orange notification message.

translate: ((key: string, params?: Record<string, string | number>) => Promise<string>)

Type declaration

    • (key: string, params?: Record<string, string | number>): Promise<string>
    • Parameters

      • key: string
      • Optional params: Record<string, string | number>

      Returns Promise<string>

url: { getParameters: ((url: string) => Promise<string>) }

Type declaration

  • getParameters: ((url: string) => Promise<string>)
      • (url: string): Promise<string>
      • Parameters

        • url: string

        Returns Promise<string>

Generated using TypeDoc