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) => Promise<any>);
    product: ((product) => Promise<any>);
}

Type declaration

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

        • customer: any

        Returns Promise<any>

  • product: ((product) => Promise<any>)
      • (product): Promise<any>
      • Add a new product to products

        Parameters

        • product: any

        Returns Promise<any>

        Example

        ...
        await add.product({
        sku: 'KS-2003',
        label: 'Test2',
        unitOfMeasure: 1,
        currency: 'CZK',
        formulaName: 'ActionButtons',
        attribute18: 'A'
        });
        ...
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, value) => Promise<void>);
    retrieveConfig: ((path, defaultValue?) => Promise<any>);
}

Type declaration

  • overrideConfig: ((path, value) => Promise<void>)
      • (path, value): 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, defaultValue?) => Promise<any>)
      • (path, defaultValue?): 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

        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>

        Example

        const visibleDashboards = await configuration.retrieveConfig(
        'customerSpecificFeatureFlag.dashboards.visible.account',
        []
        );
crmManager: {
    callAndReceive: ((message) => Promise<any>);
    findAccount: (() => Promise<any>);
    findOpportunitiesByQuery: ((query) => Promise<any>);
    getAccountAssociatedValue: (() => Promise<any>);
    getAccountAssociationField: (() => Promise<string>);
    getCurrentUser: (() => Promise<any>);
    getOpportunityAssociatedValue: (() => Promise<any>);
    getOpportunityURL: ((externalId) => Promise<string>);
    getPayload: (() => Promise<any>);
    getQuoteAccountReferenceField: (() => Promise<string>);
    getSugarCrmEntityById: ((module, id) => Promise<any>);
    isAccountPage: (() => Promise<boolean>);
    isOpportunityPage: (() => Promise<boolean>);
    postCall: ((url, method, payload) => Promise<any>);
    reportOpportunityNumberOfQuotes: (() => Promise<void>);
    updateCache: ((path, data) => Promise<void>);
}

crmManager enables communication with CRMs in which Pricefx is embedded.

Type declaration

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

        Parameters

        • message: any

        Returns Promise<any>

        Example

        const message = {
        fields: [
        { id: 'name', value: 'New name' },
        { id: 'description', value: 'New description' }
        ]
        };
        return crmManager.callAndReceive({ action: 'createNewQuote', data: message })
  • findAccount: (() => Promise<any>)
      • (): Promise<any>
      • Will return Account from CRM with provided ID.

        Returns Promise<any>

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

        Parameters

        • query: string

        Returns Promise<any>

        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;
        });
        };
  • 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) => Promise<string>)
      • (externalId): 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.

        Returns Promise<any>

        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);
        };
  • 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

        Returns Promise<string>

        Deprecated

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

        Parameters

        • module: string
        • id: string

        Returns Promise<any>

        Example

        const parentAccount = await crmManager.getSugarCrmEntityById('Accounts', parentId);
        
  • 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, method, payload) => Promise<any>)
      • (url, method, payload): Promise<any>
      • Calls HTTP request in CRM.
        Salesforce, SugarCRM only, this has not been implemented yet in other CRMs.

        Parameters

        • url: string
        • method: string

          HTTP request methods

        • payload: any

        Returns Promise<any>

        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.');
        });
        };
  • 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

        Returns Promise<void>

        Deprecated

  • updateCache: ((path, data) => Promise<void>)
      • (path, data): 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

        Parameters

        • path: string
        • data: any

        Returns Promise<void>

        Example

        // Data is a parent account for the current account
        crmManager.updateCache('sugarCRMData.payload.Account', data)
fetch: {
    customer: ((customerId) => Promise<Customer>);
    customerByFilter: ((customFilter) => Promise<Customer[]>);
    customerByName: ((customerName) => Promise<Customer[]>);
    customerExtension: ((tableName, filter) => Promise<CustomerExtension[]>);
    productById: ((sku) => Promise<any>);
    productByLabel: ((label) => Promise<Product[]>);
}

Type declaration

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

        • customerId: string

        Returns Promise<Customer>

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

        • customFilter: Criteria

        Returns Promise<Customer[]>

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

        • customerName: string

        Returns Promise<Customer[]>

  • customerExtension: ((tableName, filter) => Promise<CustomerExtension[]>)
      • (tableName, filter): Promise<CustomerExtension[]>
      • Parameters

        • tableName: string
        • filter: Criteria

        Returns Promise<CustomerExtension[]>

  • productById: ((sku) => Promise<any>)
      • (sku): Promise<any>
      • Parameters

        • sku: string

        Returns Promise<any>

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

        • label: string

        Returns Promise<Product[]>

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

Type declaration

    • Allow page navigation using interceptor API. It is possible to use appPages to define target.

      Parameters

      • targetPage: string
      • targetPageState: any

      Returns Promise<void>

      Example

      // Navigate to new Quote page

      export const quotesListDataLoad = async ({ api, response, appPages }) => {
      const { notify, navigate } = api;
      const { totalRows, data } = response;
      if (totalRows === 0) {
      await notify.success(
      'There is no relevant quote existing, go to the create-new page!'
      );
      await navigate(appPages.QC_NEW_QUOTE);
      } else if (totalRows > 0) {
      const id = data[0]?.typedId;
      await navigate(appPages.QC_NEW_QUOTE, { id });
      }
      };
notify: {
    alert: NotificationMessage;
    error: NotificationMessage;
    info: NotificationMessage;
    success: NotificationMessage;
    warning: NotificationMessage;
}

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, params?) => Promise<string>)

Type declaration

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

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

      Returns Promise<string>

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

Type declaration

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

        • url: string

        Returns Promise<string>

Generated using TypeDoc