You need to sign in to do that
Don't have an account?

get objPerms then build Map
Hey Guys,
I need to get Object Permissions then build a Map doing something like
'<Parent__r.ProfileId, ObjectPermissions>
map<Id, ObjectPermissions[]>'
I have wriiten a piece of code below, but the error says (SELECT Id, //Whichever other fields I may need
SELECT is an unexpected token
Also follwoing the data model on http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_erd_profile_permissions.htm
the code below seems to be not following the diagram.
//get objPerms then build Map<Parent__r.ProfileId, ObjectPermissions>
// map<Id, ObjectPermissions[]>
//from ObjectPermissions Parent__r.ProfileId in the set
map<Id, ObjectPermissions[]> mapProfileIdtoObjectPermissions = new map<Id, ObjectPermissions[]>();
for(PermissionSet PS : [SELECT Id, ProfileId
(SELECT Id, //Whichever other fields I may need
FROM ObjectPermissions) // could have issue with ObjectPermissions, I need to get correct child name
FROM PermissionSet
WHERE ProfileId IN: profileIds]){
//we check whether the key has already been put to the map, if not, we perform a put
if(mapProfileIdtoObjectPermissions.get(PS.ProfileId) == null)
mapProfileIdtoObjectPermissions.put(PS.ProfileId, new list<ObjectPermissions>{PS.ObjectPermissions});
// else, the key has already been put, so we just add all ObjectPermissions that are related to this ProfileId
else
mapProfileIdtoObjectPermissions.get(PS.ProfileId).addAll(PS.ObjectPermissions);
}
If someone could help I would appreciate there I am noew to Salesforce and its programming language.
Thanks
I think Ive spotted something
(SELECT Id, //Whichever other fields I may need
Remove the ','
All Answers
I think Ive spotted something
(SELECT Id, //Whichever other fields I may need
Remove the ','
I tried, but I think the problem is more than that.
Thanks for your help. :)
Try putting a comma after ProfileId like this:
Thanks it solved the problem.
No problem