Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagejs
await api.add.product({
  sku: 'KS-2003',
  label: 'Test2',
  unitOfMeasure: 1,
  currency: 'CZK',
  formulaName: 'ActionButtons',
  attribute18: 'A'
});

...

Code Block
languagejs
await api.app.getCurrentUser()
/*
{
  "version": 2,
  "typedId": 123,
  "loginName": "donatas.ka",
  ...
}
*/

...

Code Block
languagejs
await api.configuration.overrideConfig(
  'applicationEnvironment',
  'salesforce'
);

...

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

...

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

...

Code Block
languagejs
export const quotesDetailNew = async ({
  quoteAPI,
  api:
{ crmManager }
}) => {
  const payload = await api.crmManager.getPayload();
  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);
};

...

Code Block
languagejs
const parentAccount = await api.crmManager.getSugarCrmEntityById('Accounts', parentId);

...

Returns true when Pricefx is embedded under an account page in CRM.

Example:

Code Block
languagejs
export const quotesDetailSubmit = async ({
  api
}) => {
  if(await api.crmManager.isAccountPage()) {
    await api.notify.success('We on account page');
  }
};

isOpportunityPage

Code Block
languagetypescript
isOpportunityPage: (() => Promise<boolean>)

Returns true when Pricefx is embedded under the opportunity page in CRM.

Example:

Code Block
languagejs
export const quotesDetailSubmit = async ({
  api
}) => {
  if(await api.crmManager.isOpportunityPage()) {
    await api.notify.success('We on opportunity page');
  }
};

postCall

Code Block
languagetypescript
postCall: ((url, method, payload) => Promise<any>)

...

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

...