Available Actions
-
getPayload
-
getEntityURL
-
getEntityById
-
findOpportunities
-
updateOpportunity
-
updateLineItems
Default Values
-
sugarCrm opportunities path = Opportunities
-
sugarCrm accounts path = Accounts
-
sugarCrm lineItems path = Products
-
sugarCrm employees path = Employees
How to Change Default Path
JavaScript
data = {
objectPath: {
opportunities: "a",
accounts: "b",
lineItems: "c",
employees: "d",
}
//......
}
Get Current Opened Object Data (getPayload)
await crmManager
.callAndReceive({
action: "getPayload",
data: {},
})
.then(async (response) => {
console.log(response);
});
getEntityURL
await crmManager
.callAndReceive({ action: 'getEntityURL', data: {} })
.then(async response => {
console.log(response);
});
How to Get Data from Any Page in SugarCRM (getEntityById)
JavaScript
const data = {
module: "RevenueLineItems",
id: "1358f6d6-d20f-11ed-91f1-022cb44f7f76"
}
await crmManager
.callAndReceive({ action: "getEntityById", data })
.then(async (response) => {
// response will return data with value from specified page
}
.catch((reason) => {
console.error("....No message from sugarCRM", reason);
})
Get ID and Name of Opportunity (findOpportunities)
Opportunity can be searched in two ways:
1. SearchText
This function is used by Assign Opportunity to display a list of opportunities when searched.
JavaScript
await crmManager
.callAndReceive({
action: 'findOpportunities',
data: { searchText: 'opportunityDetail' } // search by name
})
.then(async response => {
console.log(response);
});
-
Filter
JavaScript
await crmManager
.callAndReceive({
action: 'findOpportunities',
data: {
filter: [
{
name: 'opportunity'
},
{
status: 'quoted'
}
]
}
})
.then(async response => {
console.log(response);
});
Update/Create Opportunity in SugarCRM (updateOpportunity)
JavaScript
const data = {
accountAssociationField:
await crmManager.getAccountAssociationField(),
accountAssociatedValue: '123',
data: {
name: 'new opportunity',
description: 'create opportunity',
account_id: '123',
account_name: '123'
}
}
await crmManager
.callAndReceive({
action: 'updateOpportunity',
data
})
.then(async response => {
console.log(response);
});
How to Create/Update Line Items in SugarCRM (updateLineItems)
const data = {
allowDelete: true, // To allow only update/create change field value to false // Opportunity line item is deleted if line item is attached to opportunity and lineitem is removed from Pricefx
opportunityAssociationField: "opportunity_id",
opportunityAssociatedValue: "66308bde-375a-11ee-9f44-0682adde4eb8",
lineItems: [
{
name: "Quote from Pricefx Nothing Phone (1)",
lineItemAssociationField: "id",
lineItemAssociatedValue: "38655026-3855-11ee-85fb-0682adde4eb8", // For testing: insert id of the opportunity line item to update it
status: "Quoted",
},
{
name: "Quote from Pricefx Samsung galaxy S24 Ultra",
lineItemAssociationField: "id",
lineItemAssociatedValue: "", // For testing: if inserted id does not exist in SugarCRM or if field is empty opportunity line item will be created
status: "Quoted",
},
],
};
await crmManager
.callAndReceive({
action: "updateLineItems",
data,
})
.then(async (response) => {
console.log(response);
});