5

In earlier versions < 7.84.2 sfdx force:user:permset:assign command was working fine, but in latest version it is throwing error Permission set "U" not found in target org. Do you need to push source?

Does anybody faced the similar issue with latest version? and know what would be the possible root cause for it.

Thanks in advance.

3 Answers 3

3

When you compare the last release v50 with the older, It looks like you have to add double quote around usernames now

V48enter image description here

V50 enter image description here

UPDATE : a case has been logged https://github.com/forcedotcom/cli/issues/802 and the team ask to use sfdx plugins:install user until they release a patch

3
  • Thanks @Badbaxx. But it doesn't resolve the issue. At a matter of fact we already have the quotes around username.
    – Amit
    Jan 15, 2021 at 15:04
  • 2
    I don't know if it is from your team but a case have been created on the subject github.com/forcedotcom/cli/issues/802
    – Badbaxx
    Jan 15, 2021 at 15:12
  • Thanks again @Badbaxx. That is exactly the issue. And I can confirm it resolves post applying the suggested workaround there.
    – Amit
    Jan 15, 2021 at 15:17
0

I think we can use another workaround without having to install any plugin.

Just create a file scripts/apex/assignCurrentUser.apex with a code

PermissionSet ps = [SELECT Id FROM PermissionSet WHERE Name = 'PermName'];
List<PermissionSetAssignment> psas = new List<PermissionSetAssignment>();

for (Id uid: new List<Id>{UserInfo.getUserId()}) {
    psas.add(new PermissionSetAssignment(AssigneeId = uid, PermissionSetId = ps.Id));
}
insert psas;

and the bash file assignCurrentUser.sh

code=$(cat scripts/apex/assignCurrentUser.apex)        
echo "${code/PermName/$1}" > temp.apex
sfdx force:apex:execute -f temp.apex
rm temp.apex

and then just execute it

./assignCurrentUser.sh PermissionSetName
0

This simply means that in the directory the permsets are missing, you might have to reload the source of the folder to populate the permsets directory under force-app/main/default

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .