Problem Profile Editor Update (v0.2)
Simple update to the package to select inaccessible profiles.
Amazing and simple update to our Problem Profile Editor—haven’t heard of it? Check out the original post.
Received some great feedback from Michael over at Free Like A Puppy about a gap in the approach. When trying to deactivate a record type, Salesforce threw up the warning:
This record type [Name of Record Type] cannot be deactivated because the following profiles use this record type as default.
Unfortunately, one of these Profiles was the Platform Integration User
Salesforce Help tells us “…you can’t view the detailed user record. Salesforce users don’t have permission to view or edit the Platform Integration User.”
This explained why the simple query of the Profile object wasn’t returning this profile (and a few others).
A quick discovery idea came up with a way to find the record ids for this type of “inaccessible” profile:
1
2
3
SELECT Id, Name, ProfileId, Profile.Id, Profile.Name
FROM User
WHERE ProfileId != null AND Profile.Id = null
Using this simple query, it wasn’t hard to convert it to the GraphQL Syntax (my new favorite approach to avoid writing Apex for simple LWCs) and incorporate the results to the picklist of Profiles.
As a reminder, I’ve decided to make this project an 🔓📦 unlocked package and the repository is open-source.
But if you’re curious, here’s what the GQL version of the SOQL looks like as an LWC’s GraphQL @wire adapter.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
@wire(graphql, { query: '$gqlQueryUserProfile', variables: "$params" })
graphqlQueryResultUserProfiles(result) {
this.gqlUserProfileData = result;
let data = result.data;
let errors = result.errors;
if (data) {
let result = data.uiapi.query.User;
let records = result.edges.map((edge) => {
let field = edge.node;
return {
"value": field.ProfileId.value,
"label": field.Name.value,
}
});
this.addOptions(records);
this.isLoaded = true;
} else if (errors) {
console.log('GQL WIRE FAILED');
console.log(JSON.stringify(errors));
} else {
this.profileOptions = [];
}
}
get params() {
return {};
}
get gqlQueryUserProfile() {
return gql`
query userprofiles {
uiapi {
query {
User(
first: 100
where: {
ProfileId: { ne: null }
Profile: {
Id: { eq: null }
}
}
orderBy: {
Name: { order: ASC }
}
) {
edges {
node {
Id
Name { value }
ProfileId { value }
}
}
}
}
}
}
`;
}
Installation Info
- v0.2 - 2025-APR-12
- Sandbox & Scratch Orgs
- https://test.salesforce.com/packaging/installPackage.apexp?p0=04t3x000001ZqqqAAC
- Production & Developer Edition Orgs
- https://login.salesforce.com/packaging/installPackage.apexp?p0=04t3x000001ZqqqAAC