Skip to content

Commit

Permalink
fix composite api
Browse files Browse the repository at this point in the history
  • Loading branch information
dufoli committed May 14, 2024
1 parent e6ebc8b commit e591fb3
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions addon/popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,11 @@ function initLinks({sfHost}){

function toCompositeRequest(queries) {
let compositeRequest = [];
for (const query in queries) {
for (const q in queries) {
compositeRequest.push({
"method": "GET",
"url": "/services/data/v" + apiVersion + "/query/?q=" + encodeURIComponent(query),
"referenceId": "fullData"
"url": "/services/data/v" + apiVersion + "/query/?q=" + encodeURIComponent(queries[q]),
"referenceId": q
});
}
return {
Expand Down Expand Up @@ -739,7 +739,7 @@ class AllDataBoxUsers extends React.PureComponent {
const fullQuerySelect = "select Id, Name, Email, Username, UserRole.Name, Alias, LocaleSidKey, LanguageLocaleKey, IsActive, ProfileId, Profile.Name";
const minimalQuerySelect = "select Id, Name, Email, Username, UserRole.Name, Alias, LocaleSidKey, LanguageLocaleKey, IsActive";
const queryFrom = "from User where (username like '%" + userQuery + "%' or name like '%" + userQuery + "%') order by IsActive DESC, LastLoginDate limit 100";
const compositeQuery = toCompositeRequest([fullQuerySelect + " " + queryFrom, minimalQuerySelect + " " + queryFrom]);
const compositeQuery = toCompositeRequest({fullData: fullQuerySelect + " " + queryFrom, minimalData: minimalQuerySelect + " " + queryFrom});

try {
setIsLoading(true);
Expand Down Expand Up @@ -775,7 +775,7 @@ class AllDataBoxUsers extends React.PureComponent {
const mediumQuerySelect = "SELECT Id, Name, Email, Username, UserRole.Name, Alias, LocaleSidKey, LanguageLocaleKey, IsActive, FederationIdentifier, ProfileId, Profile.Name, ContactId";
const minimalQuerySelect = "SELECT Id, Name, Email, Username, UserRole.Name, Alias, LocaleSidKey, LanguageLocaleKey, IsActive, FederationIdentifier, ContactId";
const queryFrom = "FROM User WHERE Id='" + selectedUserId + "' LIMIT 1";
const compositeQuery = toCompositeRequest([fullQuerySelect + " " + queryFrom, mediumQuerySelect + " " + queryFrom, minimalQuerySelect + " " + queryFrom]);
const compositeQuery = toCompositeRequest({fullData: fullQuerySelect + " " + queryFrom, mediumData: mediumQuerySelect + " " + queryFrom, minimalData: minimalQuerySelect + " " + queryFrom});

try {
setIsLoading(true);
Expand Down Expand Up @@ -1098,7 +1098,7 @@ class AllDataBoxShortcut extends React.PureComponent {
const flowSelect = "SELECT LatestVersionId, ApiName, Label, ProcessType FROM FlowDefinitionView WHERE Label LIKE '%" + shortcutSearch + "%' LIMIT 30";
const profileSelect = "SELECT Id, Name, UserLicense.Name FROM Profile WHERE Name LIKE '%" + shortcutSearch + "%' LIMIT 30";
const permSetSelect = "SELECT Id, Name, Label, Type, LicenseId, License.Name, PermissionSetGroupId FROM PermissionSet WHERE Label LIKE '%" + shortcutSearch + "%' LIMIT 30";
const compositeQuery = toCompositeRequest([flowSelect, profileSelect, permSetSelect]);
const compositeQuery = toCompositeRequest({flowSelect, profileSelect, permSetSelect});

const searchResult = await sfConn.rest("/services/data/v" + apiVersion + "/composite", {method: "POST", body: compositeQuery});
let results = searchResult.compositeResponse.filter((elm) => elm.httpStatusCode == 200 && elm.body.records.length > 0);
Expand Down

0 comments on commit e591fb3

Please sign in to comment.