Skip to content

Conversation

@maliroteh-sf
Copy link
Contributor

What does this PR do?
If no value is provided for the flag --name then interactively prompts the user to select a lightning experience app.

What issues does this PR fix or reference?
@W-16599797@

@maliroteh-sf maliroteh-sf requested a review from a team as a code owner October 9, 2024 18:31
Comment on lines +63 to +82
const appMenuItemsQuery =
'SELECT Label,Description,Name FROM AppMenuItem WHERE IsAccessible=true AND IsVisible=TRUE';
const appMenuItems = await connection.query<{ Label: string; Description: string; Name: string }>(
appMenuItemsQuery
);

const appDefinitionsQuery = "SELECT DeveloperName,DurableId FROM AppDefinition WHERE UiType='Lightning'";
const appDefinitions = await connection.query<{ DeveloperName: string; DurableId: string }>(appDefinitionsQuery);

appMenuItems.records.forEach((item) => {
const match = appDefinitions.records.find((definition) => definition.DeveloperName === item.Name);
if (match) {
results.push({
DeveloperName: match.DeveloperName,
Label: item.Label,
Description: item.Description,
DurableId: match.DurableId,
});
}
});
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally we would do all of this in a single SQL statement using JOIN but as I understand it SF SOQL statements don't support JOIN so instead I run 2 query and filter in code (since it won't be the case that an org would have thousands and thousands of apps... but rather a handful of apps)

// The appName is optional but if the user did provide an appName then it must be
// a valid one.... meaning that it should resolve to a valid appId.
const appId = await OrgUtils.getAppDefinitionDurableId(connection, appName);
if (!appId) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If appName is not valid, should user be prompted too?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's not part of the UX design so we error out instead (which is consistent with the behavior of the Beta version).

Copy link
Contributor

@sfdctaka sfdctaka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@maliroteh-sf maliroteh-sf merged commit e4fee0e into main Oct 11, 2024
13 checks passed
@maliroteh-sf maliroteh-sf deleted the app-name branch October 11, 2024 17:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants