|
| 1 | +============================================================ |
| 2 | +Push source in a scratch org |
| 3 | +============================================================ |
| 4 | +sfdx force:org:create --definitionfile config/project-scratch-def.json --setalias MyScratchOrg --targetdevhubusername [email protected] --wait 10 |
| 5 | +sfdx force:source:push --targetusername MyScratchOrg --forceoverwrite |
| 6 | +sfdx force:user:permset:assign --targetusername MyScratchOrg --permsetname OrgCheck_Users |
| 7 | +profileName=$(sfdx force:data:soql:query --targetusername MyScratchOrg --query "SELECT Name FROM Profile WHERE UserLicense.MasterLabel = 'Salesforce' AND Name LIKE '%Admin%' AND PermissionsViewAllData = true LIMIT 1" --resultformat=csv | tail -1) |
| 8 | +sfdx force:user:create --setalias uatuser --definitionfile config/user-uat-def.json "profileName=${profileName}" permsets=OrgCheck_Users --targetusername MyScratchOrg |
| 9 | + |
| 10 | +uatUserId=$(sfdx force:data:soql:query --query "SELECT Id FROM User WHERE Profile.Name = '${profileName}' AND IsActive = true" --resultformat=csv --targetusername MyScratchOrg | tail -1) |
| 11 | + |
| 12 | +## Set French Local/Language |
| 13 | +sfdx force:data:record:update --sobjectid "${uatUserId}" --sobjecttype User --values "LocaleSidKey=fr LanguageLocaleKey=fr" --targetusername MyScratchOrg |
| 14 | + |
| 15 | +## Set English Local/Language |
| 16 | +sfdx force:data:record:update --sobjectid "${uatUserId}" --sobjecttype User --values "LocaleSidKey=en_US LanguageLocaleKey=en_US" --targetusername MyScratchOrg |
| 17 | + |
| 18 | +## Set Japanese Local/Language |
| 19 | +sfdx force:data:record:update --sobjectid "${uatUserId}" --sobjecttype User --values "LocaleSidKey=ja LanguageLocaleKey=ja" --targetusername MyScratchOrg |
| 20 | + |
| 21 | +## In case of persistente language, please close all browsers before launching the next command. |
| 22 | +sfdx force:org:open --targetusername uatuser |
| 23 | + |
| 24 | + |
| 25 | +sfdx force:user:list --targetusername MyScratchOrg |
| 26 | +sfdx force:org:open --targetusername MyScratchOrg |
| 27 | + |
| 28 | +sfdx force:org:delete --targetusername MyScratchOrg |
| 29 | + |
| 30 | + |
| 31 | +============================================================ |
| 32 | +List of usefull commands for packaging |
| 33 | +============================================================ |
| 34 | +sfdx force:package:version:list |
| 35 | +sfdx force:package:version:create --package OrgCheck --definitionfile config/project-scratch-def.json --installationkeybypass --codecoverage --wait 10 |
| 36 | +sfdx force:package:version:promote --package [email protected] |
| 37 | + |
| 38 | + |
| 39 | + |
| 40 | + |
| 41 | +============================================================ |
| 42 | +List of usefull commands for pushing updates |
| 43 | +============================================================ |
| 44 | + |
| 45 | +## List the push request to update to a newer package version |
| 46 | +sfdx force:data:soql:query [email protected] --query "SELECT Id, PackageVersionId, ScheduledStartTime, Status, SystemModstamp, StartTime, EndTime, DurationSeconds FROM PackagePushRequest WHERE SystemModstamp = TODAY" --resultformat=csv |
| 47 | + |
| 48 | +## List all the subscriber part of the previous push request |
| 49 | +sfdx force:data:soql:query [email protected] --query "SELECT Id, PackagePushRequestId, SubscriberOrganizationKey, Status, SystemModstamp, StartTime, EndTime, DurationSeconds FROM PackagePushJob where SystemModstamp = today" --resultformat=csv |
| 50 | + |
| 51 | +## CHeck the pending and in progress |
| 52 | +sfdx force:data:soql:query [email protected] --query "SELECT Id, PackagePushRequestId, SubscriberOrganizationKey, Status, SystemModstamp, StartTime, EndTime, DurationSeconds FROM PackagePushJob where SystemModstamp = today and status != 'Succeeded' and status != 'failed'" --resultformat=csv |
| 53 | + |
| 54 | +## List all error you had during the previous push |
| 55 | +sfdx force:data:soql:query [email protected] --query "SELECT Id, PackagePushJobId, ErrorMessage, ErrorDetails, ErrorTitle, ErrorSeverity, ErrorType, SystemModstamp FROM PackagePushError where SystemModstamp = TODAY" --resultformat=csv |
| 56 | + |
| 57 | + |
| 58 | + |
| 59 | + |
| 60 | + |
| 61 | +============================================================ |
| 62 | +Issues with Permission Set including unwanted CRUDs & FLS |
| 63 | +============================================================ |
| 64 | + |
| 65 | +If needed, you should emptied the Permission Set (to make sure it does not include any reference to sobjects): |
| 66 | + |
| 67 | +NOTE: |
| 68 | +If the anonymous script ends with "Internal Error", you simply go to the permission set setup, |
| 69 | +edit one of the CRUD and unselect "Create" for a random object. You save. From there the |
| 70 | +anonymous script will work again. The SOAP/REST api cannot perform an update. |
| 71 | + |
| 72 | +( |
| 73 | + echo "List<ObjectPermissions> ops = [SELECT Id, ParentId, SobjectType FROM ObjectPermissions WHERE Parent.Name = 'OrgCheck_Users']; " |
| 74 | + echo "Database.delete(ops, false); "; |
| 75 | + echo "List<FieldPermissions> fps = [SELECT Id, ParentId, Field FROM FieldPermissions WHERE Parent.Name = 'OrgCheck_User']; "; |
| 76 | + echo "Database.delete(fps, false); "; |
| 77 | +) > /tmp/OrgCheck_Users_ObjectPermissions_Removal.apex |
| 78 | + |
| 79 | +for i in {1..3}; do |
| 80 | + echo "Turn #${i}" |
| 81 | + nbCRUDs=$( \ |
| 82 | + sfdx force:data:soql:query \ |
| 83 | + --query "SELECT Id FROM ObjectPermissions WHERE Parent.Name = 'OrgCheck_Users'" \ |
| 84 | + --resultformat=csv \ |
| 85 | + | egrep -v '(^(Id$)|()' | wc -l | tr -d ' ' \ |
| 86 | + ) |
| 87 | + nbFLSs=$( \ |
| 88 | + sfdx force:data:soql:query \ |
| 89 | + --query "SELECT Id FROM FieldPermissions WHERE Parent.Name = 'OrgCheck_Users'" \ |
| 90 | + --resultformat=csv \ |
| 91 | + | egrep -v '(^Id$)|()' | wc -l | tr -d ' ' \ |
| 92 | + ) |
| 93 | + echo "Permission Set <OrgCheck_Users> has ${nbCRUDs} CRUDs and ${nbFLSs} FLSs" |
| 94 | + sfdx force:apex:execute --apexcodefile /tmp/OrgCheck_Users_ObjectPermissions_Removal.apex 2>&1 >/dev/null; |
| 95 | +done |
| 96 | + |
| 97 | +echo "Permission Set <OrgCheck_Users> has now the following CRUDs and FLSs:" |
| 98 | +sfdx force:data:soql:query \ |
| 99 | + --query "SELECT Id, SobjectType, Parent.Name FROM ObjectPermissions WHERE Parent.Name = 'OrgCheck_Users'" |
| 100 | +sfdx force:data:soql:query \ |
| 101 | + --query "SELECT Id, Field, Parent.Name FROM FieldPermissions WHERE Parent.Name = 'OrgCheck_Users'" |
| 102 | + |
0 commit comments