0

I have enabled Tags on a Custom Object and I am trying to insert a Tag by a following code

insert new CustomObject__tag(Type='Public',ItemId='a0023000000DtDuEAK',name='Custom Tag' );

When I execute the code I receive an error

System.DmlException: Insert failed. First exception on row 0; first error: INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY, insufficient access rights on cross-reference id: []"

Usually this happens when a user doesn't have a Read permission to the corresponding record, but I am the owner of the record and have full access permission to custom object record.

How can I avoid this error?

0

Once Topics are enabled, Public tags are deactivated. To workaround this problem, a private tag can be created by using the following code

insert new CustomObject__tag(Type='Personal',ItemId='a0023000000DtDuEAK',name='Custom Tag' );

https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_objects_accounttag.htm

Defines the visibility of a tag.
Valid values:
Public — The tag can be viewed and manipulated by all users in an organization.
Personal — The tag can be viewed or manipulated only by a user with a matching OwnerId.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.