0

When I try to check user field access for certain fields, I receive two different gack Id errors

sf data query -q "SELECT Id, IsAccessible, IsUpdatable FROM UserFieldAccess WHERE DurableId = 'Account.00NDx000002FZkWMAW.005Hp00000iQiH3IAK' LIMIT 1"

The first one is

An unexpected error occurred. Please include this ErrorId if you contact support: 1816650657-166082 (-1712909162)

and for another query

SELECT Id, IsAccessible, IsUpdatable FROM UserFieldAccess WHERE DurableId = 'Account.00NDx000002FZB1MAO.005Hp00000iQiH3IAK' LIMIT 1

the second one is

An unexpected error occurred. Please include this ErrorId if you contact support: 505127584-158863 (529965368)

Why? How can I avoid those?

1 Answer 1

0

When I build my script to verify field access for certain fields for one user, I have implemented several auxiliary script

getUserId.sh

sf data query -q "SELECT Id FROM User WHERE $1 = '$2' LIMIT 1" --json | jq '.result.records[0].Id' -r

getFieldId.sh

sf data query -q "SELECT Id FROM CustomField where EntityDefinitionId = '$1' AND DeveloperName = '$2'" -t --json | jq '.result.records[0].Id' -r

and getUserFieldAccess.sh

sf data query -q "SELECT Id, IsAccessible, IsUpdatable FROM UserFieldAccess WHERE DurableId = '$1.$2.$3' LIMIT 1"

and finally the script to check access

checkFieldsAccess.sh

userId=$(./getUserId.sh "Profile.Name" "Salesforce API Only System Integrations")
for field in Field1 Field2 Field3 Field4 Field5
do
    fieldId=$(./getFieldId.sh Account $field)
    echo "Verifying access for $field field with Id $fieldId for user $userId"
    ./getUserFieldAccess.sh Account $fieldId $userId
done

So actually I need to chop off the last three symbols from the Field Id so it has 15 and not 18 symbols

userId=$(./getUserId.sh "Profile.Name" "Salesforce API Only System Integrations")
for field in Field1 Field2 Field3 Field4 Field5
do
    fieldId=$(./getFieldId.sh Account $field)
    len=${#fieldId}
    fieldId=${fieldId:0:$len-3}
    echo "Verifying access for $field field with Id $fieldId for user $userId"
    ./getUserFieldAccess.sh Account $fieldId $userId
done

You must log in to answer this question.

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