You need to sign in to do that
Don't have an account?
Tusar
Apex for loop string concanate
Hello - I am trying to loop through the permissionset object and trying to store the value in a variable, and trying to concanate for each loop.
However it seems, the underlined syntax is not working,
Any thoughts?
for (PermissionSetAssignment psa : [SELECT PermissionSet.Label FROM PermissionSetAssignment WHERE
PermissionSet.ISOWNEDBYPROFILE = false AND AssigneeId = :u.Id])
{ //query for the permission set Users that are already assigned
//usersWithAccess.add(psa.AssigneeId); //add the Id of each assigned User to our set
Userfunctiontype += Userfunctiontype;
System.debug(Userfunctiontype);
if(permissionsetname.indexOf(Opportunity) !=-1)
{
Userfunctiontype = 'OpportunityMgmt';
}
else if(permissionsetname.indexOf(Tracker) !=-1)
{
Userfunctiontype = 'Demo1';
}
else if(permissionsetname.indexOf(Connect) !=-1)
{
Userfunctiontype = 'Demo2';
}
}
s.put(usertype,Userfunctiontype);
update scope;
However it seems, the underlined syntax is not working,
Any thoughts?
for (PermissionSetAssignment psa : [SELECT PermissionSet.Label FROM PermissionSetAssignment WHERE
PermissionSet.ISOWNEDBYPROFILE = false AND AssigneeId = :u.Id])
{ //query for the permission set Users that are already assigned
//usersWithAccess.add(psa.AssigneeId); //add the Id of each assigned User to our set
Userfunctiontype += Userfunctiontype;
System.debug(Userfunctiontype);
if(permissionsetname.indexOf(Opportunity) !=-1)
{
Userfunctiontype = 'OpportunityMgmt';
}
else if(permissionsetname.indexOf(Tracker) !=-1)
{
Userfunctiontype = 'Demo1';
}
else if(permissionsetname.indexOf(Connect) !=-1)
{
Userfunctiontype = 'Demo2';
}
}
s.put(usertype,Userfunctiontype);
update scope;
However, might I suggest a better solution. Instead of keeping them all in a running and concatinating them like that, instead use a List of Strings and then combine the list at the end
This would also allow you to create a Set<String> to make it so that each type only shows up in your concatenated list once.